Fix pseudo-legal move validation for Janggi
authorFabian Fichter <ianfab@users.noreply.github.com>
Wed, 12 Aug 2020 20:31:20 +0000 (22:31 +0200)
committerFabian Fichter <ianfab@users.noreply.github.com>
Wed, 12 Aug 2020 20:31:20 +0000 (22:31 +0200)
Closes #170.

src/position.cpp

index 5b7be11..8b3360f 100644 (file)
@@ -1052,7 +1052,7 @@ bool Position::pseudo_legal(const Move m) const {
   // Evasions generator already takes care to avoid some kind of illegal moves
   // and legal() relies on this. We therefore have to take care that the same
   // kind of moves are filtered out here.
-  if (checkers() & ~(pieces(CANNON, BANNER) | pieces(HORSE, ELEPHANT) | pieces(JANGGI_CANNON, JANGGI_ELEPHANT)))
+  if (checkers() && !(checkers() & (pieces(CANNON, BANNER) | pieces(HORSE, ELEPHANT) | pieces(JANGGI_CANNON, JANGGI_ELEPHANT))))
   {
       if (type_of(pc) != KING)
       {