Datagen #46
No files matched your search
+5
-4
@@ -147,15 +147,17 @@ Move parseMove(Board &board, std::string_view str) {
|
|||||||
return Move(from, to, flag);
|
return Move(from, to, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::array<uint8_t, 16> CompressPieces(Board &board) {
|
std::array<uint8_t, 16> CompressPieces(Board board) {
|
||||||
const uint8_t UNMOVED_ROOK = 6;
|
const uint8_t UNMOVED_ROOK = 6;
|
||||||
std::array<uint8_t, 16> compressed{};
|
std::array<uint8_t, 16> compressed{};
|
||||||
|
|
||||||
Bitboard occupancy = board.occupied;
|
Bitboard occupancy = board.occupied;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
while (occupancy) {
|
while (occupancy) {
|
||||||
int square = occupancy.getLS1BIndex();
|
int square = occupancy.getLS1BIndex();
|
||||||
int pieceType = board.GetPieceType(square);
|
int pieceType = board.GetPieceType(square);
|
||||||
|
int pieceColor = board.GetPieceColor(square);
|
||||||
int pieceCode = pieceType;
|
int pieceCode = pieceType;
|
||||||
|
|
||||||
if (pieceType == Rook) {
|
if (pieceType == Rook) {
|
||||||
@@ -166,7 +168,7 @@ std::array<uint8_t, 16> CompressPieces(Board &board) {
|
|||||||
pieceCode = UNMOVED_ROOK;
|
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 byteIndex = index / 2;
|
||||||
int bitShift = (index % 2) * 4;
|
int bitShift = (index % 2) * 4;
|
||||||
@@ -179,5 +181,4 @@ std::array<uint8_t, 16> CompressPieces(Board &board) {
|
|||||||
|
|
||||||
return compressed;
|
return compressed;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
+1
-1
@@ -30,6 +30,6 @@ int parseSquare(std::string_view str);
|
|||||||
|
|
||||||
Move parseMove(Board &board, std::string_view str);
|
Move parseMove(Board &board, std::string_view str);
|
||||||
|
|
||||||
std::array<uint8_t, 16> CompressPieces(Board &board);
|
std::array<uint8_t, 16> CompressPieces(Board board);
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user