From: Fabian Fichter Date: Mon, 7 Oct 2019 19:36:47 +0000 (+0200) Subject: Fix pseudo-legal move validation (close #35) X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=392f57f9ea58d3f9422af7c98468b728eea57438;p=fairystockfish.git Fix pseudo-legal move validation (close #35) sittuyin STC LLR: 2.95 (-2.94,2.94) [0.00,10.00] Total: 126 W: 60 L: 2 D: 64 http://35.161.250.236:6543/tests/view/5d9b94916e23db3768ec08f3 sittuyin LTC LLR: 2.96 (-2.94,2.94) [0.00,10.00] Total: 111 W: 58 L: 1 D: 52 http://35.161.250.236:6543/tests/view/5d9b9f566e23db3768ec08fd bench: 3686859 --- diff --git a/src/movepick.cpp b/src/movepick.cpp index 8d55ec4..862aed9 100644 --- a/src/movepick.cpp +++ b/src/movepick.cpp @@ -164,6 +164,7 @@ top: case QSEARCH_TT: case PROBCUT_TT: ++stage; + assert(pos.legal(ttMove) == MoveList(pos).contains(ttMove)); return ttMove; case CAPTURE_INIT: diff --git a/src/position.cpp b/src/position.cpp index 94ca68e..7a186e9 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -926,7 +926,7 @@ bool Position::pseudo_legal(const Move m) const { { // We have already handled promotion moves, so destination // cannot be on the 8th/1st rank. - if (mandatory_pawn_promotion() && (promotion_zone_bb(us, promotion_rank(), max_rank()) & to)) + if (mandatory_pawn_promotion() && rank_of(to) == relative_rank(us, promotion_rank(), max_rank())) return false; if ( !(attacks_from(us, from) & pieces(~us) & to) // Not a capture @@ -956,7 +956,7 @@ bool Position::pseudo_legal(const Move m) const { // Our move must be a blocking evasion or a capture of the checking piece Square checksq = lsb(checkers()); if ( !((between_bb(checksq, square(us)) | checkers()) & to) - || (LeaperAttacks[~us][type_of(piece_on(checksq))][checksq] & square(us))) + || ((LeaperAttacks[~us][type_of(piece_on(checksq))][checksq] & square(us)) && !(checkers() & to))) return false; } // In case of king moves under check we have to remove king so as to catch diff --git a/src/search.cpp b/src/search.cpp index 33333d0..46ca3fb 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -169,6 +169,7 @@ namespace { for (const auto& m : MoveList(pos)) { + assert(pos.pseudo_legal(m)); if (Root && depth <= ONE_PLY) cnt = 1, nodes++; else