mirror of
https://github.com/sockspls/badfish
synced 2025-05-02 01:29:36 +00:00
Introduce make_castle_right() helper
No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
e56342ed00
commit
d549497144
4 changed files with 12 additions and 12 deletions
|
@ -35,16 +35,14 @@ namespace {
|
||||||
template<CastlingSide Side, bool OnlyChecks>
|
template<CastlingSide Side, bool OnlyChecks>
|
||||||
MoveStack* generate_castle(const Position& pos, MoveStack* mlist, Color us) {
|
MoveStack* generate_castle(const Position& pos, MoveStack* mlist, Color us) {
|
||||||
|
|
||||||
CastleRight cr = CastleRight((Side == KING_SIDE ? WHITE_OO : WHITE_OOO) << us);
|
if (pos.castle_impeded(us, Side) || !pos.can_castle(make_castle_right(us, Side)))
|
||||||
|
|
||||||
if (pos.castle_impeded(us, Side) || !pos.can_castle(cr))
|
|
||||||
return mlist;
|
return mlist;
|
||||||
|
|
||||||
// After castling, the rook and king final positions are the same in Chess960
|
// After castling, the rook and king final positions are the same in Chess960
|
||||||
// as they would be in standard chess.
|
// as they would be in standard chess.
|
||||||
Square kfrom = pos.king_square(us);
|
Square kfrom = pos.king_square(us);
|
||||||
Square kto = relative_square(us, Side == KING_SIDE ? SQ_G1 : SQ_C1);
|
|
||||||
Square rfrom = pos.castle_rook_square(us, Side);
|
Square rfrom = pos.castle_rook_square(us, Side);
|
||||||
|
Square kto = relative_square(us, Side == KING_SIDE ? SQ_G1 : SQ_C1);
|
||||||
Bitboard enemies = pos.pieces(~us);
|
Bitboard enemies = pos.pieces(~us);
|
||||||
|
|
||||||
assert(!pos.in_check());
|
assert(!pos.in_check());
|
||||||
|
|
|
@ -267,10 +267,10 @@ Score PawnEntry::update_safety(const Position& pos, Square ksq) {
|
||||||
Value bonus = shelter_storm<Us>(pos, ksq);
|
Value bonus = shelter_storm<Us>(pos, ksq);
|
||||||
|
|
||||||
// If we can castle use the bonus after the castle if is bigger
|
// If we can castle use the bonus after the castle if is bigger
|
||||||
if (pos.can_castle(Us == WHITE ? WHITE_OO : BLACK_OO))
|
if (pos.can_castle(make_castle_right(Us, KING_SIDE)))
|
||||||
bonus = std::max(bonus, shelter_storm<Us>(pos, relative_square(Us, SQ_G1)));
|
bonus = std::max(bonus, shelter_storm<Us>(pos, relative_square(Us, SQ_G1)));
|
||||||
|
|
||||||
if (pos.can_castle(Us == WHITE ? WHITE_OOO : BLACK_OOO))
|
if (pos.can_castle(make_castle_right(Us, QUEEN_SIDE)))
|
||||||
bonus = std::max(bonus, shelter_storm<Us>(pos, relative_square(Us, SQ_C1)));
|
bonus = std::max(bonus, shelter_storm<Us>(pos, relative_square(Us, SQ_C1)));
|
||||||
|
|
||||||
return kingSafety[Us] = make_score(bonus, 0);
|
return kingSafety[Us] = make_score(bonus, 0);
|
||||||
|
|
|
@ -240,7 +240,7 @@ void Position::set_castle_right(Color c, Square rfrom) {
|
||||||
|
|
||||||
Square kfrom = king_square(c);
|
Square kfrom = king_square(c);
|
||||||
CastlingSide cs = kfrom < rfrom ? KING_SIDE : QUEEN_SIDE;
|
CastlingSide cs = kfrom < rfrom ? KING_SIDE : QUEEN_SIDE;
|
||||||
int cr = (cs == KING_SIDE ? WHITE_OO : WHITE_OOO) << c;
|
CastleRight cr = make_castle_right(c, cs);
|
||||||
|
|
||||||
st->castleRights |= cr;
|
st->castleRights |= cr;
|
||||||
castleRightsMask[kfrom] |= cr;
|
castleRightsMask[kfrom] |= cr;
|
||||||
|
@ -1727,15 +1727,13 @@ bool Position::pos_is_ok(int* failedStep) const {
|
||||||
if (failedStep) (*failedStep)++;
|
if (failedStep) (*failedStep)++;
|
||||||
if (debugCastleSquares)
|
if (debugCastleSquares)
|
||||||
for (Color c = WHITE; c <= BLACK; c++)
|
for (Color c = WHITE; c <= BLACK; c++)
|
||||||
for (CastlingSide s = KING_SIDE; s <= QUEEN_SIDE; s = CastlingSide(s+1))
|
for (CastlingSide s = KING_SIDE; s <= QUEEN_SIDE; s = CastlingSide(s + 1))
|
||||||
{
|
{
|
||||||
CastleRight cr = CastleRight((s == KING_SIDE ? WHITE_OO : WHITE_OOO) << c);
|
if (!can_castle(make_castle_right(c, s)))
|
||||||
|
|
||||||
if (!can_castle(cr))
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ( piece_on(castleRookSquare[c][s]) != make_piece(c, ROOK)
|
if ( piece_on(castleRookSquare[c][s]) != make_piece(c, ROOK)
|
||||||
|| castleRightsMask[castleRookSquare[c][s]] != cr)
|
|| castleRightsMask[castleRookSquare[c][s]] != make_castle_right(c, s))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -347,6 +347,10 @@ inline Piece make_piece(Color c, PieceType pt) {
|
||||||
return Piece((c << 3) | pt);
|
return Piece((c << 3) | pt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline CastleRight make_castle_right(Color c, CastlingSide s) {
|
||||||
|
return CastleRight((s == KING_SIDE ? WHITE_OO : WHITE_OOO) << c);
|
||||||
|
}
|
||||||
|
|
||||||
inline PieceType type_of(Piece p) {
|
inline PieceType type_of(Piece p) {
|
||||||
return PieceType(p & 7);
|
return PieceType(p & 7);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue