This is clearly a Polyglot bug. When I try it, I get a completely different error message, though. E.g. from the log file:
- Code: Select all
1305017481.004 POLYGLOT *LEARN WIN*
1305017481.004 POLYGLOT write_integer(): fputc(): No such file or directory
1305017481.004 POLYGLOT *** QUIT ***
This is not really a crash, but a voluntary exit by Polyglot, after discovering the fputc() call it attempted to use to write a byte into the book file returned a failure code. The error message doesn't seem to make sense, though: this is not an error one could get when writing a stream. So I wonder if the correct error (derived from errno) is returned here. I suspect it is an earlier error (from when it tried to open its default book at startup, which is not there) that was still hanging there.
Shouldn't the routine ferror(FILE *f); be used to get the error on the stream I/O?
From looking at the log, it seems the probem is the options are processed in the wrong order:
- Code: Select all
1305017454.316 POLYGLOT *** LOGFILE OPENED ***
1305017454.316 POLYGLOT Setting PolyGlot option "Book=true"
1305017454.316 POLYGLOT *** SETTING BOOK ***
1305017454.316 POLYGLOT BOOK "book.bin"
1305017454.316 POLYGLOT Unable to open book "book.bin"
1305017454.316 POLYGLOT Setting PolyGlot option "BookFile=C:\WinBoard-4.5.0\WinBoard\testbook.bin"
1305017454.316 POLYGLOT *** SETTING BOOK ***
1305017454.316 POLYGLOT BOOK "C:\WinBoard-4.5.0\WinBoard\testbook.bin"
1305017454.316 POLYGLOT Setting PolyGlot option "BookLearn=true"
First the book (in this case testbook.bin) is opened, and only after that the option BookLearn is set. So when the book was openend, BookLearn was still false, and the book file was opened read-only...
Michel!? Current work-around is to put BookLearn=true in the polyglot.ini file _before_ the line that sets the Book option. Then it works for me.
- Code: Select all
; Created: Tue May 10 10:50:33 2011
[PolyGlot]
EngineCommand=glaurung.exe
EngineDir=C:\cygwin\home\hgm\glaurung22
Log=true
LogFile=learn.log
Book=true
BookLearn=true
BookFile=C:\WinBoard-4.5.0\WinBoard\testbook.bin
[Engine]
Hash=20
When I check the 'properties' of testbook.bin, indeed it now says it was last modified today. I haven't actually checked what the modification was (my WinBoard Edit Book function does not print the learn field yet), but from looking at the Polyglot code I guess this must be OK. It seems the learning stores then number of times the move is played, and the number of half-points scored with it, each as a 16-bit integer.
Edit:
I can confirm now that the book learn info is written by Polyglot exactly as it should. It only updates the stats for all book moves played by the engine that was using the book, not for the moves played by its opponent.
So it would just be a matter of having Polyglot's book-probing code use this statistics (in addition to the weights) to decide which move to pick. It could, for instance, use the info to modify the weights (not in the book,of course, but in its move-picking calculation) as follows:
weight *= (learnPoints+10.)/(learnTotal+1.)
This would bias it to play moves it did not play before (because the weights of such moves are multiplied by 10), but when moves are played many times with an average result (50%), the multiplier would converge (after many more than 10 plays) to 1, and above-average results would converge to a higher value (maximally doubling the weight), while very poor results could reduce it to nearly zero. To tune the aggressiveness of the learning,one could introduce an exponent f:
weight *= power( (learnPonts + power(10., 1./f))/(learnTotal+1.), f);