Polyglot books with tournament

Discussion of chess software programming and technical issues.

Moderators: hgm, Dann Corbit, Harvey Williamson

stevenaaus
Posts: 608
Joined: Wed Oct 13, 2010 9:44 am
Location: Australia

Polyglot books with tournament

Post by stevenaaus »

I'm looking at adding a "Use Book" feature to Scid vs. PC's tournament.
I have a working implementation, but am not sure it is correct.

Am i correct in saying that in this mode, the engines dont give *any* input
until an out of book position is reached ?

Is it normal that both engines use the same book, or can this be configured ?

I see from Xboards doco :

Code: Select all

It is also possible to specify a GUI opening book here, i.e. an opening book that XBoard consults for any position a playing engine gets in. It then forces the engine to play the book move, rather than to think up its own, if that position is found in the book. [b]The book can switched on and off independently for either engine.[/b]
Is this independent thing fair/ useful ?

Code: Select all

The way book moves are chosen can be influenced through the settings of book depth and variety. After both sides have played more moves than the specified depth, the book will no longer be consulted. When the variety is set to 50, moves will be played with the probability specified in the book. When set to 0, only the move(s) with the highest probability will be played. When set to 100, all listed moves will be played with equal pobability. Other settings interpolate between that.
Is this still the current behaviour. Is any of these modes more widely used ?

The implementation i have is that book moves are returned according to their weight. Making a book move takes me ~ 400 microseconds. This is probably not fastest because (unfortunately, in implementation) the book is opened and closed every move. Is this (relatively) slow speed likely to be an issue ?

cheers, Steven
User avatar
hgm
Posts: 27701
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Polyglot books with tournament

Post by hgm »

stevenaaus wrote:Am i correct in saying that in this mode, the engines dont give *any* input
until an out of book position is reached ?
Indeed, the engine is kept in force mode until it is out of book, and the book moves are fed both to the engine and its opponent.
Is it normal that both engines use the same book, or can this be configured ?
Thi is a design choice for the GUI. In XBoard I only support a common book. Beause the feature was mainly used as a means to force diversity during engine tournaments, not as a replacement for dedicated engine books. (Although in an operator-mediated OTB tourney it can of course still be used for that purpose.) WB engines are supposed to handle their own books. And for UCI engines, which in general are dependent on GUI support for their books, Polyglot can do double duty as book adapter.
Is this independent thing fair/ useful ?
It is a standard feature of UCI engines that in those that do support book it can be swicthed off. This was inherited from that. Whether is is fair is really no concern. There are plenty of applications (like running test gauntlets for your own engine) where fairness is not required, and this ould be useful. (e.g. gauntlet engine plays with its own book, the opponents with a general GUI book.)
Is this still the current behaviour. Is any of these modes more widely used ?
This is still current behavior. I have no idea how much it is used, but it was trivial to implement, and seemed useful to have. Tuning variety and book depth are options commonly found in other GUIs.
The implementation i have is that book moves are returned according to their weight. Making a book move takes me ~ 400 microseconds. This is probably not fastest because (unfortunately, in implementation) the book is opened and closed every move. Is this (relatively) slow speed likely to be an issue ?
I never timed this in XBoard. There I re-open the book file for every move too. (I think.) The idea was that the OS would cache the book anyway, so that it would not really have to access the disk again. More of a problem seemed to me that the search is done by bi-section, requiring a number of highly scattered probes to the book file.
Michel
Posts: 2271
Joined: Mon Sep 29, 2008 1:50 am

Re: Polyglot books with tournament

Post by Michel »

More of a problem seemed to me that the search is done by bi-section, requiring a number of highly scattered probes to the book file.
Since the keys are uniformly distributed and the book is ordered, interpolation search should reduce the number of probes somewhat.
But I do not think it matters much.
User avatar
hgm
Posts: 27701
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Polyglot books with tournament

Post by hgm »

This is not a bad idea at all, not least because it is just a trivial modification to the bi-section algorithm. If you are at a fraction f of the key space, the std deviation of the number of keys before you in a book of N entries is only sqrt(N*f*(1-f)). So say N is a million, and f=0.75, then the first probe would miss the target on average by 433 entries, which is N*f for the second probe, while 1-f there is ~1. So the second probe would on average only be 21 entries off, i.e. already fall in the same disk sector, after which probes become infinitely fast. With bisection it would take 11 probes to narrow down to 500 entries.
stevenaaus
Posts: 608
Joined: Wed Oct 13, 2010 9:44 am
Location: Australia

Re: Polyglot books with tournament

Post by stevenaaus »

Anyway, it's in scidvspc subversion now. Thanks HG for advice.
Yes - this is a nice feature to mix up the tournament. :)
I wonder if people generally use performance of variety orientated books ?

It's not as configurable as xboard. Book moves are of frequency according to weight, and there's no "one engine only" sort of thing, mainly because the configuration widget is too crowded anyway, but it wouldnt be hard to do if.

I just kind-of ignore the engines until an out of book position is got, then tell them whats happened. And I'm not allowing to go back into book as it *maybe* messes up my ponder code, and seems sensible anyway.

BTW - Scid's inbuilt engine (src/engine.cpp/Engine::Search) can occasionally segfault crashing program :( If anyone wants to look at it, configure the build with ./configure DEBUG="-DASSERTIONS" to disable symbol stripping. Computer Tournaments/Serious Game/Tac Game are the only places this is used i think.
stevenaaus
Posts: 608
Joined: Wed Oct 13, 2010 9:44 am
Location: Australia

Re: Polyglot books with tournament

Post by stevenaaus »

Anywya - I've been doing some testing and running games between Critter 1.6 and Komodo 3.

If i configure Critter to use 2 threads, it wins. If i configure it with 4 threads, it loses. My CPU is a 2.6GHz Core 2 Quad... I suppose with 4 threads Critter is trying to compete with the OS or GUI. I wonder exactly what's happening ?