From 02427ff3b8c1a70746fb6c7a6e9c49b8406f006a Mon Sep 17 00:00:00 2001 From: Fabian Fichter Date: Wed, 1 Apr 2020 23:00:30 +0200 Subject: [PATCH] Allow passing in bikjang despite check Closes #94. --- src/movegen.cpp | 4 ++++ src/position.cpp | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/movegen.cpp b/src/movegen.cpp index 61fb28b..11fe7c7 100644 --- a/src/movegen.cpp +++ b/src/movegen.cpp @@ -494,6 +494,10 @@ ExtMove* generate(const Position& pos, ExtMove* moveList) { Bitboard sliderAttacks = 0; Bitboard sliders = pos.checkers(); + // Passing move by king + if (pos.king_pass()) + *moveList++ = make(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))) { diff --git a/src/position.cpp b/src/position.cpp index 56b0063..873b18f 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -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(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(us)) || st->bikjang) { Square s = type_of(moved_piece(m)) == KING ? to : square(us); if (attacks_bb(~us, ROOK, s, occupied) & pieces(~us, KING) & ~square_bb(to)) -- 1.7.0.4