X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fposition.cpp;h=5dc6050f081fbfc412111dc1334df1bf259cfeb3;hb=55eb0445ddbb6ec4a6868eacb986e022865e19a6;hp=ba015d3c38edb3cf87be062f952f4fbcec568cc4;hpb=900f249f596417b35129f1dc357cd5392018e575;p=stockfish diff --git a/src/position.cpp b/src/position.cpp index ba015d3c..5dc6050f 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -1,6 +1,6 @@ /* Stockfish, a UCI chess playing engine derived from Glaurung 2.1 - Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file) + Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file) Stockfish is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -283,8 +283,6 @@ Position& Position::set(const string& fenStr, bool isChess960, StateInfo* si, Th thisThread = th; set_state(st); - assert(pos_is_ok()); - return *this; } @@ -1013,9 +1011,9 @@ void Position::do_null_move(StateInfo& newSt) { } st->key ^= Zobrist::side; + ++st->rule50; prefetch(TT.first_entry(key())); - ++st->rule50; st->pliesFromNull = 0; sideToMove = ~sideToMove; @@ -1054,7 +1052,10 @@ Key Position::key_after(Move m) const { if (captured) k ^= Zobrist::psq[captured][to]; - return k ^ Zobrist::psq[pc][to] ^ Zobrist::psq[pc][from]; + k ^= Zobrist::psq[pc][to] ^ Zobrist::psq[pc][from]; + + return (captured || type_of(pc) == PAWN) + ? k : adjust_key50(k); } @@ -1080,8 +1081,9 @@ bool Position::see_ge(Move m, Value threshold) const { if (swap <= 0) return true; + assert(color_of(piece_on(from)) == sideToMove); Bitboard occupied = pieces() ^ from ^ to; - Color stm = color_of(piece_on(from)); + Color stm = sideToMove; Bitboard attackers = attackers_to(to, occupied); Bitboard stmAttackers, bb; int res = 1; @@ -1098,10 +1100,12 @@ bool Position::see_ge(Move m, Value threshold) const { // Don't allow pinned pieces to attack as long as there are // pinners on their original square. if (pinners(~stm) & occupied) + { stmAttackers &= ~blockers_for_king(stm); - if (!stmAttackers) - break; + if (!stmAttackers) + break; + } res ^= 1;