return false;
// Illegal king passing move
- if (king_pass_on_stalemate() && type_of(m) == SPECIAL && from == to && !checkers())
+ if (king_pass_on_stalemate() && is_pass(m) && !checkers())
{
for (const auto& move : MoveList<NON_EVASIONS>(*this))
- if (!(type_of(move) == SPECIAL && from == to) && legal(move))
+ if (!is_pass(move) && legal(move))
return false;
}
// Flying general rule and bikjang
// In case of bikjang passing is always allowed, even when in check
- if (st->bikjang && type_of(m) == SPECIAL && from == to)
+ if (st->bikjang && is_pass(m))
return true;
if ((var->flyingGeneral && count<KING>(us)) || st->bikjang)
{
Piece captured = type_of(m) == ENPASSANT ? make_piece(them, PAWN) : piece_on(to);
if (to == from)
{
- assert((type_of(m) == PROMOTION && sittuyin_promotion()) || (type_of(m) == SPECIAL && king_pass()));
+ assert((type_of(m) == PROMOTION && sittuyin_promotion()) || (is_pass(m) && king_pass()));
captured = NO_PIECE;
}
st->capturedpromoted = is_promoted(to);
st->unpromotedCapturedPiece = captured ? unpromoted_piece_on(to) : NO_PIECE;
+ st->pass = is_pass(m);
assert(color_of(pc) == us);
assert(captured == NO_PIECE || color_of(captured) == (type_of(m) != CASTLING ? them : us));
assert(type_of(m) == DROP || empty(from) || type_of(m) == CASTLING || is_gating(m)
|| (type_of(m) == PROMOTION && sittuyin_promotion())
- || (type_of(m) == SPECIAL && king_pass()));
+ || (is_pass(m) && king_pass()));
assert(type_of(st->capturedPiece) != KING);
// Remove gated piece
}
}
// Check for bikjang rule (Janggi)
- if (var->bikjangRule && st->pliesFromNull > 0 && st->bikjang && st->previous->bikjang)
+ if (var->bikjangRule && st->pliesFromNull > 0 && ( (st->bikjang && st->previous->bikjang)
+ || (st->pass && st->previous->pass)))
{
// material counting
auto weigth_count = [this](PieceType pt, int v){ return v * (count(WHITE, pt) - count(BLACK, pt)); };
return gating_type(m) && (type_of(m) == NORMAL || type_of(m) == CASTLING);
}
+inline bool is_pass(Move m) {
+ return type_of(m) == SPECIAL || from_sq(m) == to_sq(m);
+}
+
constexpr Move make_move(Square from, Square to) {
return Move((from << SQUARE_BITS) + to);
}
expect perft.exp grand startpos 3 259514 > /dev/null
expect perft.exp xiangqi startpos 4 3290240 > /dev/null
expect perft.exp xiangqi "fen 1rbaka2R/5r3/6n2/2p1p1p2/4P1bP1/PpC3Bc1/1nPR2P2/2N2AN2/1c2K1p2/2BAC4 w - - 0 1" 4 4485547 > /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 76824 > /dev/null
- expect perft.exp janggi "fen 1Pbcka3/3nNn1c1/N2CaC3/1pB6/9/9/5P3/9/4K4/9 w - - 0 23" 4 151944 > /dev/null
+ expect perft.exp janggi startpos 4 1065277 > /dev/null
+ expect perft.exp janggi "fen 1n1kaabn1/cr2N4/5C1c1/p1pNp3p/9/9/P1PbP1P1P/3r1p3/4A4/R1BA1KB1R b - - 0 1" 4 76763 > /dev/null
+ expect perft.exp janggi "fen 1Pbcka3/3nNn1c1/N2CaC3/1pB6/9/9/5P3/9/4K4/9 w - - 0 23" 4 151202 > /dev/null
fi
rm perft.exp