How to use openings books?

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
cdani
Posts: 2204
Joined: Sat Jan 18, 2014 10:24 am
Location: Andorra

Re: How to use openings books?

Post by cdani »

Luis Babboni wrote:
cdani wrote:
Luis Babboni wrote:
That´s how I guessed all engines works, but today Soberango was start tested to be add to CCRL 40/4 Rank and crashes because is not able to start a game after some moves made by Arena GUI using its openings book
If your engine is uci and supports the uci command
position startpos moves e2e4 e7e5
it should work.
Thanks Daniel!
Soberango uses xBoard*
But anyway I´m not understand your suggestion.
You mean that read GUI information gives to the engine while move using its book and transform it to this to set the apropiate position in the engine board?

*: when I say that uses xBoard, is not that I take the pseudocode showed in http://hgm.nubati.net/CECP.html and use it to write a complete xboard interfase in FreeBasic. The communication Soberango have with GUI is just using the minimum commands I saw I need to run it and all other are simply ignored.
I never programmed for Xboard. If Arena decides the moves sure it sends them to the engine to let it update its internal board.
User avatar
Luis Babboni
Posts: 464
Joined: Sat Feb 28, 2015 4:37 pm
Location: Argentina

Re: How to use openings books?

Post by Luis Babboni »

cdani wrote:
Luis Babboni wrote:
cdani wrote:
Luis Babboni wrote:
That´s how I guessed all engines works, but today Soberango was start tested to be add to CCRL 40/4 Rank and crashes because is not able to start a game after some moves made by Arena GUI using its openings book
If your engine is uci and supports the uci command
position startpos moves e2e4 e7e5
it should work.
Thanks Daniel!
Soberango uses xBoard*
But anyway I´m not understand your suggestion.
You mean that read GUI information gives to the engine while move using its book and transform it to this to set the apropiate position in the engine board?

*: when I say that uses xBoard, is not that I take the pseudocode showed in http://hgm.nubati.net/CECP.html and use it to write a complete xboard interfase in FreeBasic. The communication Soberango have with GUI is just using the minimum commands I saw I need to run it and all other are simply ignored.
I never programmed for Xboard. If Arena decides the moves sure it sends them to the engine to let it update its internal board.
Thanks Daniel!

So not send a FEN with the final position after book moves?
If you know it not doing that when use UCI, I guess do not do it when use xBoard.
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: How to use openings books?

Post by Sven »

Luis Babboni wrote:
hgm wrote: ...
If you want the engine be in control of what book moves it selects, it should handle a book itself. This would be something the GUI is notinvolved in, and knows nothing about. The engine is free to decide what method it uses to find a move, when its turn comes up. It can use search and evaluation,or it could just read the move from a file.
That´s how I guessed all engines works, but today Soberango was start tested to be add to CCRL 40/4 Rank and crashes because is not able to start a game after some moves made by Arena GUI using its openings book

That´s why I start thinking in add the ability to use openings book that I was planed for future after quiescence search, hashtables and tablebases and mostly after improving the evaluation cause actually just count material and then has no sense the choice of one or other move in opening if no implies material difference.
Luis, please have a look at the implementation of the "force" command (including other commands that must react correctly in force mode), it does not work correctly. After sending these commands:

Code: Select all

xboard
protover 2
new
force
usermove e2e4
Soberango 0.0.7.1 plays a move (e7e6) instead of sitting and waiting for the next command (or move) in force mode. That will also be the reason why using an opening book does not work. I suggest to look at "usermove" first ...
User avatar
Luis Babboni
Posts: 464
Joined: Sat Feb 28, 2015 4:37 pm
Location: Argentina

Re: How to use openings books?

Post by Luis Babboni »

Yes, "usermove" launch the search and the rest of the engine work, this must be the mistake.
I was sure that after any "usermove" there is no other option that the need of the engine to make a move. :oops:
Dann Corbit
Posts: 12537
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: How to use books?

Post by Dann Corbit »

Luis Babboni wrote:Thanks Dann!

No, just from the begining!

But is able to read a FEN, what do the subroutine I did to comunicate Soberango with the GUI is this:

Code: Select all

If DiceGUI="new" Then
  	Reseteo
  	FEN="rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"		
  	CargaFEN(FEN)
EndIf
Where:
-DiceGUI is the command sent by the GUI.
-Reseteo clean the board and restore all variables.
-CargaFEN() read the FEN and set the apropiate variables.

Sorry, not sure if my question is correct:
After wich command instead of "new" must the engine read the FEN?
Not every game starts with the opening position.
If you get a [FEN tag in the PGN header, then expect a non-standard starting position.

For the UCI protocol itself, you will just get the position to start playing from.
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
User avatar
hgm
Posts: 27787
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: How to use openings books?

Post by hgm »

Luis Babboni wrote:Yes, "usermove" launch the search and the rest of the engine work, this must be the mistake.
I was sure that after any "usermove" there is no other option that the need of the engine to make a move. :oops:
"usermove" does not launch a search directly. What it does is change the side to move. This can trigger a search when the engine is playing for the side that now has the move. But a 'force' command sets the engine to play neither side, so it would never start searching and playing a move, no matter which color is on move.

The GUI would not send you any position when using the GUI book. Most GUIs also have an option to start grom a given opening line, however, specified as incomplete PGN game. Such a game can contain a FEN tag, and in that case the GUI would send the position before sending the moves of the line (after 'new' and 'force'). Unless you would have taken measures to avoid that, the GUI would send you an 'edit' command for that.
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: How to use openings books?

Post by Sven »

hgm wrote:
Luis Babboni wrote:Yes, "usermove" launch the search and the rest of the engine work, this must be the mistake.
I was sure that after any "usermove" there is no other option that the need of the engine to make a move. :oops:
"usermove" does not launch a search directly. What it does is change the side to move. This can trigger a search when the engine is playing for the side that now has the move. But a 'force' command sets the engine to play neither side, so it would never start searching and playing a move, no matter which color is on move.
Provided the implementation of "usermove" is correct ... In the given case "usermove" erroneously also sets the engine to play the side that has the move, so it ends the "force" mode immediately. That should be avoided since it is mainly the task of the "go" command.
User avatar
hgm
Posts: 27787
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: How to use openings books?

Post by hgm »

Indeed, what I described is what the command should do according to the specs. Moving should occur because the side to move gets equal to the side played. Never as execution of a command. Commands only affect the side to move (usermove, setboard, white, black, new) or the side played (new, go, white, black, force).
User avatar
Luis Babboni
Posts: 464
Joined: Sat Feb 28, 2015 4:37 pm
Location: Argentina

Re: How to use openings books?

Post by Luis Babboni »

As in most of my code, not sure how clear, easy or usefull to future features but it seems I solved the problem and now Soberango could play using openings books! :)

Thanks guys for your help! :)