It would not be so easy to implement adequate error reporting / warning
here. Because at the point where the played move is added, there doesn't
have to be consistency between the book as it is on file / in memory,
and the text in the Edit Book window. It would be easy to check whether
the entered move is in the file, but what you would really want to know
is whether it is slready (and still) in the window. But for that you
first would have to parse the entire text in the window, and convert the
moves to XBoard's internal move representation. You cannot compare
text-wise, because the same move could be written in different ways
(e.g. SAN or long algebraic) if the user typed a move by hand in the
window.
I agree that it is in general good to protect the user from errors. But
there are already so many other errors possible that XBoard could never
detect. Such as releasing a slider on the wrong square while entering
the move that you are adding, through a mouse glitch. So I wonder
whether all this is really worth the effort. Perhaps hand-creating a
book is a feature that just should not be used at 3 am. ;-)
I did not address the issue of the PGN with the single game. This is due
to a general property of XBoard's Load Game function: 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,
from which you can select games. The Save Games as Book function loops
through this Game List. I suppose it could just add the current game if
there is no such list, rather than producing the error message. That
would be almost trivial. It doesn't seem a very sensible action, though,
to create a book from a single game.
Alan Bennet schreef op 23-10-2025 21:42:
Hi,
"Edit Book" - "add next move" allows to add a move that is already in
the list. I think this behavior has negative consequences for move
selection. see user session below. A workaround is to manually delete
duplicate row(s). There are some other quirks with saving/editing the
book but those are for a separate topic.
## := quirk
#### := issue being reported
--
Alan
$ xboard --version
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 "[Pp]olyglot" -e "[Bb]ook" ~/.xboardrc
-saveOutOfBookInfo true
-adapterCommand 'polyglot -noini -ec "%fcp" -ed "%fd" -uci
NalimovCache=%defaultCacheSizeEGTB -pg ShowTbHits=true'
-polyglotDir ""
-usePolyglotBook true
-polyglotBook "/home/REDACTED/chesspgbook/book.bin"
-bookDepth 12
-bookVariation 50
-discourageOwnBooks false
$ ls -Gg --time-style=+%Y.%m.%dT%H%M -Gg ~/chesspgbook/
total 1456
-rwxr-xr-x 1 1487264 2023.03.03T1358 Performance.bin
$ cat ~/Documents/tmp/test.pgn
[White "fischer"]
[Result "1-0"]
e4 e5 Nf3 1-0
[White "spassky"]
[Result "1-0"]
d4 Nf6 c4 1-0
[White "kramnik"]
[Result "1-0"]
Nf3 d5 d4 1-0
$ xboard &
[1] 21626
GUI | File | Load Game | Recently Used | test.pgn
GUI | File | Save Games as Book
## success here because 3 games
## but if only 1 game in PGN ,
## xboard complains "Game list not loaded or empty"
$ ls -Gg --time-style=+%Y.%m.%dT%H%M -Gg ~/chesspgbook/
total 1456
-rw-r--r-- 1 0 2025.10.23T1454 book.bin
-rwxr-xr-x 1 1487264 2023.03.03T1358 Performance.bin
## 0-byte file, xboard does not commit the book until Quit
## at this moment GUI | Edit | Edit Book does nothing
GUI | File | Quit
$ ls -Gg --time-style=+%Y.%m.%dT%H%M -Gg ~/chesspgbook/
total 1460
-rw-r--r-- 1 64 2025.10.23T1456 book.bin
-rwxr-xr-x 1 1487264 2023.03.03T1358 Performance.bin
[1]+ Done xboard
$ hexdump -e '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
463b96181691fc9c 031c 0001 00000001
463b96181691fc9c 02db 0001 00000001
463b96181691fc9c 0195 0001 00000001
ffffffffffffffff 0000 0000 00000000
## only 3 moves in the book, should be 9
## i am going to investigate
## and maybe send another report
$ xboard &
[1] 21795
GUI | Edit | Edit Book
33.3% 1 e4 {1/0}
33.3% 1 d4 {1/0}
33.3% 1 Nf3 {1/0}
GUI | manually edit the weights (1,1,1) to (2,3,4)
33.3% 2 e4 {1/0}
33.3% 3 d4 {1/0}
33.3% 4 Nf3 {1/0}
GUI | commit changes
22.2% 2 e4 {1/0}
33.3% 3 d4 {1/0}
44.4% 4 Nf3 {1/0}
GUI | add next move | c2c4
22.2% 2 e4 {1/0}
33.3% 3 d4 {1/0}
44.4% 4 Nf3 {1/0}
0.0% 1 c4
GUI | commit changes
20.0% 2 e4 {1/0}
30.0% 3 d4 {1/0}
40.0% 4 Nf3 {1/0}
10.0% 1 c4
GUI | add next move | d2d4 #### d2d4 already in list
20.0% 2 e4 {1/0}
30.0% 3 d4 {1/0}
40.0% 4 Nf3 {1/0}
10.0% 1 c4
0.0% 1 d4
#### i think xboard should give an ERR instead of adding the duplicate
GUI | commit changes
18.2% 2 e4 {1/0}
27.3% 3 d4 {1/0}
36.4% 4 Nf3 {1/0}
9.1% 1 c4
9.1% 1 d4
$ hexdump -e '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
463b96181691fc9c 031c 0002 00000001
463b96181691fc9c 02db 0003 00000001
463b96181691fc9c 0195 0004 00000001
463b96181691fc9c 029a 0001 00000000
463b96181691fc9c 02db 0001 00000000
ffffffffffffffff 0000 0000 00000000
GUI | manually delete the row " 9.1% 1 d4 "
## if delete just the weight, xboard does some weird math
18.2% 2 e4 {1/0}
27.3% 3 d4 {1/0}
36.4% 4 Nf3 {1/0}
9.1% 1 c4
GUI | commit changes
20.0% 2 e4 {1/0}
30.0% 3 d4 {1/0}
40.0% 4 Nf3 {1/0}
10.0% 1 c4
$ 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
463b96181691fc9c 031c 0002 00000001
463b96181691fc9c 02db 0003 00000001
463b96181691fc9c 0195 0004 00000001
463b96181691fc9c 029a 0001 00000000
ffffffffffffffff 0000 0000 00000000
ffffffffffffffff 0000 0000 00000000
GUI | File | Quit
$