Rebel Book Draw?

Discussion of chess software programming and technical issues.

Moderators: hgm, Harvey Williamson, bob

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
User avatar
hgm
Posts: 23214
Joined: Fri Mar 10, 2006 9:06 am
Location: Amsterdam
Full name: H G Muller
Contact:

Re: Rebel Book Draw?

Post by hgm » Wed Oct 03, 2018 11:38 am

Well, what book you should use is obviously dependent on contempt. For playing against weaker opponents the book should not contain lines that lead to a quick draw, as through the conempt draw should be considered a very poor result. Objectively inferior moves would become the best moves due to contempt.

You cannot solve that by just detecting wether book moves are repeats. The engine might have committed itself many moves before to playing the drawish line, and it should have avoided it then.

Joost Buijs
Posts: 844
Joined: Thu Jul 16, 2009 8:47 am
Location: Almere, The Netherlands

Re: Rebel Book Draw?

Post by Joost Buijs » Wed Oct 03, 2018 11:48 am

hgm wrote:
Wed Oct 03, 2018 11:38 am
Well, what book you should use is obviously dependent on contempt. For playing against weaker opponents the book should not contain lines that lead to a quick draw, as through the conempt draw should be considered a very poor result. Objectively inferior moves would become the best moves due to contempt.

You cannot solve that by just detecting wether book moves are repeats. The engine might have committed itself many moves before to playing the drawish line, and it should have avoided it then.
Agreed, the most ideal is to select different books for different opponents, also depending upon what color you play. In practice though, most people use a single book only.

Rookie seems to keep track of moves and scores of every engine it plays against, I think this is too far stretched, at least I never considered doing something like that.

User avatar
hgm
Posts: 23214
Joined: Fri Mar 10, 2006 9:06 am
Location: Amsterdam
Full name: H G Muller
Contact:

Re: Rebel Book Draw?

Post by hgm » Wed Oct 03, 2018 12:59 pm

I guess that when a book contains WDL info, you could either consider the draws as wins or losses depending on the sign of the contempt, When drawish lines are considered losses, they would automatically be avoided. But Polyglot books don't have that; they only assign a single weight to each move.

This could be a nice option when building a Polyglot book: for how many points you want to count a draw. That would make it easy to create different books from the same data set, for stronger, equal or weaker opponents. Perhaps I should add such an option to WinBoard. (Which, like Polyglot, now counts draws as 1/2 point.)

An alternative would be to sneak this info into to Polyglot books in a way compatible with the existing format. The latter has 16 bits for the weights. (And the standard book-building algorithm sets it to 2*wins + draws scored with the move.) For the move selection only the relative weights are important, and it is very questionable whether the resolution for that needs to be larger than 8 bits. So you could use the high-order 8 bits to contain the true (scaled and rounded) weights, and then use the low 8 bits to indicate the contribution draws did make to that. During move selection this could then be used to adjust the weights based on a book-contempt factor, which would add between -1 and 1 times the draw contribution to those. Then the same book could be used against opponents of any strength. Perhaps I should also implement such an option in WinBoard's book probing, using (w + (w & 255)*f*256) instead of weight w. For f=0 that would give the usual move selection, but for specially prepared book settings f=1 or f=-1 could be useful.

odomobo
Posts: 59
Joined: Thu Jul 05, 2018 11:09 pm
Location: Chicago, IL
Full name: Josh Odom

Re: Rebel Book Draw?

Post by odomobo » Wed Oct 03, 2018 2:37 pm

I think it's important to write code to prevent this from blindly happening. It's a failure of the book format more than anything else, and can potentially happen anytime there's a potential cycle. If it were me, I'd just have the opening book code perform a real search if about to draw or if the opponent is about to draw. I guess this is only really important if you use contempt; I'm pretty sure a cycle should only be able to happen in an opening book if the position is weaker for that side.
hgm wrote:
Wed Oct 03, 2018 12:59 pm
and then use the low 8 bits to indicate the contribution draws did make to that.
Isn't it more straightforward to encode score in this area? Then the engine can directly use contempt factor in the case of a looming draw.

User avatar
hgm
Posts: 23214
Joined: Fri Mar 10, 2006 9:06 am
Location: Amsterdam
Full name: H G Muller
Contact:

Re: Rebel Book Draw?

Post by hgm » Wed Oct 03, 2018 3:19 pm

Books are usually made from collections of games played by human GMs, and these are not annotated with scores. So how would you get the scores? The reason to use a book in the first place is that the engine cannot be trusted in the opening, so having the engine calculate scores doesn't seem a good idea either.

Also, even a perfect score would correlate with the game result according to the usual draw = 1/2 rule, which is exactly what the move weights in the book is also supposed to represent. So it would not add any new information. What you need is to know how much of the expected result is ue to draws. A move with a 53% result would be a very poor choice against a weaker opponent if it came about by 6% wins and 94% draws. You would prefer a move with 47% wins, 10% draws and 43% losses, even though that would only be a 52% result, and presumably thus have a lower score than the 53% move. But against an opponent for which you have utter contempt, a draw counts as a loss. So you are really making the choice between a 6% move and a 47% move.

bob
Posts: 20369
Joined: Mon Feb 27, 2006 6:30 pm
Location: Birmingham, AL

Re: Rebel Book Draw?

Post by bob » Wed Oct 03, 2018 6:17 pm

This is a problem you have to fix. If your opponent plays a move that "undoes" one of his recent moves (or his most recent move most commonly) then you will find that position in your book if you are not careful to recognize the 2-fold repetition. My fix was to simply ignore a book move that repeats the position and if there are no other moves, fall out of book and let your search find something that will not repeat (unless your score is negative).

Joost Buijs
Posts: 844
Joined: Thu Jul 16, 2009 8:47 am
Location: Almere, The Netherlands

Re: Rebel Book Draw?

Post by Joost Buijs » Thu Oct 04, 2018 6:06 am

bob wrote:
Wed Oct 03, 2018 6:17 pm
This is a problem you have to fix. If your opponent plays a move that "undoes" one of his recent moves (or his most recent move most commonly) then you will find that position in your book if you are not careful to recognize the 2-fold repetition. My fix was to simply ignore a book move that repeats the position and if there are no other moves, fall out of book and let your search find something that will not repeat (unless your score is negative).
This sounds like a reasonable solution, unfortunately this is not possible when you use an external book adapter like polyglot that many people seem to use. Of course the best is to incorporate the book code in the engine like (I assume) you did in Crafty.

User avatar
JVMerlino
Posts: 990
Joined: Wed Mar 08, 2006 9:15 pm
Location: San Francisco, California

Re: Rebel Book Draw?

Post by JVMerlino » Thu Oct 04, 2018 4:07 pm

FWIW, I tested several engines on the position before White decided to repeat:



The scores ranged between a few cp either side of 0.0 up to +0.5 for White, with the best move being either Nbd2 or a4. Therefore, Black agreeing to repeat in this case seems quite reasonable.

Post Reply