Computer Chess Club Archives


Search

Terms

Messages

Subject: Synchronising with Winboard

Author: Steve Maughan

Date: 10:01:59 12/30/01


I'm trying to get my chess program to play using Winboard.  I've managed to get
it to communicate with the main program using the Standard I/O but am having
difficulties getting it to synchronise the commands.  The following debug output
from Winboard will illustrate:

========================================================================
recognized 'normal' (-1) as variant normal
WinBoard 4.2.5 + JChess.exe
Reset(1, 0) from gameMode 0
recognized 'normal' (-1) as variant normal
GameEnds(0, (null), 2)
StartChildProcess (dir="C:\JChess\") JChess.exe
581 >first : xboard
protover 2
1943 >first : time 30000
otim 30000
1943 >first : e2e4
1973 <first : 2 -35 1 48 g8f6 f1d3
1973 <first : 3 -25 1 232 g8f6 f1d3 b8c6
1973 <first : 3 -20 1 408 b8c6 f1d3 c6d4
1973 <first : 3 -11 1 663 g7g5 f1d3 f8g7
1983 <first : 3 -7 1 830 g7g6 f1d3 f8g7
1983 <first : 3 0 1 1077 e7e5 f1d3 f8c5
1993 <first : 4 -13 1 1892 e7e5 g1f3 f8d6 f1d3
2053 <first : 5 0 1 7567 e7e5 f1d3 f8c5 g1f3 b8c6
2243 <first : 6 -13 1 23348 e7e5 f1d3 f8c5 b2b3 c5d4 b1c3
2514 <first : move e7e5
Interrupting first
4246 >first : time 29942
otim 29826
4246 >first : g1f3
4276 <first : 2 -130 1 29 g8e7 f3e5
4276 <first : 2 -35 1 139 g8f6 f1d3
4276 <first : 2 -13 1 213 f8d6 f1d3
4276 <first : 3 -3 1 429 f8d6 f1d3 b8c6
4286 <first : 3 0 1 1009 b8c6 f1d3 f8c5
4286 <first : 4 -10 1 1446 b8c6 f1d3 f8c5 b1c3
4406 <first : 5 0 1 10675 b8c6 f1d3 f8c5 b1c3 g8f6
4607 <first : 6 -9 1 28629 b8c6 f1d3 f8c5 c2c4 g8f6 b1c3
5538 <first : move b8c6
Interrupting first
7671 >first : time 29813
otim 29613
7671 >first : f1b5
7701 <first : 2 -35 1 37 g8e7 b1c3
7701 <first : 2 -30 1 120 g8f6 b1c3
7701 <first : 2 -8 1 273 f8d6 b1c3
7701 <first : 3 2 1 628 f8d6 b1c3 g8f6
7741 <first : 4 -8 1 3115 f8d6 d2d4 e5d4 f3d4
7951 <first : 5 -8 1 20023 f8d6 d2d4 e5d4 f3d4 c6d4
8222 <first : 5 -5 1 41366 g8f6 d2d3 f8d6 c1e3 e8g8
9203 <first : 6 -10 1 119315 g8f6 d2d3 f8d6 c1e3 f6g4 e3d2
9654 <first : 6 -10 1 156615 g8f6 d2d3 f8d6 c1e3 f6g4 e3d2
Interrupting first
10585 >first : new
random
10585 >first : level 40 5 0
10585 >first : post
10585 >first : hard
12498 <first : move g8f6
Interrupting first
14931 >first : time 29331
otim 29370
14931 >first : e1g1
GameEnds(0, (null), 2)
Interrupting first
21691 >first : force
21691 >first : quit
====================================================================

There is a delay between Winboard sending the 'xboard' command and 'new'.  This
means that my engine processes the first few moves and then resets the game on
response to thE 'NEW' command.  The code (in Delphi) that I have for getting the
info from Winboard is as:

====================================================================
var
  chess : TJChess;
  ThreadID : THandle;

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<>'');
    //parse command
    s:=UpperCase(Trim(s));
  	if s='QUIT' then
    begin
    	quit:=true;
      chess.NewCommand:=true;
      chess.Quit;
    end
    else if s='NEW' then
    begin
      chess.NewCommand:=true;
    	chess.NewGame;
    end
    else if s='GO' then
    begin

    end
    else
    begin
    	if chess.LegalMoves.IndexOf(s)<>-1 then
      begin
	      chess.NewCommand:=true;
      	chess.PlayMove(s);
      end;
    end;
    while not(quit) and chess.NewCommand do
    begin
    	Application.ProcessMessages;
      sleep(1);
    end;
  end;
end;

begin
  chess:=TJChess.create;
  createthread(nil,0,@read_winboard,nil,0,ThreadID);
  chess.WinboardMode:=true;
  chess.Execute;
  chess.Free;
end.
====================================================================

Why is there a delay for the New command?  Is Winboard waiting for me to send
something initially?  Should I wait until I get the New command?  Has anyone had
any of these problems before?

All suggestions appreciated!!

Many thanks,

Steve Maughan



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.