Skip to content

Commit eefef52

Browse files
committed
Validate drops of pseudo-royals
Closes #867.
1 parent 87fdab8 commit eefef52

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

src/position.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,6 +1146,9 @@ bool Position::legal(Move m) const {
11461146
if (capture(m) && (var->petrifyOnCaptureTypes & type_of(moved_piece(m))) && (st->pseudoRoyals & from))
11471147
return false;
11481148
Bitboard pseudoRoyals = st->pseudoRoyals & pieces(sideToMove);
1149+
// Add dropped pseudo-royal
1150+
if (type_of(m) == DROP && (extinction_piece_types() & type_of(moved_piece(m))))
1151+
pseudoRoyals |= square_bb(to);
11491152
Bitboard pseudoRoyalsTheirs = st->pseudoRoyals & pieces(~sideToMove);
11501153
if (is_ok(from) && (pseudoRoyals & from))
11511154
pseudoRoyals ^= square_bb(from) ^ kto;

test.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@
120120
castlingKingPiece = k
121121
extinctionValue = loss
122122
extinctionPieceTypes = k
123+
124+
[coregaldrop:coregal]
125+
pieceDrops = true
126+
startFen = rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR[Qq] w KQkq - 0 1
123127
"""
124128

125129
sf.load_variant_config(ini_text)
@@ -346,6 +350,11 @@ def test_legal_moves(self):
346350
result = sf.legal_moves("seirawan", fen, [])
347351
self.assertIn("c8g4h", result)
348352

353+
# Drop pseudo-royals into check
354+
result = sf.legal_moves("coregaldrop", sf.start_fen("coregaldrop"), [])
355+
self.assertIn("Q@a3", result)
356+
self.assertNotIn("Q@a6", result)
357+
349358
# In Cannon Shogi the FGC and FSC can also move one square diagonally and, besides,
350359
# move or capture two squares diagonally, by leaping an adjacent piece.
351360
fen = "lnsg1gsnl/1rc1kuab1/p1+A1p1p1p/3P5/6i2/6P2/P1P1P3P/1B1U1ICR1/LNSGKGSNL[] w - - 1 3"

0 commit comments

Comments
 (0)