Creating a crazyhouse opening book for xboard

Discussion of anything and everything relating to chess playing software and machines.

Moderators: hgm, Rebel, chrisw

Isaac
Posts: 265
Joined: Sat Feb 22, 2014 8:37 pm

Creating a crazyhouse opening book for xboard

Post by Isaac »

Hello people,
I would like to create a crazyhouse opening book for Sunsetter-TJchess engines to use via xboard. As far as I understand, xboard/polyglot seems to understand only files with .bin extension as books.

What I have so far is a book.pgn with won games from both sides. So I need to filter this file and create another bookwhite.pgn for all 1-0 games, and another bookblack.pgn for all 0-1 games. And then merge both books into a single one. Then convert that file.pgn to file.bin so that Sunsetter-TJchess would play only the winning lines instead of both losing and winning lines via xboard.

The problem is, ScidvsPC cannot open my book.pgn and polyglot cannot deal with crazyhouse games, at least for book merging.
I am sure there is a way to perform what I have in mind, since TJchess comes with a book.bin (that has too many bad lines with black).

Any idea is welcome!
ZirconiumX
Posts: 1334
Joined: Sun Jul 17, 2011 11:14 am

Re: Creating a crazyhouse opening book for xboard

Post by ZirconiumX »

Isaac wrote:Hello people,
I would like to create a crazyhouse opening book for Sunsetter-TJchess engines to use via xboard. As far as I understand, xboard/polyglot seems to understand only files with .bin extension as books.

What I have so far is a book.pgn with won games from both sides. So I need to filter this file and create another bookwhite.pgn for all 1-0 games, and another bookblack.pgn for all 0-1 games. And then merge both books into a single one. Then convert that file.pgn to file.bin so that Sunsetter-TJchess would play only the winning lines instead of both losing and winning lines via xboard.

The problem is, ScidvsPC cannot open my book.pgn and polyglot cannot deal with crazyhouse games, at least for book merging.
I am sure there is a way to perform what I have in mind, since TJchess comes with a book.bin (that has too many bad lines with black).

Any idea is welcome!
I think you need to develop your own book format. Polyglot was not designed for anything other than regular chess, so you are on your own.

Perhaps you could alter Polyglot to handle Crazyhouse instead.

Matthew:out
Some believe in the almighty dollar.

I believe in the almighty printf statement.
User avatar
hgm
Posts: 27810
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Creating a crazyhouse opening book for xboard

Post by hgm »

You can use the XBoard 'Save Games to Book' menu item to convert the currently loaded PGN file to a Polyglot book. (Better try this in Game Viewer mode only, as it might be buggy with an engine.)

Unfortunately it is still on the to-do list to only convert the currently filtered games (i.e. those displayed in the game list) to book, and ignore the others. But I don't think there really isn't much need to make separate white and black books, and merge. Polyglot books use the number of half-points scored with the move as the weight. So white wins automatically contribute only to the weight of moves for white, and black wins only contribute to the weight of black moves.

Unless my thinking is very flawed, I think merging the files from the white and black wins would produce exactly the same result.

You might want to remove all draws, though. (But can there be draws in Crazyhouse?)
Isaac
Posts: 265
Joined: Sat Feb 22, 2014 8:37 pm

Re: Creating a crazyhouse opening book for xboard

Post by Isaac »

Thanks Matthew. I'm not a programmer so it's going to be hard for me :)
But since tjchess already has a .bin book for zh, I guess there's an easy way to build it.
hgm wrote:You can use the XBoard 'Save Games to Book' menu item to convert the currently loaded PGN file to a Polyglot book. (Better try this in Game Viewer mode only, as it might be buggy with an engine.)

Unfortunately it is still on the to-do list to only convert the currently filtered games (i.e. those displayed in the game list) to book, and ignore the others. But I don't think there really isn't much need to make separate white and black books, and merge. Polyglot books use the number of half-points scored with the move as the weight. So white wins automatically contribute only to the weight of moves for white, and black wins only contribute to the weight of black moves.

Unless my thinking is very flawed, I think merging the files from the white and black wins would produce exactly the same result.

You might want to remove all draws, though. (But can there be draws in Crazyhouse?)
Thank you very much H.G.M. I'll have to refresh my memory on how to start xboard in Game Viewer mode. I think you already told me how to do so in another thread but I'm not really good at searching stuff in this forum... and google seems to ignore all threads and posts in this forum to me, so searching from google does not return anything either.

I didn't take any drew games. Around 1% of zh games ends in a draw, so yes they are quite possible although not really common.
Isaac
Posts: 265
Joined: Sat Feb 22, 2014 8:37 pm

Re: Creating a crazyhouse opening book for xboard

Post by Isaac »

Here's what I've done:

Code: Select all

xboard -ncp zhbook.pgn
.
In Common Engine I've set max move to 99 or so and I've named "testbook.bin" as book name.
I've pressed on "Saves Games to book". It created a testbook.bin, but its size is worrisome to me: 33.6 kB. While the same book but in pgn format is around 512 kB (contains around 600 games).

Not sure what happened...
Ferdy
Posts: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Creating a crazyhouse opening book for xboard

Post by Ferdy »

Isaac wrote:Here's what I've done:

Code: Select all

xboard -ncp zhbook.pgn
.
In Common Engine I've set max move to 99 or so and I've named "testbook.bin" as book name.
I've pressed on "Saves Games to book". It created a testbook.bin, but its size is worrisome to me: 33.6 kB. While the same book but in pgn format is around 512 kB (contains around 600 games).

Not sure what happened...
You need to load the games first, before pressing "Save Games to Book".
Isaac
Posts: 265
Joined: Sat Feb 22, 2014 8:37 pm

Re: Creating a crazyhouse opening book for xboard

Post by Isaac »

Ferdy wrote:
Isaac wrote:Here's what I've done:

Code: Select all

xboard -ncp zhbook.pgn
.
In Common Engine I've set max move to 99 or so and I've named "testbook.bin" as book name.
I've pressed on "Saves Games to book". It created a testbook.bin, but its size is worrisome to me: 33.6 kB. While the same book but in pgn format is around 512 kB (contains around 600 games).

Not sure what happened...
You need to load the games first, before pressing "Save Games to Book".
Aren't they loaded with the command

Code: Select all

xboard -ncp zhbook.pgn
?
If not, how do you load them?
Ferdy
Posts: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Creating a crazyhouse opening book for xboard

Post by Ferdy »

Isaac wrote:
Ferdy wrote:
Isaac wrote:Here's what I've done:

Code: Select all

xboard -ncp zhbook.pgn
.
In Common Engine I've set max move to 99 or so and I've named "testbook.bin" as book name.
I've pressed on "Saves Games to book". It created a testbook.bin, but its size is worrisome to me: 33.6 kB. While the same book but in pgn format is around 512 kB (contains around 600 games).

Not sure what happened...
You need to load the games first, before pressing "Save Games to Book".
Aren't they loaded with the command

Code: Select all

xboard -ncp zhbook.pgn
?
If not, how do you load them?
I use winboard open it load the games change book file name and press the sgtb. In this way I can see the game list.
User avatar
hgm
Posts: 27810
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Creating a crazyhouse opening book for xboard

Post by hgm »

I think "xboard -ncp FILENAME" should indeed load the file automatically at startup. You should be able to see if you were successful in this by the Game List of all games in the file appearing in a separate window. If not, you can load the file interactively through the File -> Load Game menu.

How large the created bin book is will depend a lot on whether the games contain much overlap, or not. PGN is not a terribly compact format, so I am not sure if 512KB -> 33KB is anything to worry about. An empty book would be only 16 bytes, so there should be something in the bin book you made (about 2000 moves, actually).

To check if it all makes sense, you could open the Edit Book window, and see what it shows when you step through various opening positions.

Note that only moves that were played a minimum number of times go into the book. I have forgotten what that number exactly was, but it is at least two. So the unique 'tail' of games would not be included in the book. If you don't want to exclude those, you must fool XBoard, by pressing 'Save Games to Book' a second time, with the same PGN still loaded. Each time you press it, it adds the currently loaded games to its internal buffer where it builds the book, before saving that. This way you can combine several PGNs into one book. But by this trick, you could make XBoard think every game was played twice, so that all their moves will be included in the book.
Last edited by hgm on Tue Jun 17, 2014 2:06 pm, edited 2 times in total.
Norbert Raimund Leisner
Posts: 1643
Joined: Tue May 20, 2008 4:57 pm
Location: Augsburg - Germany

Re: Creating a crazyhouse opening book for xboard

Post by Norbert Raimund Leisner »

Hello Isaac,

for the Fink project http://www.finkproject.org/ just a Sjeng 11-crazyhouse opening book exists on the website

http://pdb.finkproject.org/pdb/package.php/sjeng-zhbook - perhaps you can ask Matthias Neeracher <neeracherATmacDOTcom>

or visit this website: http://sjeng.org/download.html

Best wishes,

Norbert