Fix pawn double-step move validation
authorFabian Fichter <ianfab@users.noreply.github.com>
Tue, 20 Aug 2019 21:25:59 +0000 (23:25 +0200)
committerFabian Fichter <ianfab@users.noreply.github.com>
Tue, 20 Aug 2019 21:25:59 +0000 (23:25 +0200)
src/movegen.cpp
src/position.cpp

index 7542044..17ec978 100644 (file)
@@ -134,7 +134,7 @@ namespace {
             if (dcCandidateQuiets)
             {
                 Bitboard dc1 = shift<Up>(dcCandidateQuiets) & emptySquares & ~file_bb(ksq);
-                Bitboard dc2 = shift<Up>(dc1 & TRank3BB) & emptySquares;
+                Bitboard dc2 = pos.double_step_enabled() ? shift<Up>(dc1 & TRank3BB) & emptySquares : Bitboard(0);
 
                 b1 |= dc1;
                 b2 |= dc2;
index 5a3e197..b2aee5a 100644 (file)
@@ -920,8 +920,8 @@ bool Position::pseudo_legal(const Move m) const {
       if (   !(attacks_from<PAWN>(us, from) & pieces(~us) & to) // Not a capture
           && !((from + pawn_push(us) == to) && empty(to))       // Not a single push
           && !(   (from + 2 * pawn_push(us) == to)              // Not a double push
-               && (rank_of(from) == relative_rank(us, double_step_rank())
-                   || (first_rank_double_steps() && rank_of(from) == relative_rank(us, RANK_1)))
+               && (rank_of(from) == relative_rank(us, double_step_rank(), max_rank())
+                   || (first_rank_double_steps() && rank_of(from) == relative_rank(us, RANK_1, max_rank())))
                && empty(to)
                && empty(to - pawn_push(us))
                && double_step_enabled()))