Rename castling flag to castling right

This is a more conventional naming as
reported also in:

http://chessprogramming.wikispaces.com/Castling+rights

No functional change.
This commit is contained in:
Marco Costalba
2014-03-08 15:08:55 +01:00
parent 13b9e1e098
commit 1d1b7df7c6
6 changed files with 55 additions and 55 deletions
+20 -20
View File
@@ -47,7 +47,7 @@ namespace Zobrist {
Key psq[COLOR_NB][PIECE_TYPE_NB][SQUARE_NB];
Key enpassant[FILE_NB];
Key castling[CASTLING_FLAG_NB];
Key castling[CASTLING_RIGHT_NB];
Key side;
Key exclusion;
}
@@ -263,7 +263,7 @@ void Position::set(const string& fenStr, bool isChess960, Thread* th) {
else
continue;
set_castling_flag(c, rsq);
set_castling_right(c, rsq);
}
// 4. En passant square. Ignore if no pawn capture is possible
@@ -297,30 +297,30 @@ void Position::set(const string& fenStr, bool isChess960, Thread* th) {
}
/// Position::set_castling_flag() is a helper function used to set castling
/// flags given the corresponding color and the rook starting square.
/// Position::set_castling_right() is a helper function used to set castling
/// rights given the corresponding color and the rook starting square.
void Position::set_castling_flag(Color c, Square rfrom) {
void Position::set_castling_right(Color c, Square rfrom) {
Square kfrom = king_square(c);
CastlingSide cs = kfrom < rfrom ? KING_SIDE : QUEEN_SIDE;
CastlingFlag cf = (c | cs);
CastlingRight cr = (c | cs);
st->castlingFlags |= cf;
castlingFlagsMask[kfrom] |= cf;
castlingFlagsMask[rfrom] |= cf;
castlingRookSquare[cf] = rfrom;
st->castlingRights |= cr;
castlingRightsMask[kfrom] |= cr;
castlingRightsMask[rfrom] |= cr;
castlingRookSquare[cr] = rfrom;
Square kto = relative_square(c, cs == KING_SIDE ? SQ_G1 : SQ_C1);
Square rto = relative_square(c, cs == KING_SIDE ? SQ_F1 : SQ_D1);
for (Square s = std::min(rfrom, rto); s <= std::max(rfrom, rto); ++s)
if (s != kfrom && s != rfrom)
castlingPath[cf] |= s;
castlingPath[cr] |= s;
for (Square s = std::min(kfrom, kto); s <= std::max(kfrom, kto); ++s)
if (s != kfrom && s != rfrom)
castlingPath[cf] |= s;
castlingPath[cr] |= s;
}
@@ -791,12 +791,12 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
st->epSquare = SQ_NONE;
}
// Update castling flags if needed
if (st->castlingFlags && (castlingFlagsMask[from] | castlingFlagsMask[to]))
// Update castling rights if needed
if (st->castlingRights && (castlingRightsMask[from] | castlingRightsMask[to]))
{
int cf = castlingFlagsMask[from] | castlingFlagsMask[to];
k ^= Zobrist::castling[st->castlingFlags & cf];
st->castlingFlags &= ~cf;
int cr = castlingRightsMask[from] | castlingRightsMask[to];
k ^= Zobrist::castling[st->castlingRights & cr];
st->castlingRights &= ~cr;
}
// Prefetch TT access as soon as we know the new hash key
@@ -1128,7 +1128,7 @@ void Position::clear() {
Key Position::compute_key() const {
Key k = Zobrist::castling[st->castlingFlags];
Key k = Zobrist::castling[st->castlingRights];
for (Bitboard b = pieces(); b; )
{
@@ -1396,9 +1396,9 @@ bool Position::pos_is_ok(int* failedStep) const {
if (!can_castle(c | s))
continue;
if ( (castlingFlagsMask[king_square(c)] & (c | s)) != (c | s)
if ( (castlingRightsMask[king_square(c)] & (c | s)) != (c | s)
|| piece_on(castlingRookSquare[c | s]) != make_piece(c, ROOK)
|| castlingFlagsMask[castlingRookSquare[c | s]] != (c | s))
|| castlingRightsMask[castlingRookSquare[c | s]] != (c | s))
return false;
}