if ( ((ss >> col) && (col >= 'a' && col <= 'h'))
&& ((ss >> row) && (row == '3' || row == '6')))
{
- st->epSquare = make_square(file_from_char(col), rank_from_char(row));
+ st->epSquare = make_square(File(col - 'a') + FILE_A, Rank(row - '1') + RANK_1);
// Ignore if no capture is possible
Color them = opposite_color(sideToMove);
for (Square sq = sqH; sq >= sqA; sq--)
if (piece_on(sq) == rook)
{
- do_allow_oo(c);
+ set_castle_kingside(c);
initialKRFile = square_file(sq);
break;
}
for (Square sq = sqA; sq <= sqH; sq++)
if (piece_on(sq) == rook)
{
- do_allow_ooo(c);
+ set_castle_queenside(c);
initialQRFile = square_file(sq);
break;
}
File rookFile = File(token - 'A') + FILE_A;
if (rookFile < initialKFile)
{
- do_allow_ooo(c);
+ set_castle_queenside(c);
initialQRFile = rookFile;
}
else
{
- do_allow_oo(c);
+ set_castle_kingside(c);
initialKRFile = rookFile;
}
}
return move_is_pl_slow(m);
// Is not a promotion, so promotion piece must be empty
- if (move_promotion_piece(m) - 2 != PIECE_TYPE_NONE)
+ if (promotion_piece_type(m) - 2 != PIECE_TYPE_NONE)
return false;
// If the from square is not occupied by a piece belonging to the side to
{
clear_bit(&b, from);
- switch (move_promotion_piece(m))
+ switch (promotion_piece_type(m))
{
case KNIGHT:
return bit_is_set(attacks_from<KNIGHT>(to), ci.ksq);
st->epSquare = SQ_NONE;
}
- // Update castle rights, try to shortcut a common case
- int cm = castleRightsMask[from] & castleRightsMask[to];
- if (cm != ALL_CASTLES && ((cm & st->castleRights) != st->castleRights))
+ // Update castle rights if needed
+ if ( st->castleRights != CASTLES_NONE
+ && (castleRightsMask[from] & castleRightsMask[to]) != ALL_CASTLES)
{
key ^= zobCastle[st->castleRights];
- st->castleRights &= castleRightsMask[from];
- st->castleRights &= castleRightsMask[to];
+ st->castleRights &= castleRightsMask[from] & castleRightsMask[to];
key ^= zobCastle[st->castleRights];
}
if (pm) // promotion ?
{
- PieceType promotion = move_promotion_piece(m);
+ PieceType promotion = promotion_piece_type(m);
assert(promotion >= KNIGHT && promotion <= QUEEN);
if (pm) // promotion ?
{
- PieceType promotion = move_promotion_piece(m);
+ PieceType promotion = promotion_piece_type(m);
pt = PAWN;
assert(promotion >= KNIGHT && promotion <= QUEEN);
sideToMove = opposite_color(pos.side_to_move());
// Castling rights
- if (pos.can_castle_kingside(WHITE)) do_allow_oo(BLACK);
- if (pos.can_castle_queenside(WHITE)) do_allow_ooo(BLACK);
- if (pos.can_castle_kingside(BLACK)) do_allow_oo(WHITE);
- if (pos.can_castle_queenside(BLACK)) do_allow_ooo(WHITE);
+ if (pos.can_castle_kingside(WHITE)) set_castle_kingside(BLACK);
+ if (pos.can_castle_queenside(WHITE)) set_castle_queenside(BLACK);
+ if (pos.can_castle_kingside(BLACK)) set_castle_kingside(WHITE);
+ if (pos.can_castle_queenside(BLACK)) set_castle_queenside(WHITE);
initialKFile = pos.initialKFile;
initialKRFile = pos.initialKRFile;
if (failedStep) *failedStep = 1;
// Side to move OK?
- if (!color_is_ok(side_to_move()))
+ if (side_to_move() != WHITE && side_to_move() != BLACK)
return false;
// Are the king squares in the position correct?
// Castle files OK?
if (failedStep) (*failedStep)++;
- if (!file_is_ok(initialKRFile))
+ if (!square_is_ok(make_square(initialKRFile, RANK_1)))
return false;
- if (!file_is_ok(initialQRFile))
+ if (!square_is_ok(make_square(initialQRFile, RANK_1)))
return false;
// Do both sides have exactly one king?