mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-20 00:56:39 +08:00
Rename some variables for more clarity.
No functional change. Resolves #131
This commit is contained in:
@@ -147,13 +147,13 @@ void Position::init() {
|
||||
for (File f = FILE_A; f <= FILE_H; ++f)
|
||||
Zobrist::enpassant[f] = rk.rand<Key>();
|
||||
|
||||
for (int cf = NO_CASTLING; cf <= ANY_CASTLING; ++cf)
|
||||
for (int cr = NO_CASTLING; cr <= ANY_CASTLING; ++cr)
|
||||
{
|
||||
Bitboard b = cf;
|
||||
Bitboard b = cr;
|
||||
while (b)
|
||||
{
|
||||
Key k = Zobrist::castling[1ULL << pop_lsb(&b)];
|
||||
Zobrist::castling[cf] ^= k ? k : rk.rand<Key>();
|
||||
Zobrist::castling[cr] ^= k ? k : rk.rand<Key>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -363,7 +363,7 @@ void Position::set_castling_right(Color c, Square rfrom) {
|
||||
void Position::set_state(StateInfo* si) const {
|
||||
|
||||
si->key = si->pawnKey = si->materialKey = 0;
|
||||
si->npMaterial[WHITE] = si->npMaterial[BLACK] = VALUE_ZERO;
|
||||
si->nonPawnMaterial[WHITE] = si->nonPawnMaterial[BLACK] = VALUE_ZERO;
|
||||
si->psq = SCORE_ZERO;
|
||||
|
||||
si->checkersBB = attackers_to(king_square(sideToMove)) & pieces(~sideToMove);
|
||||
@@ -397,7 +397,7 @@ void Position::set_state(StateInfo* si) const {
|
||||
|
||||
for (Color c = WHITE; c <= BLACK; ++c)
|
||||
for (PieceType pt = KNIGHT; pt <= QUEEN; ++pt)
|
||||
si->npMaterial[c] += pieceCount[c][pt] * PieceValue[MG][pt];
|
||||
si->nonPawnMaterial[c] += pieceCount[c][pt] * PieceValue[MG][pt];
|
||||
}
|
||||
|
||||
|
||||
@@ -456,7 +456,7 @@ const string Position::fen() const {
|
||||
|
||||
Phase Position::game_phase() const {
|
||||
|
||||
Value npm = st->npMaterial[WHITE] + st->npMaterial[BLACK];
|
||||
Value npm = st->nonPawnMaterial[WHITE] + st->nonPawnMaterial[BLACK];
|
||||
|
||||
npm = std::max(EndgameLimit, std::min(npm, MidgameLimit));
|
||||
|
||||
@@ -492,16 +492,16 @@ Bitboard Position::check_blockers(Color c, Color kingColor) const {
|
||||
|
||||
|
||||
/// Position::attackers_to() computes a bitboard of all pieces which attack a
|
||||
/// given square. Slider attacks use the occ bitboard to indicate occupancy.
|
||||
/// given square. Slider attacks use the occupied bitboard to indicate occupancy.
|
||||
|
||||
Bitboard Position::attackers_to(Square s, Bitboard occ) const {
|
||||
Bitboard Position::attackers_to(Square s, Bitboard occupied) const {
|
||||
|
||||
return (attacks_from<PAWN>(s, BLACK) & pieces(WHITE, PAWN))
|
||||
| (attacks_from<PAWN>(s, WHITE) & pieces(BLACK, PAWN))
|
||||
| (attacks_from<KNIGHT>(s) & pieces(KNIGHT))
|
||||
| (attacks_bb<ROOK>(s, occ) & pieces(ROOK, QUEEN))
|
||||
| (attacks_bb<BISHOP>(s, occ) & pieces(BISHOP, QUEEN))
|
||||
| (attacks_from<KING>(s) & pieces(KING));
|
||||
return (attacks_from<PAWN>(s, BLACK) & pieces(WHITE, PAWN))
|
||||
| (attacks_from<PAWN>(s, WHITE) & pieces(BLACK, PAWN))
|
||||
| (attacks_from<KNIGHT>(s) & pieces(KNIGHT))
|
||||
| (attacks_bb<ROOK>(s, occupied) & pieces(ROOK, QUEEN))
|
||||
| (attacks_bb<BISHOP>(s, occupied) & pieces(BISHOP, QUEEN))
|
||||
| (attacks_from<KING>(s) & pieces(KING));
|
||||
}
|
||||
|
||||
|
||||
@@ -526,15 +526,15 @@ bool Position::legal(Move m, Bitboard pinned) const {
|
||||
Square ksq = king_square(us);
|
||||
Square to = to_sq(m);
|
||||
Square capsq = to - pawn_push(us);
|
||||
Bitboard occ = (pieces() ^ from ^ capsq) | to;
|
||||
Bitboard occupied = (pieces() ^ from ^ capsq) | to;
|
||||
|
||||
assert(to == ep_square());
|
||||
assert(moved_piece(m) == make_piece(us, PAWN));
|
||||
assert(piece_on(capsq) == make_piece(~us, PAWN));
|
||||
assert(piece_on(to) == NO_PIECE);
|
||||
|
||||
return !(attacks_bb< ROOK>(ksq, occ) & pieces(~us, QUEEN, ROOK))
|
||||
&& !(attacks_bb<BISHOP>(ksq, occ) & pieces(~us, QUEEN, BISHOP));
|
||||
return !(attacks_bb< ROOK>(ksq, occupied) & pieces(~us, QUEEN, ROOK))
|
||||
&& !(attacks_bb<BISHOP>(ksq, occupied) & pieces(~us, QUEEN, BISHOP));
|
||||
}
|
||||
|
||||
// If the moving piece is a king, check whether the destination
|
||||
@@ -767,7 +767,7 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
|
||||
st->pawnKey ^= Zobrist::psq[them][PAWN][capsq];
|
||||
}
|
||||
else
|
||||
st->npMaterial[them] -= PieceValue[MG][captured];
|
||||
st->nonPawnMaterial[them] -= PieceValue[MG][captured];
|
||||
|
||||
// Update board and piece lists
|
||||
remove_piece(capsq, them, captured);
|
||||
@@ -837,7 +837,7 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
|
||||
st->psq += psq[us][promotion][to] - psq[us][PAWN][to];
|
||||
|
||||
// Update material
|
||||
st->npMaterial[us] += PieceValue[MG][promotion];
|
||||
st->nonPawnMaterial[us] += PieceValue[MG][promotion];
|
||||
}
|
||||
|
||||
// Update pawn hash key and prefetch access to pawnsTable
|
||||
@@ -1234,8 +1234,8 @@ bool Position::pos_is_ok(int* step) const {
|
||||
if ( st->key != si.key
|
||||
|| st->pawnKey != si.pawnKey
|
||||
|| st->materialKey != si.materialKey
|
||||
|| st->npMaterial[WHITE] != si.npMaterial[WHITE]
|
||||
|| st->npMaterial[BLACK] != si.npMaterial[BLACK]
|
||||
|| st->nonPawnMaterial[WHITE] != si.nonPawnMaterial[WHITE]
|
||||
|| st->nonPawnMaterial[BLACK] != si.nonPawnMaterial[BLACK]
|
||||
|| st->psq != si.psq
|
||||
|| st->checkersBB != si.checkersBB)
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user