From 4889715e47130eea364a6197d97d1917a8960aec Mon Sep 17 00:00:00 2001 From: rektdie Date: Wed, 2 Apr 2025 06:23:03 +0200 Subject: [PATCH] fixed marlinformat --- source/utils.cpp | 9 +++++---- source/utils.h | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/source/utils.cpp b/source/utils.cpp index 5de5d36..b9bd037 100644 --- a/source/utils.cpp +++ b/source/utils.cpp @@ -147,15 +147,17 @@ Move parseMove(Board &board, std::string_view str) { return Move(from, to, flag); } -std::array CompressPieces(Board &board) { +std::array CompressPieces(Board board) { const uint8_t UNMOVED_ROOK = 6; std::array compressed{}; + Bitboard occupancy = board.occupied; int index = 0; while (occupancy) { int square = occupancy.getLS1BIndex(); int pieceType = board.GetPieceType(square); + int pieceColor = board.GetPieceColor(square); int pieceCode = pieceType; if (pieceType == Rook) { @@ -166,7 +168,7 @@ std::array CompressPieces(Board &board) { pieceCode = UNMOVED_ROOK; } - pieceCode |= (board.sideToMove == Black ? (1 << 3) : 0); + pieceCode |= (pieceColor << 3); // Shift the color to the 3rd bit (bit 3) int byteIndex = index / 2; int bitShift = (index % 2) * 4; @@ -179,5 +181,4 @@ std::array CompressPieces(Board &board) { return compressed; } - -} +} \ No newline at end of file diff --git a/source/utils.h b/source/utils.h index fbd09b1..61b5ebc 100644 --- a/source/utils.h +++ b/source/utils.h @@ -30,6 +30,6 @@ int parseSquare(std::string_view str); Move parseMove(Board &board, std::string_view str); -std::array CompressPieces(Board &board); +std::array CompressPieces(Board board); }