Assorted trivial cleanups January 2020
Assorted trivial cleanups. No functional changepull/2482/head
parent
bae019b53e
commit
384bff4264
|
@ -155,7 +155,7 @@ Value Endgame<KBNK>::operator()(const Position& pos) const {
|
|||
Square loserKSq = pos.square<KING>(weakSide);
|
||||
Square bishopSq = pos.square<BISHOP>(strongSide);
|
||||
|
||||
// If our Bishop does not attack A1/H8, we flip the enemy king square
|
||||
// If our bishop does not attack A1/H8, we flip the enemy king square
|
||||
// to drive to opposite corners (A8/H1).
|
||||
|
||||
Value result = VALUE_KNOWN_WIN
|
||||
|
@ -167,7 +167,7 @@ Value Endgame<KBNK>::operator()(const Position& pos) const {
|
|||
}
|
||||
|
||||
|
||||
/// KP vs K. This endgame is evaluated with the help of a bitbase.
|
||||
/// KP vs K. This endgame is evaluated with the help of a bitbase
|
||||
template<>
|
||||
Value Endgame<KPK>::operator()(const Position& pos) const {
|
||||
|
||||
|
|
|
@ -317,20 +317,19 @@ namespace {
|
|||
// Bonus for bishop on a long diagonal which can "see" both center squares
|
||||
if (more_than_one(attacks_bb<BISHOP>(s, pos.pieces(PAWN)) & Center))
|
||||
score += LongDiagonalBishop;
|
||||
}
|
||||
|
||||
// An important Chess960 pattern: A cornered bishop blocked by a friendly
|
||||
// pawn diagonally in front of it is a very serious problem, especially
|
||||
// when that pawn is also blocked.
|
||||
if ( Pt == BISHOP
|
||||
&& pos.is_chess960()
|
||||
&& (s == relative_square(Us, SQ_A1) || s == relative_square(Us, SQ_H1)))
|
||||
{
|
||||
Direction d = pawn_push(Us) + (file_of(s) == FILE_A ? EAST : WEST);
|
||||
if (pos.piece_on(s + d) == make_piece(Us, PAWN))
|
||||
score -= !pos.empty(s + d + pawn_push(Us)) ? CorneredBishop * 4
|
||||
: pos.piece_on(s + d + d) == make_piece(Us, PAWN) ? CorneredBishop * 2
|
||||
: CorneredBishop;
|
||||
// An important Chess960 pattern: a cornered bishop blocked by a friendly
|
||||
// pawn diagonally in front of it is a very serious problem, especially
|
||||
// when that pawn is also blocked.
|
||||
if ( pos.is_chess960()
|
||||
&& (s == relative_square(Us, SQ_A1) || s == relative_square(Us, SQ_H1)))
|
||||
{
|
||||
Direction d = pawn_push(Us) + (file_of(s) == FILE_A ? EAST : WEST);
|
||||
if (pos.piece_on(s + d) == make_piece(Us, PAWN))
|
||||
score -= !pos.empty(s + d + pawn_push(Us)) ? CorneredBishop * 4
|
||||
: pos.piece_on(s + d + d) == make_piece(Us, PAWN) ? CorneredBishop * 2
|
||||
: CorneredBishop;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -817,7 +817,7 @@ void Position::do_move(Move m, StateInfo& newSt, bool givesCheck) {
|
|||
st->nonPawnMaterial[us] += PieceValue[MG][promotion];
|
||||
}
|
||||
|
||||
// Update pawn hash key and prefetch access to pawnsTable
|
||||
// Update pawn hash key
|
||||
st->pawnKey ^= Zobrist::psq[pc][from] ^ Zobrist::psq[pc][to];
|
||||
|
||||
// Reset rule 50 draw counter
|
||||
|
@ -944,7 +944,7 @@ void Position::do_castling(Color us, Square from, Square& to, Square& rfrom, Squ
|
|||
}
|
||||
|
||||
|
||||
/// Position::do(undo)_null_move() is used to do(undo) a "null move": It flips
|
||||
/// Position::do(undo)_null_move() is used to do(undo) a "null move": it flips
|
||||
/// the side to move without executing any move on the board.
|
||||
|
||||
void Position::do_null_move(StateInfo& newSt) {
|
||||
|
@ -1027,16 +1027,16 @@ bool Position::see_ge(Move m, Value threshold) const {
|
|||
if (swap <= 0)
|
||||
return true;
|
||||
|
||||
Bitboard occ = pieces() ^ from ^ to;
|
||||
Bitboard occupied = pieces() ^ from ^ to;
|
||||
Color stm = color_of(piece_on(from));
|
||||
Bitboard attackers = attackers_to(to, occ);
|
||||
Bitboard attackers = attackers_to(to, occupied);
|
||||
Bitboard stmAttackers, bb;
|
||||
int res = 1;
|
||||
|
||||
while (true)
|
||||
{
|
||||
stm = ~stm;
|
||||
attackers &= occ;
|
||||
attackers &= occupied;
|
||||
|
||||
// If stm has no more attackers then give up: stm loses
|
||||
if (!(stmAttackers = attackers & pieces(stm)))
|
||||
|
@ -1044,7 +1044,7 @@ bool Position::see_ge(Move m, Value threshold) const {
|
|||
|
||||
// Don't allow pinned pieces to attack (except the king) as long as
|
||||
// there are pinners on their original square.
|
||||
if (st->pinners[~stm] & occ)
|
||||
if (st->pinners[~stm] & occupied)
|
||||
stmAttackers &= ~st->blockersForKing[stm];
|
||||
|
||||
if (!stmAttackers)
|
||||
|
@ -1059,8 +1059,8 @@ bool Position::see_ge(Move m, Value threshold) const {
|
|||
if ((swap = PawnValueMg - swap) < res)
|
||||
break;
|
||||
|
||||
occ ^= lsb(bb);
|
||||
attackers |= attacks_bb<BISHOP>(to, occ) & pieces(BISHOP, QUEEN);
|
||||
occupied ^= lsb(bb);
|
||||
attackers |= attacks_bb<BISHOP>(to, occupied) & pieces(BISHOP, QUEEN);
|
||||
}
|
||||
|
||||
else if ((bb = stmAttackers & pieces(KNIGHT)))
|
||||
|
@ -1068,7 +1068,7 @@ bool Position::see_ge(Move m, Value threshold) const {
|
|||
if ((swap = KnightValueMg - swap) < res)
|
||||
break;
|
||||
|
||||
occ ^= lsb(bb);
|
||||
occupied ^= lsb(bb);
|
||||
}
|
||||
|
||||
else if ((bb = stmAttackers & pieces(BISHOP)))
|
||||
|
@ -1076,8 +1076,8 @@ bool Position::see_ge(Move m, Value threshold) const {
|
|||
if ((swap = BishopValueMg - swap) < res)
|
||||
break;
|
||||
|
||||
occ ^= lsb(bb);
|
||||
attackers |= attacks_bb<BISHOP>(to, occ) & pieces(BISHOP, QUEEN);
|
||||
occupied ^= lsb(bb);
|
||||
attackers |= attacks_bb<BISHOP>(to, occupied) & pieces(BISHOP, QUEEN);
|
||||
}
|
||||
|
||||
else if ((bb = stmAttackers & pieces(ROOK)))
|
||||
|
@ -1085,8 +1085,8 @@ bool Position::see_ge(Move m, Value threshold) const {
|
|||
if ((swap = RookValueMg - swap) < res)
|
||||
break;
|
||||
|
||||
occ ^= lsb(bb);
|
||||
attackers |= attacks_bb<ROOK>(to, occ) & pieces(ROOK, QUEEN);
|
||||
occupied ^= lsb(bb);
|
||||
attackers |= attacks_bb<ROOK>(to, occupied) & pieces(ROOK, QUEEN);
|
||||
}
|
||||
|
||||
else if ((bb = stmAttackers & pieces(QUEEN)))
|
||||
|
@ -1094,9 +1094,9 @@ bool Position::see_ge(Move m, Value threshold) const {
|
|||
if ((swap = QueenValueMg - swap) < res)
|
||||
break;
|
||||
|
||||
occ ^= lsb(bb);
|
||||
attackers |= (attacks_bb<BISHOP>(to, occ) & pieces(BISHOP, QUEEN))
|
||||
| (attacks_bb<ROOK >(to, occ) & pieces(ROOK , QUEEN));
|
||||
occupied ^= lsb(bb);
|
||||
attackers |= (attacks_bb<BISHOP>(to, occupied) & pieces(BISHOP, QUEEN))
|
||||
| (attacks_bb<ROOK >(to, occupied) & pieces(ROOK , QUEEN));
|
||||
}
|
||||
|
||||
else // KING
|
||||
|
@ -1105,7 +1105,7 @@ bool Position::see_ge(Move m, Value threshold) const {
|
|||
return (attackers & ~pieces(stm)) ? res ^ 1 : res;
|
||||
}
|
||||
|
||||
return res;
|
||||
return bool(res);
|
||||
}
|
||||
|
||||
/// Position::is_draw() tests whether the position is drawn by 50-move rule
|
||||
|
|
|
@ -46,7 +46,6 @@ struct StateInfo {
|
|||
Square epSquare;
|
||||
|
||||
// Not copied when making a move (will be recomputed anyhow)
|
||||
int repetition;
|
||||
Key key;
|
||||
Bitboard checkersBB;
|
||||
Piece capturedPiece;
|
||||
|
@ -54,6 +53,7 @@ struct StateInfo {
|
|||
Bitboard blockersForKing[COLOR_NB];
|
||||
Bitboard pinners[COLOR_NB];
|
||||
Bitboard checkSquares[PIECE_TYPE_NB];
|
||||
int repetition;
|
||||
};
|
||||
|
||||
/// A list to keep track of the position states along the setup moves (from the
|
||||
|
@ -277,10 +277,14 @@ inline int Position::castling_rights(Color c) const {
|
|||
}
|
||||
|
||||
inline bool Position::castling_impeded(CastlingRights cr) const {
|
||||
assert(cr == WHITE_OO || cr == WHITE_OOO || cr == BLACK_OO || cr == BLACK_OOO);
|
||||
|
||||
return byTypeBB[ALL_PIECES] & castlingPath[cr];
|
||||
}
|
||||
|
||||
inline Square Position::castling_rook_square(CastlingRights cr) const {
|
||||
assert(cr == WHITE_OO || cr == WHITE_OOO || cr == BLACK_OO || cr == BLACK_OOO);
|
||||
|
||||
return castlingRookSquare[cr];
|
||||
}
|
||||
|
||||
|
|
|
@ -683,7 +683,7 @@ Ret do_probe_table(const Position& pos, T* entry, WDLScore wdl, ProbeState* resu
|
|||
bool blackStronger = (pos.material_key() != entry->key);
|
||||
|
||||
int flipColor = (symmetricBlackToMove || blackStronger) * 8;
|
||||
int flipSquares = (symmetricBlackToMove || blackStronger) * 070;
|
||||
int flipSquares = (symmetricBlackToMove || blackStronger) * 56;
|
||||
int stm = (symmetricBlackToMove || blackStronger) ^ pos.side_to_move();
|
||||
|
||||
// For pawns, TB files store 4 separate tables according if leading pawn is on
|
||||
|
@ -762,7 +762,7 @@ Ret do_probe_table(const Position& pos, T* entry, WDLScore wdl, ProbeState* resu
|
|||
// piece is below RANK_5.
|
||||
if (rank_of(squares[0]) > RANK_4)
|
||||
for (int i = 0; i < size; ++i)
|
||||
squares[i] ^= 070; // Vertical flip: SQ_A8 -> SQ_A1
|
||||
squares[i] ^= SQ_A8; // Vertical flip: SQ_A8 -> SQ_A1
|
||||
|
||||
// Look for the first piece of the leading group not on the A1-D4 diagonal
|
||||
// and ensure it is mapped below the diagonal.
|
||||
|
|
Loading…
Reference in New Issue