Author: Bas Hamstra
Date: 10:09:53 09/05/99
Go up one level in this thread
On September 05, 1999 at 11:45:36, Nicolas Carrasco wrote:
>Dear Guys,
>
>Now I am able to comunicate my chess engine to Winboard but I only want to ask
>you some questions to know if I can have any problems because at the file
>included at Winboard.
>
>What this function do ?
>setbuf(stdout, NULL);
>
>At winbord´s protocol file says that "scanf" can have problems so I created my
>own function:
>////////////////////////////////////////////////////////////////////
>#include <stdio.h>
>
>void cgets ( char *buffer )
>{
> char i, ch;
> /* Read in single line from "stdin": */
> for( i = 0; (i < 80) && ((ch = getchar()) != EOF) && (ch != '\n'); i++ )
> buffer[i] = (char)ch;
>
> /* Terminate string with null character: */
> buffer[i] = '\0';
>}
>/////////////////////////////////////////////////////////////////
>
>I think with this works fine!
>
>But, can I use printf to comunicate Winboard succesfuly ?
>
>How crafty thinks and gets text at the same time?
>
>Thanks
There are 2 ways: you can make a polling function that is called every x nodes.
For example every 1000 nodes you call from within the search a function that
checks for input from winboard. If there is input and the input requires some
action, you set a parameter AbortSearch to true and continue where you left the
search. Now the search will be aborted, because of the parameter you set and you
handle the input.
The other way is to use a polling thread that does basically the same.
Both hardly slow your search down... To check if inputs needs to be handled and
if the search (or pondering) needs abortion in the various "states" the engine
can be in, can be a bit messy :) That is if you want to support all winboard
features.
The first method is probably the most portable.
Regards,
Bas Hamstra.
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.