Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Programmers, Help !!

Author: Robert Hyatt

Date: 08:27:29 04/22/02

Go up one level in this thread


On April 22, 2002 at 10:04:27, Matthias Gemuh wrote:

>Hi Experts,
>the release of HyLogic has been retarded because HyLogic releases only 50% CPU
>to opponent with ponder OFF !
>What am I doing wrong? I basically call ReadStdIn() in an infinite loop under
>Windows (both GUI and Console).
>When HyLogic is not thinking, it is querying input with ReadStdIn() in the
>infinite loop.


Don't do that.  Only poll while pondering.  When you want a move, do a
read() directly and skip the polling stuff...




>
>void ReadStdIn(AnsiString &pStdIn)
>{
>char str[5];
>DWORD nBytesRead=0L;
>BOOL bRead;
>HANDLE StdIn, StdOut;
>
>StdIn = GetStdHandle(STD_INPUT_HANDLE);
>StdOut = GetStdHandle(STD_OUTPUT_HANDLE);
>pStdIn = "";
>bRead = PeekNamedPipe((HANDLE)StdIn, NULL, 0, NULL, &nBytesRead, NULL);
>if ((!bRead)||(nBytesRead==0)) return;
>while (1) {
>bRead = ReadFile((HANDLE)StdIn, (LPVOID)(LPSTR)str, (DWORD)1,
>(LPDWORD)&nBytesRead, (LPOVERLAPPED)NULL);
>if (!bRead) break; if (str[0] != '\n') { str[1] = '\0'; pStdIn = pStdIn + str; }
>else break;
>}
>}
>
>
>Thanks,
>Matthias.



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.