Hi,
please point me to a documentation that specifies how setboard should be use (WRT color & engine mode). I found only
http://www.open-aurec.com/wbforum/WinBo ... ntf.html#8 and
http://www.gnu.org/software/xboard/engine-intf.html#8.
But apart from this, what's wrong with the output I gave if the behaviour of my engine is exactly what you (and me) described?
CSVN Programmers' Tournaments May 2014
Moderators: hgm, Rebel, chrisw
-
- Posts: 286
- Joined: Mon Jun 03, 2013 7:05 pm
- Location: Italy
-
- Posts: 27796
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: CSVN Programmers' Tournaments May 2014
Setboard does not set the engine to play, does it? I always assumed that it should leave the engine in force mode (when I was writing engines). I had a peek in the protocol specs, and I could not find anything about this. (But I might have missed it). Except that when you receive 'setboard' in analyze mode it should leave the engine in analyze mode. This kind of suggests that in general setboard should leave the engine in the mode it is in. But as XBoard only sends a setboard after putting the engine in force mode first, (and never in analyze mode, which has to be left anyway for Edit Position mode in order to generate the position), the difference becomes a moot point.
All my engines that implement setboard switch to force mode when receiving it, if they were not already there. This never caused any problems with WinBoard. This implies that setting the engine to play either color on setboard must cause problems, as apparently WinBoard sends a 'go' after it to set the engine playing. And an extra 'go' is not at all harmless, because on engines that already start playing by themselves after receiving the move, that 'go' would be interpreted after they moved, and then set it playing for the other side!
All my engines that implement setboard switch to force mode when receiving it, if they were not already there. This never caused any problems with WinBoard. This implies that setting the engine to play either color on setboard must cause problems, as apparently WinBoard sends a 'go' after it to set the engine playing. And an extra 'go' is not at all harmless, because on engines that already start playing by themselves after receiving the move, that 'go' would be interpreted after they moved, and then set it playing for the other side!
-
- Posts: 286
- Joined: Mon Jun 03, 2013 7:05 pm
- Location: Italy
Re: CSVN Programmers' Tournaments May 2014
I suppose these engines are in play mode after a setboard like mine, otherwise they would not start to play after receiving a move... It was my first "error" in implementing the protocol, I waited for a "go" after the "usermove", a "go" that never arrived (I don't recall the specific situation though).hgm wrote:... because on engines that already start playing by themselves after receiving the move...
The spec is far from being clear IMHO.
-
- Posts: 27796
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: CSVN Programmers' Tournaments May 2014
True, it is high time the specs are rewritten. But it really doesn't suggest anywhere that setboard should set the engine to play a specific side. And the model protocol driver is clear enough (at least for those that read C):
Code: Select all
// recognize the command, and execute it
if(!strcmp(command, "quit")) { break; } // breaks out of infinite loop
if(!strcmp(command, "force")) { engineSide = NONE; continue; }
if(!strcmp(command, "analyze")) { engineSide = ANALYZE; continue; }
if(!strcmp(command, "exit")) { engineSide = NONE; continue; }
if(!strcmp(command, "level")) {
int min, sec=0;
sscanf(inBuf, "level %d %d %d", &mps, &min, &inc) == 3 || // if this does not work, it must be min:sec format
sscanf(inBuf, "level %d %d:%d %d", &mps, &min, &sec, &inc);
timeControl = 60*min + sec; timePerMove = -1;
continue;
}
if(!strcmp(command, "protover")){
printf("feature ping=1 setboard=1 colors=0 usermove=1 memory=1 debug=1");
printf("feature option=\"Resign -check 0\""); // example of an engine-defined option
printf("feature option=\"Contempt -spin 0 -200 200\""); // and another one
printf("feature done=1");
continue;
}
if(!strcmp(command, "option")) { // setting of engine-define option; find out which
if(sscanf(inBuf+7, "Resign=%d", &resign) == 1) continue;
if(sscanf(inBuf+7, "Contempt=%d", &contemptFactor) == 1) continue;
continue;
}
if(!strcmp(command, "sd")) { sscanf(inBuf, "sd %d", &maxDepth); continue; }
if(!strcmp(command, "st")) { sscanf(inBuf, "st %d", &timePerMove); continue; }
if(!strcmp(command, "memory")) { SetMemorySize(atoi(inBuf+7)); continue; }
if(!strcmp(command, "ping")) { printf("pong%s", inBuf+4); continue; }
if(!strcmp(command, "easy")) { ponder = OFF; continue; }
if(!strcmp(command, "hard")) { ponder = ON; continue; }
if(!strcmp(command, "go")) { engineSide = stm; continue; }
if(!strcmp(command, "post")) { postThinking = ON; continue; }
if(!strcmp(command, "nopost")) { postThinking = OFF;continue; }
if(!strcmp(command, "random")) { randomize = ON; continue; }
if(!strcmp(command, "hint")) { if(ponderMove != INVALID) printf("Hint: %s\n", MoveToText(ponderMove)); continue; }
// if(!strcmp(command, "")) { sscanf(inBuf, " %d", &); continue; }
// ignored commands:
if(!strcmp(command, "book")) { continue; }
if(!strcmp(command, "xboard")) { continue; }
if(!strcmp(command, "computer")){ continue; }
if(!strcmp(command, "name")) { continue; }
if(!strcmp(command, "ics")) { continue; }
if(!strcmp(command, "accepted")){ continue; }
if(!strcmp(command, "rejected")){ continue; }
if(!strcmp(command, "variant")) { continue; }
if(!strcmp(command, "")) { continue; }
// now process commands that do alter the position, and thus invalidate the ponder move
ponderMove = INVALID;
if(!strcmp(command, "new")) { engineSide = BLACK; stm = Setup(DEFAULT_FEN); maxDepth = MAXPLY; randomize = OFF; continue; }
if(!strcmp(command, "setboard")){ engineSide = NONE; stm = Setup(inBuf+9); continue; }
if(!strcmp(command, "undo")) { stm = TakeBack(1); continue; }
if(!strcmp(command, "remove")) { stm = TakeBack(2); continue; }
if(!strcmp(command, "usermove")){
int move = ParseMove(inBuf+9);
if(move == INVALID) printf("Illegal move\n");
else {
stm = MakeMove(stm, move);
gameMove[moveNr++] = move; // remember game
}
continue;
}
printf("Error: unknown command\n");
-
- Posts: 4052
- Joined: Thu May 15, 2008 9:57 pm
- Location: Berlin, Germany
- Full name: Sven Schüle
Re: CSVN Programmers' Tournaments May 2014
The output you gave shows that xboard (or WinBoard) rejects the move that your engine sends in reply to the user move received after "setboard". This shows what HGM wrote, which also differs from my previous understanding of "setboard": xboard sends "force" immediately prior to "setboard", and it does not expect the engine to leave the force mode when reacting to "setboard".xmas79 wrote:Hi,
please point me to a documentation that specifies how setboard should be use (WRT color & engine mode). I found only
http://www.open-aurec.com/wbforum/WinBo ... ntf.html#8 and
http://www.gnu.org/software/xboard/engine-intf.html#8.
But apart from this, what's wrong with the output I gave if the behaviour of my engine is exactly what you (and me) described?
So my initial comment was not perfect, it was more of "wishful thinking". I looked up the implementation of "setboard" in my engines and found that I do not leave the force mode in "setboard" as well, otherwise it would not work correctly with xboard/WinBoard. I am not sure, though, whether this has always been normal behaviour of xboard, maybe this is a change that HGM made some time ago?
As to the specs, it is right that the intended behaviour of engines after receiving "setboard" is not specified explicitly. I still believe that the original idea (a long time ago) should have been to have a consistent behaviour of "new" and "setboard" since both reset the game to a new starting position, either the standard initial position or one given by FEN. Here I am almost sure that HGM has a different view about it, maybe driven by his interest in other chess variants which poses additional requirements. I would be glad if xboard either sends an explicit "go" after both "new" and "setboard" commands when followed by a user move, or does not send it in both cases.
Sven
-
- Posts: 27796
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: CSVN Programmers' Tournaments May 2014
I did not alter anything in this area. I don't think anything could be altered without breaking the vast majority of existing engines and adapters, w.r.t. the possibility to play from setup positions.
I don't know why things are so inconsistent as they are. Originally, there did not exist a setboard command in WB protocol, and the position had to be defined through the 'edit' command, plus 'white' or 'black' commands for the side to move. The latter commands are indeed like 'new', in the sense that the set the engine to play the side not on move, so that you can set it thinking by just playing a move, and only need 'go' when you want it to start.
This altering of the engine side seemed to cause confusion amongst engine authors, with as a result that the 'black' command was deprecated, and replaced by the white command plus a dummy move in force mode to set the right side to move before issuing the edit command. Apparently the setboard command was designed to mimic that behavior in a single command.
In the GUI code it is now also a horrible problem to figure out when you have to send 'go' or not.
I don't know why things are so inconsistent as they are. Originally, there did not exist a setboard command in WB protocol, and the position had to be defined through the 'edit' command, plus 'white' or 'black' commands for the side to move. The latter commands are indeed like 'new', in the sense that the set the engine to play the side not on move, so that you can set it thinking by just playing a move, and only need 'go' when you want it to start.
This altering of the engine side seemed to cause confusion amongst engine authors, with as a result that the 'black' command was deprecated, and replaced by the white command plus a dummy move in force mode to set the right side to move before issuing the edit command. Apparently the setboard command was designed to mimic that behavior in a single command.
In the GUI code it is now also a horrible problem to figure out when you have to send 'go' or not.
-
- Posts: 286
- Joined: Mon Jun 03, 2013 7:05 pm
- Location: Italy
Re: CSVN Programmers' Tournaments May 2014
If only I had it when I wrote my driver...
-
- Posts: 286
- Joined: Mon Jun 03, 2013 7:05 pm
- Location: Italy
Re: CSVN Programmers' Tournaments May 2014
I think the vast majority of engines and adapters are still "active", so a hardening (and/or update) on the behaviour of the protocol should be considered IMHO. I'm happy with what I already have, a protocol driver that works, even if sometimes some dynamics are not fully understood...
-
- Posts: 27796
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: CSVN Programmers' Tournaments May 2014
Then you should have looked better! It has been posted on WinBoard forum years ago...xmas79 wrote:If only I had it when I wrote my driver...
-
- Posts: 27796
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: CSVN Programmers' Tournaments May 2014
Where did you get that idea? If there are more than 30 of the existing engines still under active development, I would be very surprised. Plus that there are people that like to run old versions, which would not even be updated for engines that are still active.xmas79 wrote:I think the vast majority of engines and adapters are still "active", so a hardening (and/or update) on the behaviour of the protocol should be considered IMHO. I'm happy with what I already have, a protocol driver that works, even if sometimes some dynamics are not fully understood...
The specs could be formulated more clearly to describe the actual behavior, but backward compatibility is sort of sacred.