Datagen #46

Merged
rektdie merged 27 commits from datagen into main 2025-04-03 03:54:14 +02:00
Showing only changes of commit 34f5bbdd43 - Show all commits
+18 -10
View File
@@ -80,9 +80,15 @@ public:
uint16_t viriMove = 0; uint16_t viriMove = 0;
int flags = GetFlags(); int flags = GetFlags();
// Set from and to squares (6 bits each) // Define masks for different parts of the move
viriMove |= MoveFrom(); const uint16_t FROM_MASK = 0x3F; // 6 bits for the 'from' square (0-63)
viriMove |= MoveTo() << 6; const uint16_t TO_MASK = 0x3F; // 6 bits for the 'to' square (0-63)
const uint16_t MOVE_TYPE_MASK = 0x3 << 12; // 2 bits for the move type (castling, en passant, promotion, etc.)
const uint16_t PROMO_PIECE_MASK = 0x3 << 14; // 2 bits for the promotion piece (knight, bishop, etc.)
// Set 'from' and 'to' squares
viriMove |= (MoveFrom() & FROM_MASK); // Mask the 'from' square
viriMove |= (MoveTo() & TO_MASK) << 6; // Mask the 'to' square
// Determine move type (bits 12-13) // Determine move type (bits 12-13)
uint16_t moveType = 0; uint16_t moveType = 0;
@@ -98,22 +104,24 @@ public:
moveType = 3; // Promotion moveType = 3; // Promotion
// Set promo piece (bits 14-15) // Set promo piece (bits 14-15)
if (flags == knightPromotion || flags == knightPromoCapture) { if (flags == knightPromotion || flags == knightPromoCapture) {
promoPiece = 0; // Knight promoPiece = 1; // Knight
} }
else if (flags == bishopPromotion || flags == bishopPromoCapture) { else if (flags == bishopPromotion || flags == bishopPromoCapture) {
promoPiece = 1; // Bishop promoPiece = 2; // Bishop
} }
else if (flags == rookPromotion || flags == rookPromoCapture) { else if (flags == rookPromotion || flags == rookPromoCapture) {
promoPiece = 2; // Rook promoPiece = 3; // Rook
} }
else if (flags == queenPromotion || flags == queenPromoCapture) { else if (flags == queenPromotion || flags == queenPromoCapture) {
promoPiece = 3; // Queen promoPiece = 4; // Queen
} }
} }
// else moveType remains 0 (normal move)
viriMove |= moveType << 12; // Apply move type (bits 12-13) using mask
viriMove |= promoPiece << 14; viriMove |= (moveType & MOVE_TYPE_MASK);
// Apply promotion piece (bits 14-15) using mask
viriMove |= (promoPiece & PROMO_PIECE_MASK);
return viriMove; return viriMove;
} }