Leaving/Returning to Book Annoyance

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Leaving/Returning to Book Annoyance

Post by bob »

jhaglund wrote:
JVMerlino wrote:
jhaglund wrote:IMO, take the book move, if it matches a variation within the book.

The moves within the book should be taken. That is why the book was created in the first place.

Otherwise, fclose() book at first ended variation, ExitBook(), then start the Ponder().

Have some sort of null character to decide when the book line is done, and ponder should start.

Jumping I/O of the book is generally from a book creation problem. To me, pondering should start after the book exits.

If your program can tell if it's the last move in the book, I would think it'd be safe to start pondering on your opponent's time.

if(moves_in_variation <= 1), start ponder.
Hi Joshua,

With the ProDeo book, it is possible to tell if a line has ended...sort of. But there is no way to determine if it is possible to go back into book later on.

Thanks for the reply,
jm
Why wouldn't the book have a previous move or FEN that was made to bring it back to the book?

If FEN == Next_FEN_in_book, continue book. If FEN != Next_FEN_in_book, close_book_4_good, start ponder.

Could you give a variation where this happens?

When a book is biased towards white or black's lines of play, this is generally where I see this happen. I don't like books like that for general use.
What commonly happens is a transposition from one type of opening to another, with an intermediary non-book move that "connects" the two. Another way we see this is through a transposition of moves. For example, e4 e5 Nf3 Nc6 and the only book move you have for white is Nc3 followed by Bc4. But white plays Bc4 which takes you out of book, You play the move you would have played after Nc3 by doing a normal search, and when your opponent now plays Nc3 you are right back into the book. Other ideas like 1e4 e5 2. f4, But I we start with 1. f4 and you choose to play e5, and now I can play e4 and transpose back into the book.

There is an ugly case you do need to handle that is well known. 1. e4 e5 2.Nf3 Nc6 3. Bb5 a6 is common. But what should black play if the following sequence of moves is played: 1. e4 e5 2. Nf3 a6 3. Bb5. Now what do you play? Nc6? will take you right back into a known Ruy Lopez book line. axb6 will take you right into a won game. You don't want to transpose back in and miss winning a piece here.
MattieShoes
Posts: 718
Joined: Fri Mar 20, 2009 8:59 pm

Re: Leaving/Returning to Book Annoyance

Post by MattieShoes »

So one solution would be only use book moves if the *current* position is in book, regardless of whether there are children within book.

If your engine as Black plays e4 e5 Nf3 a6 or your engine as black plays e4 e5 Nf3 a6 Bb5, you've got book issues larger than missing a won piece anyway methinks... :-)
User avatar
hgm
Posts: 27807
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Leaving/Returning to Book Annoyance

Post by hgm »

WinBoard uses books in Polyglot format, which contain (position, move) pairs. When an engine using the GUI book gets to move, WinBoard first checks if the position occurs in the book, and if it does, selects one of the moves it occurs with for the engine to play, and forces it into the engine.

This works irrespective of what happened before (i.e. if you were in or out of book, and if the engine was pondering or not). The forcing of the move automatically takes the engine out of ponder.

The latter is a bit strange; if ponder is on, I guess it would be perfectly allowed for the engine to start pondering after it has played a book move. It can always discard the ponder results when the opponent does a move that stays in book. WinBoard protocol is a bit illogical, in that it uses a separate command for switching pondering on in force mode, namely analysis. Many engines do not support that command, though. Nevertheless, it might be possible to have WB optionally put the engine in analysis mode before forcing in the book moves when ponder is on, so that it starts ponderingthe position. Then when the opponent gives you a move that brings you out of book, WB would bring the engine back into machine-white or machine-black mode by sending it a go command.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Leaving/Returning to Book Annoyance

Post by bob »

MattieShoes wrote:So one solution would be only use book moves if the *current* position is in book, regardless of whether there are children within book.

If your engine as Black plays e4 e5 Nf3 a6 or your engine as black plays e4 e5 Nf3 a6 Bb5, you've got book issues larger than missing a won piece anyway methinks... :-)
Or use book moves only if the position before the book move is a known book position, and the position after the book move is a known book position.