aboutsummaryrefslogtreecommitdiff
path: root/src/book.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/book.cpp')
-rw-r--r--src/book.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/book.cpp b/src/book.cpp
index abf9693..2d499ca 100644
--- a/src/book.cpp
+++ b/src/book.cpp
@@ -81,6 +81,18 @@ static uint16_t PolyglotToMono(uint16_t polyglotMove) {
uint8_t from = (polyglotMove >> 6) & 63;
uint8_t promo = (polyglotMove >> 12) & 7;
+ // Polyglot encodes castling as king moving to the rook's square.
+ // Convert to king-moves-two-squares form that the engine expects.
+ if (from == 4 && to == 7) {
+ to = 6; // white kingside: e1h1 -> e1g1
+ } else if (from == 4 && to == 0) {
+ to = 2; // white queenside: e1a1 -> e1c1
+ } else if (from == 60 && to == 63) {
+ to = 62; // black kingside: e8h8 -> e8g8
+ } else if (from == 60 && to == 56) {
+ to = 58; // black queenside: e8a8 -> e8c8
+ }
+
PieceType promotion = NONEPIECE;
switch (promo) {
case 0: