X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fposition.cpp;h=01f51ed0c358b0de39264c54373b107183885b71;hp=69a756d9ce9b0b68ab0eecce7758a4ced1e05401;hb=2c237da54647bb7526f3512bea183eb44919cdda;hpb=e06a117d5e78ec4edc051f2b161d36559f784d37 diff --git a/src/position.cpp b/src/position.cpp index 69a756d9..01f51ed0 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -52,6 +52,9 @@ namespace { const string PieceToChar(" PNBRQK pnbrqk"); +const Piece Pieces[] = { W_PAWN, W_KNIGHT, W_BISHOP, W_ROOK, W_QUEEN, W_KING, + B_PAWN, B_KNIGHT, B_BISHOP, B_ROOK, B_QUEEN, B_KING }; + // min_attacker() is a helper function used by see_ge() to locate the least // valuable attacker for the side to move, remove the attacker we just found // from the bitboards and scan for new X-ray attacks behind it. @@ -62,7 +65,7 @@ PieceType min_attacker(const Bitboard* bb, Square to, Bitboard stmAttackers, Bitboard b = stmAttackers & bb[Pt]; if (!b) - return min_attacker(bb, to, stmAttackers, occupied, attackers); + return min_attacker(bb, to, stmAttackers, occupied, attackers); occupied ^= b & ~(b - 1); @@ -474,7 +477,7 @@ Bitboard Position::slider_blockers(Bitboard sliders, Square s, Bitboard& pinners pinners = 0; // Snipers are sliders that attack 's' when a piece is removed - Bitboard snipers = ( (PseudoAttacks[ROOK ][s] & pieces(QUEEN, ROOK)) + Bitboard snipers = ( (PseudoAttacks[ ROOK][s] & pieces(QUEEN, ROOK)) | (PseudoAttacks[BISHOP][s] & pieces(QUEEN, BISHOP))) & sliders; while (snipers) @@ -501,7 +504,7 @@ Bitboard Position::attackers_to(Square s, Bitboard occupied) const { return (attacks_from(s, BLACK) & pieces(WHITE, PAWN)) | (attacks_from(s, WHITE) & pieces(BLACK, PAWN)) | (attacks_from(s) & pieces(KNIGHT)) - | (attacks_bb(s, occupied) & pieces(ROOK, QUEEN)) + | (attacks_bb< ROOK>(s, occupied) & pieces( ROOK, QUEEN)) | (attacks_bb(s, occupied) & pieces(BISHOP, QUEEN)) | (attacks_from(s) & pieces(KING)); } @@ -1097,10 +1100,10 @@ bool Position::is_draw(int ply) const { stp = stp->previous->previous; // At root position ply is 1, so return a draw score if a position - // repeats once earlier but after or at the root, or repeats twice - // strictly before the root. + // repeats once earlier but strictly after the root, or repeats twice + // before or at the root. if ( stp->key == st->key - && ++cnt + (ply - i > 0) == 2) + && ++cnt + (ply - 1 > i) == 2) return true; }