// Connecting your Delphi engine to Winboard // // This code gives the basic functionality of reading from and writing to // Winboard. // // It's not meant as complete sample code, just to point you // to the functions you can use. // // When I wanted to connect my engine to Winboard, most time I spent was // searching for these functions, so this might save you some time. // // The further implementationtime depends on how much you want to add, but // just parsing the input for moves and "go" combined with this code should // be enough to play a match against an other engine on your machine. // // Good luck, // // Tony Werten global variable: gHandleout,Threadid:integer; procedure on_someone_wants_to_start_winboard_connection //make the connection (only done once ) begin gHandleout:=getstdhandle(std_output_handle); createthread(nil,0,@read_winboard,nil,0,Threadid); // we want a different thread because the read is a blocking read end; procedure read_winboard; // do the actual reading var tekst:string[50]; ch:char; begin while true do begin tekst:=''; repeat read(input,ch); tekst:=tekst+ch; until ch=#10; parste_text_and_do_something_with_it; //actually the biggest work //you have to set a flag to stop the pondering, // parse the move, maybe correct internal time etc. end; end; procedure send_winboard(var msg:string); // send your own move var len:cardinal; x:pChar; begin len:=length(msg); x:=pchar(msg+#10); // just to be safe _lwrite(gHandleout,x,len+1); end;