diff options
| author | Adam <adammegarules1@gmail.com> | 2026-08-03 20:10:03 +0200 |
|---|---|---|
| committer | Adam <adammegarules1@gmail.com> | 2026-08-03 20:10:03 +0200 |
| commit | 9acc4d8b4fb616e8a0b0d2fed85a752c3a86ccc6 (patch) | |
| tree | dd4920f7b4007fd2fdf253099a6a9f7172439b51 /src/uci.cpp | |
| parent | b9b255a4816533ddcc8cb698c668822803faffdf (diff) | |
adding bitboard logging
Diffstat (limited to 'src/uci.cpp')
| -rw-r--r-- | src/uci.cpp | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/src/uci.cpp b/src/uci.cpp index 94e5693..31c4e43 100644 --- a/src/uci.cpp +++ b/src/uci.cpp @@ -76,6 +76,48 @@ Game initBoard( b.ThreeFoldMap[key] = 1; return b; }; +static void PrintBitboard(uint64_t bb, const std::string &name) { + std::cout << name << "\n"; + + for (int rank = 7; rank >= 0; --rank) { + std::printf("%d | ", 8 - rank); + + for (int file = 0; file < 8; file++) { + int sq = rank * 8 + file; + std::cout << (((bb >> sq) & 1ULL) ? "1 " : ". "); + } + + std::printf(" | %d\n", 8 - rank); + } + std::cout << " a b c d e f g h\n"; + std::cout << "0x" << std::hex << bb << std::dec << "\n\n"; +} + +static void DebugBitboards(const Game *g) { + static constexpr const char *pieceNames[] = { + "None", "Pawn", "Knight", "Bishop", "Rook", "Queen", "King", + }; + + std::cout << "========================\n"; + std::cout << "Occupancy Bitboards\n"; + std::cout << "========================\n"; + + PrintBitboard(g->WhitePieceBitboard, "White Occupancy"); + PrintBitboard(g->BlackPieceBitboard, "Black Occupancy"); + PrintBitboard(g->PieceBitboard, "All Pieces"); + + std::cout << "========================\n"; + std::cout << "Piece Bitboards\n"; + std::cout << "========================\n"; + + for (int color = 0; color < 2; ++color) { + std::cout << (color ? "White\n" : "Black\n"); + + for (int type = PAWN; type <= KING; ++type) { + PrintBitboard(g->PieceBitboards[color][type], pieceNames[type]); + } + } +} void Uci() { unordered_map<uint64_t, TranspositionsEntry> transpositions = {}; Game game = @@ -92,7 +134,7 @@ void Uci() { break; } if (cmd == "board") { - for (int rank = 0; rank < 8; rank++) { + for (int rank = 7; rank >= 0; --rank) { std::printf("%d |", 8 - rank); for (int file = 0; file < 8; file++) { @@ -104,6 +146,9 @@ void Uci() { std::printf(" | %d\n", 8 - rank); } } + if (cmd == "bits") { + DebugBitboards(&game); + } if (cmd == "uci") { cout << "id name " << engine_version() << "\n"; cout << "uciok\n"; |
