Bug with usebook and edit position?

Discussions about the WinBoard protocol. Here you can also report bugs and request new features.

Moderators: hgm, Andres Valverde

Bug with usebook and edit position?

Postby what_no2000 » 12 Jul 2016, 20:28

In WinBoard 4.8.0b I think there is an issue with using a GUI book (usebook) together with the edit position command. In short if one edit to a position that will play a book move, no move will be played on the board and the engine will run out of time.

Steps to reproduce:
  • Winboard startup dialog
  • Select "Fruit 2.1" -fcp "polyglot _PG/fruit.ini"
  • Additional options: -debug
  • Options/Common engine
  • select use book
  • unselect first has own book
  • unselect second has own book
  • mode/edit position
  • select a position that gives a book hit: "rnbqkbnr/pppp1ppp/8/4p3/4P3/8/PPPP1PPP/RNBQKBNR w KQkq - 0 1"
  • mode/machine white

Result: White clock will count down, but white will never make a move.

If I rerun the steps, but keep "first has own book" selected, bypassing WinBoard's GUI book, everything works okay.

Looking at the debug log it looks like WinbBoard GUI decide on a book move, send it to the engine, but then sending an undo command. After that the GUI does not do the book move on the board, but keeps the engine in force mode and lets white clock run out of time.

This is from the debug log:
Code: Select all
100920 >first : ping 4
Impossible move , type = 0
100921 >first : force
write FEN 50-move: 0 0 0
e0. p=-6
100921 >first : setboard rnbqkbnr/pppp1ppp/8/4p3/4P3/8/PPPP1PPP/RNBQKBNR w KQkq - 0 1
EditPosDone
100923 >first : name AW
100923 >first : time 30000
100923 >first : otim 30000
book key = 0844931a6ef4b9a0
book move field = 405
book hit = g1f3
100923 >first : force
100924 >first : usermove g1f3
nps: w=-1, b=-1
Undoing extra move from first, gameMode 1
100935 >first : undo
100936 <first : # readyok
100936 <first :
100936 <first : pong 4
what_no2000
 
Posts: 5
Joined: 03 Nov 2009, 10:03

Re: Bug with usebook and edit position?

Postby H.G.Muller » 14 Jul 2016, 19:09

Indeed, you are right. Thanks for reporting this. The problem is that in case of a book hit, WinBoard fakes that the engine sent it that book move in response to a 'go'command (while in fact the 'go'command was never sent). But this is all done in the same output burst together with a 'ping 4'. So if the engine had been playing it would heve responded 'pong 4' before responding to 'go' with a move. In the faked sequence the move comes before the 'ping', so WinBoard classifies it as a move from a previous game, which it should ignore or undo.

Nasty problem. I guess WinBoard should really wait for the engine to catch up with the ping before even consulting the book.
User avatar
H.G.Muller
 
Posts: 3453
Joined: 16 Nov 2005, 12:02
Location: Diemen, NL

Re: Bug with usebook and edit position?

Postby H.G.Muller » 28 Jul 2016, 15:06

I finally had some time to address this problem. The solution I used is just delay processing of the book move WinBoard selected for the engine until the pings and pongs are balanced. In TwoMachines mode this was already done.

I uploaded the fixed version to http://hgm.nubati.net/winboard491.zip . Perhaps you can test it to see if all problems now have gone away. I also have it print an extra "force" after "black" when it uses the latter in combination with "edit" to set upa black-to-move position, to make sure setting up the position does not cause the engine to leave force mode. The erroneous adjudication when black checkmates with only two pieces (which was mistaken for a bare King in 4.9.0, because increase of the number of piece types to 66 had caused the black King to be counted as a white piece) is fixed too.

I guess we should release this version as quickly as possible as 4.9.1.
User avatar
H.G.Muller
 
Posts: 3453
Joined: 16 Nov 2005, 12:02
Location: Diemen, NL

Re: Bug with usebook and edit position?

Postby what_no2000 » 30 Jul 2016, 15:53

I have tried the winboard4.9.1.exe version, and with that version I can not reproduce the bug with Fruit 2.1 described in this thread.

However I still manage to get a error situation with FairyMax when following the steps to reproduce from the "Bug with black/white command together with usebook and edit"-thread. (The error situation is a slightly different from before.)

Steps to reproduce:
  • Winboard startup dialog
  • Select "Fairy-Max 4.8" -fcp fmax -fd "..\Fairy-Max" /firstXBook
  • Additional options: -debug
  • Options/Common engine
  • Select use book
  • Unselect first has own book
  • Unselect second has own book
  • Play e2e4
  • Wait for the black book move
  • Mode/edit position
  • Select a position that gives a book hint with black in the move: "rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq - 0 1". Do this by moving blacks piece back on the Board and select black to play, or by copying the FEN to the board, both situation will now give the same result.
  • Mode/machine black
  • Wait

Result:
  • Winboard will play a book move for black.
  • The engine will start to think/ponder and play a white move.
  • The engine will think its playing white, so it will do no more moves.
  • Winboard thinks the engine plays black, so it will wait for the engine to play.

This is the important part of the debug log:

I don't see any additional force commands in the log close to the white or black command, as you mentioned.

Code: Select all
43231 >first : .
EditPosDone
43232 >first : white
43232 >first : time 30000
43232 >first : otim 30000
43232 >first : black
book key = 823c9b50fd114196
book move field = 3307
book hit = d7d6
43232 >first : d7d6
nps: w=-1, b=-1
43253 <first : pong 2
# I have removed post thinking output from the engine and some debug from the engine here.
47547 <first : move b1c3


This is the full debug log:

Code: Select all
recognized 'normal' (-1) as variant normal
recognized 'normal' (-1) as variant normal
shuffleOpenings = 0
Version: WinBoard 4.9.160728 + fmax
Reset(1, 0) from gameMode 0
recognized 'normal' (-1) as variant normal
GameEnds(0, (null), 2)
shuffleOpenings = 0
StartChildProcess (dir="..\Fairy-Max") fmax
542 >first : xboard
protover 2
561 <first : tellics say     Fairy-Max 4.8V
561 <first : tellics say     by H.G. Muller
561 <first : tellics say Gothic Chess is protected by U.S. patent #6,481,716 by Ed Trice.
561 <first : tellics say Falcon Chess is protected by U.S. patent #5,690,334 by George W. Duke
562 <first : feature myname="Fairy-Max 4.8V"
562 >first : accepted myname
562 <first : feature memory=1
562 >first : accepted memory
562 <first : feature setboard=0 xedit=1 ping=1 done=0
562 >first : accepted setboard
562 >first : accepted xedit
563 >first : accepted ping
563 >first : accepted done
563 <first : feature variants="normal,nocastle,shatranj,asean,makruk,cambodian,ai-wok,courier,knightmate,capablanca,gothic,falcon,cylinder,berolina,super,seirawan,spartan,great,light-brigade,king-of-the-hill,bifurcator,team-mate,fairy"
563 >first : accepted variants
563 <first : feature option="Resign -check 0"
564 >first : accepted option
564 <first : feature option="Resign Threshold -spin 800 200 1200"
564 >first : accepted option
564 <first : feature option="Claim draw after -spin 50 0 200"
564 >first : accepted option
564 <first : feature option="Ini File -file fmax.ini"
564 >first : accepted option
564 <first : feature option="Multi-PV Margin -spin 0 0 1000"
565 >first : accepted option
565 <first : feature option="Variant fairy selects -combo FIDE-Clobberers /// Clobberers-FIDE /// FIDE-Nutters /// Nutters-FIDE /// Clobberers-Nutters /// Nutters-Clobberers /// FIDE-Rookies /// Rookies-FIDE /// Clobberers-Rookies /// Rookies-Clobberers"
565 >first : accepted option
565 <first : feature option="Makruk rules -combo makruk /// Cambodian /// Ai-wok"
566 >first : accepted option
566 <first : feature option="Dummy Slider Example -slider 20 0 100"
566 >first : accepted option
566 <first : feature option="Dummy String Example -string happy birthday!"
566 >first : accepted option
566 <first : feature option="Dummy Path Example -path ."
566 >first : accepted option
566 <first : feature option="Info -button"
567 >first : accepted option
567 <first : feature option="Clear Hash -button"
567 >first : accepted option
567 <first : feature done=1
567 >first : accepted done
583 >first : memory 68
583 >first : new
random
583 >first : level 40 5 0
583 >first : post
583 >first : hard
583 >first : ping 1
Impossible move , type = 0
622 <first : pong 1
nps: w=-1, b=-1
nps: w=-1, b=-1
20922 >first : time 30000
20922 >first : otim 30000
book key = 823c9b50fd114196
book move field = 3364
book hit = e7e5
20923 >first : force
20923 >first : e2e4
20923 >first : e7e5
silence
Interrupting first
26147 >first : force
43227 >first : memory 68
43227 >first : new
random
43227 >first : level 40 5 0
43227 >first : post
43227 >first : hard
43227 >first : ping 2
Impossible move e7e5, type = 0
43228 >first : force
43229 >first : a2a3
43229 >first : edit
43229 >first : #
43229 >first : Pe4
43229 >first : Pa2
43229 >first : Pb2
43229 >first : Pc2
43229 >first : Pd2
43229 >first : Pf2
43229 >first : Pg2
43229 >first : Ph2
43229 >first : Ra1
43229 >first : Nb1
43229 >first : Bc1
43229 >first : Qd1
43229 >first : Ke1
43229 >first : Bf1
43229 >first : Ng1
43230 >first : Rh1
43230 >first : c
43230 >first : Ra8
43230 >first : Nb8
43230 >first : Bc8
43230 >first : Qd8
43230 >first : Ke8
43230 >first : Bf8
43230 >first : Ng8
43230 >first : Rh8
43230 >first : Pa7
43230 >first : Pb7
43230 >first : Pc7
43230 >first : Pd7
43230 >first : Pe7
43230 >first : Pf7
43230 >first : Pg7
43230 >first : Ph7
43231 >first : .
EditPosDone
43232 >first : white
43232 >first : time 30000
43232 >first : otim 30000
43232 >first : black
book key = 823c9b50fd114196
book move field = 3307
book hit = d7d6
43232 >first : d7d6
nps: w=-1, b=-1
43253 <first : pong 2
43253 <first : # times @ 17125524
43253 <first : # 16+16 pieces, centr = (1,1) R=40
43253 <first :  1     15        0          3 d2d4
43255 <first :  1     27        0          5 d2d3
43256 <first :  1     30        0          7 f2f4
43258 <first :  2      4        0         15 f2f4 c7c5
43258 <first :  2      6        0         53 b1c3 c7c5
43259 <first :  2     11        0        233 d2d4 b8c6
43260 <first :  2     13        0        240 d2d3 c7c5
43261 <first :  3     27        0        681 d2d3 c7c5 b1c3
43262 <first :  3     29        0       1002 f2f4 c7c5 b1c3
43262 <first :  4      6        1       2375 f2f4 b8c6 b1c3 c8e6
silence
43353 <first :  4      7        1       5515 d2d4 b8c6 b1c3 c8e6
43354 <first :  4     13        1       5999 d2d3 c7c5 c1f4 b8c6
43355 <first :  5      8        1       7651 d2d3 c7c5 c1f4 b8c6 b1c3
43355 <first :  5     11        3      15098 f2f4 c7c5 g1f3 b8c6 b1c3
43356 <first :  5     12        6      39711 h2h3 c7c5 d2d4 b8c6 g1f3
43356 <first :  5     13        9      74366 g1h3 b8c6 d2d3 c8e6 b1c3
43358 <first :  5     19       10      90552 g1f3 b8c6 d2d3 c8e6 b1c3
43386 <first :  6     -3       14     117499 g1f3 b8c6 f1d3 c6b4 e1g1 b4d3
43407 <first :  6      9       15     138943 g1h3 b8c6 f1d3 c6e5 e1g1 e5d3
43432 <first :  6     13       18     163786 g1e2 b8c6 f2f4 c8e6 b1c3 g8f6
43612 <first :  7     16       35     346061 g1e2 c7c5 d2d3 b8c6 c1f4 d8b6 d1c1
43839 <first :  7     19       59     575769 a2a4 b8c6 d2d4 e7e5 g1f3 c8g4 f1b5
44079 <first :  7     25       82     813409 d2d4 b8d7 b1d2 c7c5 g1f3 g8f6 f1d3
45379 <first :  8      2      213    2111486 d2d4 g8f6 b1c3 c7c6 c1f4 c8e6
47198 <first :  8     13      394    3933321 b1c3 g8f6 g1f3 c7c5 f1d3 b8c6 e1g1 c8e6
47547 <first : # times @ 17129830: real=4306 cpu=4294
47547 <first : # promo = 0 (`) GT = 0
47547 <first : move b1c3
silence
GameEnds(29, xboard exit, 2)
write FEN 50-move: 0 3 1
e1. p=-6
e2. p=-3
e3. p=-6
Interrupting first
53608 >first : result * {xboard exit}
53608 >first : force
53608 >first : ping 3
53608 >first : quit
name = '%APPDATA%\winboard48.ini', expanded name = 'C:\Users\AW\AppData\Roaming\winboard48.ini'
what_no2000
 
Posts: 5
Joined: 03 Nov 2009, 10:03


Return to WinBoard development and bugfixing

Who is online

Users browsing this forum: No registered users and 18 guests