Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: A Delphi - WinBoard problem

Author: Steve Maughan

Date: 12:03:02 09/24/04

Go up one level in this thread


Martin,

Here's the Delphi version of Monarch's routine to poll input.  In a quick test,
with it running but not thinking (i.e. polling input), the CPU utilization was
between 2% and 4%.

I hope it helps

Steve

=============================================================================
procedure read_winboard;
var
  s :string;
  c :char;
  quit : boolean;
begin
  quit:=false;
  while not(quit) do
  begin
    s:='';
    repeat
    	read(input,c);
      s:=s+c;
    until (c in [#10 ,#13]) and (s<>'') or Quit;
    if Quit then exit;
    s:=trim(s);    //parse command
    if assigned(chess) and (s<>'') then
    begin
      //benchmark
      if UpperCase(s)='TEST' then
      	chess.test2
      else if UpperCase(s)='BENCH' then
      	chess.bench
      //UCI Commands
      else if UpperCase(s)='UCI' then
        Chess.SetUCI
      else
      if UpperCase(s)='ISREADY' then
        chess.uciIsReady
      else if UpperCase(s)='QUIT' then
      begin
        quit:=true;
        chess.Quit;
      end
      else if UpperCase(s)='STOP' then
        chess.uciStop
      else if pos('GO',UpperCase(s))=1 then
        chess.uciGo(s)
      else if UpperCase(s)='PONDERHIT' then
        chess.uciPonderHit
      else if pos('POSITION',UpperCase(s))=1 then
      begin
        chess.uciPosition(s);
      end
      else if pos('SETOPTION',UpperCase(s))=1 then
        chess.uciSetOption(s)
      else
      begin
        {$IFDEF DEBUG}
        WriteCommand('Unknown.txt',s);
        {$ENDIF}
      end;
    end;
    Application.ProcessMessages;
    sleep(1);
  end;
end;



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.