diff options
| -rw-r--r-- | src/board/fen.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/board/fen.cpp b/src/board/fen.cpp index e020e78..f44719a 100644 --- a/src/board/fen.cpp +++ b/src/board/fen.cpp @@ -2,8 +2,10 @@ #include "board.hpp" #include <cassert> #include <cctype> +#include <cstdint> #include <cstdlib> #include <cstring> +#include <iostream> #include <print> #include <string> #include <sys/types.h> @@ -185,5 +187,18 @@ void setBoardFen(const std::string &fen, Game *g) { break; } g->enPassant = enpassant; + updateBitboards(g); + + int whiteKingCount = __builtin_popcountll(g->PieceBitboards[true][KING]); + int blackKingCount = __builtin_popcountll(g->PieceBitboards[false][KING]); + + if (whiteKingCount != 1) { + std::cerr << "ERROR: expected exactly one white king\n"; + exit(1); + } + if (blackKingCount != 1) { + std::cerr << "ERROR: expected exactly one black king\n"; + exit(1); + } } |
