Fix pseudo-legal move validation (resolves #12)
authorFabian Fichter <ianfab@users.noreply.github.com>
Fri, 9 Nov 2018 21:43:31 +0000 (22:43 +0100)
committerFabian Fichter <ianfab@users.noreply.github.com>
Fri, 9 Nov 2018 21:58:45 +0000 (22:58 +0100)
For pieces which move and capture in different ways,
the pseudo-legal move validation needs to take into account
whether a move is a capture or not.

This fixes the pseudo-legal move validation for breakthrough and hoppelpoppel.

breakthrough
ELO: 372.25 +-109.6 (95%) LOS: 100.0%
Total: 100 W: 86 L: 7 D: 7

hoppelpoppel
ELO: 530.72 +-154.4 (95%) LOS: 100.0%
Total: 100 W: 92 L: 1 D: 7

src/position.cpp

index e14ca16..ecf827c 100644 (file)
@@ -843,7 +843,7 @@ bool Position::pseudo_legal(const Move m) const {
                && double_step_enabled()))
           return false;
   }
-  else if (!(attacks_from(us, type_of(pc), from) & to))
+  else if (!((capture(m) ? attacks_from(us, type_of(pc), from) : moves_from(us, type_of(pc), from)) & to))
       return false;
 
   // Evasions generator already takes care to avoid some kind of illegal moves