Allow passing in bikjang despite check
authorFabian Fichter <ianfab@users.noreply.github.com>
Wed, 1 Apr 2020 21:00:30 +0000 (23:00 +0200)
committerFabian Fichter <ianfab@users.noreply.github.com>
Wed, 1 Apr 2020 21:00:30 +0000 (23:00 +0200)
Closes #94.

src/movegen.cpp
src/position.cpp

index 61fb28b..11fe7c7 100644 (file)
@@ -494,6 +494,10 @@ ExtMove* generate<EVASIONS>(const Position& pos, ExtMove* moveList) {
   Bitboard sliderAttacks = 0;
   Bitboard sliders = pos.checkers();
 
+  // Passing move by king
+  if (pos.king_pass())
+      *moveList++ = make<SPECIAL>(ksq, ksq);
+
   // Consider all evasion moves for special pieces
   if (sliders & (pos.pieces(CANNON, BANNER) | pos.pieces(HORSE, ELEPHANT) | pos.pieces(JANGGI_CANNON, JANGGI_ELEPHANT)))
   {
index 56b0063..873b18f 100644 (file)
@@ -925,8 +925,10 @@ bool Position::legal(Move m) const {
   Bitboard occupied = (type_of(m) != DROP ? pieces() ^ from : pieces()) | to;
 
   // Flying general rule and bikjang
-  // In case of bikjang passing is allowed
-  if ((var->flyingGeneral && count<KING>(us)) || (st->bikjang && !(type_of(moved_piece(m)) == KING && from == to)))
+  // In case of bikjang passing is always allowed, even when in check
+  if (st->bikjang && type_of(m) == SPECIAL && from == to)
+      return true;
+  if ((var->flyingGeneral && count<KING>(us)) || st->bikjang)
   {
       Square s = type_of(moved_piece(m)) == KING ? to : square<KING>(us);
       if (attacks_bb(~us, ROOK, s, occupied) & pieces(~us, KING) & ~square_bb(to))