Ah, I see what causes the problem. The long-algebraic for Rh1 produced by move_to_string already is in error, and produces e1g1. The culprit is a patch aimed to catch non-compliant notation for castling as King takes own Rook (used in UCI Chess960 implementation) in normal Chess. I copied this routine from the public-domain code for probing Polyglot books. At that time I had already noticed that the patch was no good, and written a remark about that in a comment:

    // correct FRC-style castlings in variant normal.
// [HGM] This is buggy code! e1h1 could very well be a normal R or Q move.
    if(!strcmp(move_s,"e1h1")){
      safeStrCpy(move_s,"e1g1", 6);
    }else  if(!strcmp(move_s,"e1a1")){
      safeStrCpy(move_s,"e1c1", 6);
    }else  if(!strcmp(move_s,"e8h8")){
      safeStrCpy(move_s,"e8g8", 6);
    }else  if(!strcmp(move_s,"e8a8")){
      safeStrCpy(move_s,"e8c8", 6);
    }

But then I apparently forgot all about it. What is needed here is first a test to see if we are in variant normal. And then whether there is a King on the from-square. If these conditions are not both satisfied, this code should not be executed. I guess we have gotten away with this for so long because in genuine opening lines there will almost never be a Rook on e1/e8. And even if there is, it is very unlikely that anyone moved it to the corner square.

Alan Bennet schreef op 26-10-2025 07:12:
Hi,

Thanks again for replying. I have a new issue with "add next move", but first to tidy up the previous email.

On 10/25/25 08:36, h.g.muller" via XBoard and WinBoard bugs wrote:

It would not be so easy to implement adequate error reporting / warning here.

Okay. I don't _really_ need it, because if I make a mistake I can fix it.

... Perhaps hand-creating a book is a feature that just should not be used at 3 am. ;-)

Indeed!

... a PGN with a single game is immediately loaded in the memory buffer as the current game, but when there are more games in the file a Game List is created,

Expected behavior then. I can just make sure there is more than one game.

## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ##

New issue. For the following move list I am having trouble adding the move 24.Rh1 to the book. It keeps adding 24.Rg1 instead. Or it's doing something else. Very spooky, just in time for Halloween.

1.e4 d5 2.exd5 Qxd5 3.Nc3 Qa5 4.d4 Nf6 5.Nf3 c6 6.Bd2 Bf5 7.Bc4 e6 8.Qe2 Bb4 9.O-O-O Nbd7 10.a3 Bxc3 11.Bxc3 Qc7 12.Ne5 Nd5 13.Bd2 b5 14.Bb3 Nxe5 15.dxe5 O-O-O 16.g4 Bg6 17.f4 h5 18.h3 a6 19.Qf3 f5 20.exf6 gxf6 21.Rhe1 hxg4 22.hxg4 e5 23.f5 Bf7

User debug session below. Note that I am using the xboard feature that allows me to add the same move more than once. :)

--
Alan


$ xboard -v
xboard version 4.9.1

configure options: prefix=/usr; datarootdir=/usr/share; datadir=/usr/share; gamedatadir=/usr/share/games/xboard; desktopdir=/usr/share/applications; mimedir=/usr/share/mime/packages; iconsdir=/usr/share/icons/hicolor/48x48/apps; svgiconsdir=/usr/share/icons/hicolor/scalable/apps; infodir=/usr/share/info; sysconfigdir=; update_mimedb=yes; NLS=yes; GTK=yes; Xaw3d=no; Xaw=no; ptys=pipes; zippy=yes; sigint=yes

$ grep -e "-bookDepth" ~/.xboardrc
-bookDepth 51

$ cat ~/Documents/tmp/Rf1-Rg1-Rh1.pgn
[White "Rf1"]
[Result "1/2-1/2"]

1. e4 d5 2. exd5 Qxd5 3. Nc3 Qa5 4. d4 Nf6 5. Nf3 c6 6. Bd2 Bf5
7. Bc4 e6 8. Qe2 Bb4 9. O-O-O Nbd7 10. a3 Bxc3 11. Bxc3 Qc7 12.
Ne5 Nd5 13. Bd2 b5 14. Bb3 Nxe5 15. dxe5 O-O-O 16. g4 Bg6 17. f4
h5 18. h3 a6 19. Qf3 f5 20. exf6 gxf6 21. Rhe1 hxg4 22. hxg4 e5
23. f5 Bf7
24. Rf1 Rhe8 25. Rfe1
1/2-1/2

[White "Rg1"]
[Result "1/2-1/2"]

1. e4 d5 2. exd5 Qxd5 3. Nc3 Qa5 4. d4 Nf6 5. Nf3 c6 6. Bd2 Bf5
7. Bc4 e6 8. Qe2 Bb4 9. O-O-O Nbd7 10. a3 Bxc3 11. Bxc3 Qc7 12.
Ne5 Nd5 13. Bd2 b5 14. Bb3 Nxe5 15. dxe5 O-O-O 16. g4 Bg6 17. f4
h5 18. h3 a6 19. Qf3 f5 20. exf6 gxf6 21. Rhe1 hxg4 22. hxg4 e5
23. f5 Bf7
24. Rg1 Rhe8 25. Rge1
1/2-1/2

[White "Rh1"]
[Result "1/2-1/2"]

1. e4 d5 2. exd5 Qxd5 3. Nc3 Qa5 4. d4 Nf6 5. Nf3 c6 6. Bd2 Bf5
7. Bc4 e6 8. Qe2 Bb4 9. O-O-O Nbd7 10. a3 Bxc3 11. Bxc3 Qc7 12.
Ne5 Nd5 13. Bd2 b5 14. Bb3 Nxe5 15. dxe5 O-O-O 16. g4 Bg6 17. f4
h5 18. h3 a6 19. Qf3 f5 20. exf6 gxf6 21. Rhe1 hxg4 22. hxg4 e5
23. f5 Bf7
24. Rh1 Rhe8 25. Rhe1
1/2-1/2


$ rm ~/chesspgbook/book.bin

$ xboard -ncp &
[1] 29001

GUI | File | Load Game | Recently Used | Rf1-Rg1-Rh1.pgn

GUI | File | Save Games as Book

GUI | File | Quit

$ hexdump -ve '1/1 "%.02x" 1/1 "%.02x" 1/1 "%.02x" 1/1 "%.02x" 1/1 "%.02x" 1/1 "%.02x" 1/1 "%.02x" 1/1 "%.02x " 1/1 "%.02x" 1/1 "%.02x " 1/1 "%.02x" 1/1 "%.02x " 1/1 "%.02x" 1/1 "%.02x" 1/1 "%.02x" 1/1 "%02x " "\n"' ~/chesspgbook/book.bin | grep -F "612d49983aa49672"
612d49983aa49672 0105 0001 00010001         ##  Rf1
612d49983aa49672 0106 0001 00010001         ##  Rg1
612d49983aa49672 0107 0001 00010001         ##  Rh1
[1]+  Done                    xboard -ncp

$ xboard -ncp &
[1] 29061

GUI | Edit | Edit Book

GUI | right-click through the book until 23...Bf7 is played

 33.3%     1 Rf1 {1/1}
 33.3%     1 Rg1 {1/1}
 33.3%     1 Rg1 {1/1}                      ##  where is Rh1 ??

GUI | add next move | drag Re1-h1

 33.3%     1 Rf1 {1/1}
 33.3%     1 Rg1 {1/1}
 33.3%     1 Rg1 {1/1}
  0.0%     1  Rh1                           ##  so far so good

GUI | commit changes

 25.0%     1 Rf1 {1/1}
 25.0%     1 Rg1 {1/1}
 25.0%     1 Rg1 {1/1}
 25.0%     1 Rg1                            ##  what happened ??

GUI | File | Quit

$ hexdump -ve '1/1 "%.02x" 1/1 "%.02x" 1/1 "%.02x" 1/1 "%.02x" 1/1 "%.02x" 1/1 "%.02x" 1/1 "%.02x" 1/1 "%.02x " 1/1 "%.02x" 1/1 "%.02x " 1/1 "%.02x" 1/1 "%.02x " 1/1 "%.02x" 1/1 "%.02x" 1/1 "%.02x" 1/1 "%02x " "\n"' ~/chesspgbook/book.bin | grep -F "612d49983aa49672"
612d49983aa49672 0105 0001 00010001         ##  Rf1
612d49983aa49672 0106 0001 00010001         ##  Rg1
612d49983aa49672 0106 0001 00010001         ##  Rg1
612d49983aa49672 0107 0001 00000000         ##  Rh1  spooky
[1]+  Done                    xboard -ncp

$

Reply via email to