Prohibit non-passing moves not breaking bikjang
authorFabian Fichter <ianfab@users.noreply.github.com>
Tue, 31 Mar 2020 18:31:57 +0000 (20:31 +0200)
committerFabian Fichter <ianfab@users.noreply.github.com>
Tue, 31 Mar 2020 18:31:57 +0000 (20:31 +0200)
Closes #92.

src/position.cpp
tests/perft.sh

index bbf361a..629f37e 100644 (file)
@@ -924,8 +924,9 @@ bool Position::legal(Move m) const {
 
   Bitboard occupied = (type_of(m) != DROP ? pieces() ^ from : pieces()) | to;
 
-  // Flying general rule
-  if (var->flyingGeneral && count<KING>(us))
+  // 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)))
   {
       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))
index 706c823..aba4711 100755 (executable)
@@ -74,7 +74,7 @@ if [[ $1 == "largeboard" ]]; then
   expect perft.exp courier startpos 4 500337 > /dev/null
   expect perft.exp grand startpos 3 259514 > /dev/null
   expect perft.exp xiangqi startpos 4 3290240 > /dev/null
-  expect perft.exp janggi startpos 4 1075083 > /dev/null
+  expect perft.exp janggi startpos 4 1067293 > /dev/null
   expect perft.exp janggi "fen 1n1kaabn1/cr2N4/5C1c1/p1pNp3p/9/9/P1PbP1P1P/3r1p3/4A4/R1BA1KB1R b - - 0 1" 4 76826 > /dev/null
 fi