Fix bok retrieval mov moves that could be KxR castling v4.9.x
authorH.G.Muller <hgm@hgm-xboard.(none)>
Sun, 26 Oct 2025 18:58:08 +0000 (19:58 +0100)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Sun, 26 Oct 2025 18:58:08 +0000 (19:58 +0100)
The probing code for the Polyglot book corrected moves like e1h1,
which could be a castling in the KxR notation that UCI uses for Chess960,
to compliant CECP notation (e1g1). But it also did that for Rook or Queen
moves that were not castlings at all. Now we test for a King on the
from-square before doing this.

book.c

diff --git a/book.c b/book.c
index f0b8c74..626c354 100644 (file)
--- a/book.c
+++ b/book.c
@@ -563,9 +563,10 @@ move_to_string (char move_s[20], uint16 move)
     }
 
     if(gameInfo.variant != VariantNormal) return;
+    p = boards[currentMove][fr][ff];
+    if(p != WhiteKing && p != BlackKing) return; // not a castling
 
     // 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")){