reworked viri move | bench 1422551

This commit is contained in:
rektdie committed 2025-04-18 10:08:43 +02:00
1 parent beccce4ae7
commit e19af9df0e
1 file changed
+15 -21
+15 -21
View File
@@ -84,48 +84,42 @@ public:
uint16_t viriMove = 0; uint16_t viriMove = 0;
int flags = GetFlags(); int flags = GetFlags();
// Define masks for different parts of the move const uint16_t TO_MASK = 0xFC0;
const uint16_t FROM_MASK = 0x3F; // 6 bits for the 'from' square (0-63) const uint16_t MOVE_TYPE_MASK = 0x3000;
const uint16_t TO_MASK = 0x3F; // 6 bits for the 'to' square (0-63) const uint16_t PROMO_PIECE_MASK = 0xC000;
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();
viriMove |= (MoveFrom() & FROM_MASK); // Mask the 'from' square viriMove |= (MoveTo() << 6) & TO_MASK;
viriMove |= (MoveTo() & TO_MASK) << 6; // Mask the 'to' square
// Determine move type (bits 12-13)
uint16_t moveType = 0; uint16_t moveType = 0;
uint16_t promoPiece = 0; uint16_t promoPiece = 0;
if (flags == kingCastle || flags == queenCastle) { if (flags == kingCastle || flags == queenCastle) {
moveType = 1; // Castling moveType = 2;
} }
else if (flags == epCapture) { else if (flags == epCapture) {
moveType = 2; // En passant moveType = 1;
} }
else if (flags >= knightPromotion && flags <= queenPromoCapture) { else if (flags >= knightPromotion && flags <= queenPromoCapture) {
moveType = 3; // Promotion moveType = 3;
// Set promo piece (bits 14-15)
if (flags == knightPromotion || flags == knightPromoCapture) { if (flags == knightPromotion || flags == knightPromoCapture) {
promoPiece = 1; // Knight promoPiece = 0;
} }
else if (flags == bishopPromotion || flags == bishopPromoCapture) { else if (flags == bishopPromotion || flags == bishopPromoCapture) {
promoPiece = 2; // Bishop promoPiece = 0;
} }
else if (flags == rookPromotion || flags == rookPromoCapture) { else if (flags == rookPromotion || flags == rookPromoCapture) {
promoPiece = 3; // Rook promoPiece = 0;
} }
else if (flags == queenPromotion || flags == queenPromoCapture) { else if (flags == queenPromotion || flags == queenPromoCapture) {
promoPiece = 4; // Queen promoPiece = 0;
} }
} }
// Apply move type (bits 12-13) using mask viriMove |= (moveType << 12) & MOVE_TYPE_MASK;
viriMove |= (moveType & MOVE_TYPE_MASK);
// Apply promotion piece (bits 14-15) using mask viriMove |= (promoPiece << 14) & PROMO_PIECE_MASK;
viriMove |= (promoPiece & PROMO_PIECE_MASK);
return viriMove; return viriMove;
} }