if (is_gating(m) && gating_square(m) == to)
from = to_sq(m), to = from_sq(m);
else if (type_of(m) == CASTLING && !pos.is_chess960())
+ {
to = make_square(to > from ? pos.castling_kingside_file() : pos.castling_queenside_file(), rank_of(from));
+ // If the castling move is ambiguous with a normal king move, switch to 960 notation
+ if (pos.pseudo_legal(make_move(from, to)))
+ to = to_sq(m);
+ }
string move = (type_of(m) == DROP ? UCI::dropped_piece(pos, m) + (Options["Protocol"] == "usi" ? '*' : '@')
: UCI::square(pos, from)) + UCI::square(pos, to);
castling = false
startFen = r6r/1nbqkbn1/pppppppp/8/8/PPPPPPPP/1NBQKBN1/R6R w - - 0 1
-# Diana Chess // Kingside castling not working!
+# Diana Chess
# https://greenchess.net/rules.php?v=diana
[diana:losalamos]
pieceToCharTable = PNBRQ................Kpnbrq................k
flagPiece = k
whiteFlag = *8
blackFlag = *1
+
+[diana:losalamos]
+pieceToCharTable = PNBRQ................Kpnbrq................k
+bishop = b
+promotionPieceTypes = rbn
+castling = true
+castlingKingsideFile = e
+castlingQueensideFile = b
+startFen = rbnkbr/pppppp/6/6/PPPPPP/RBNKBR w KQkq - 0 1
"""
sf.load_variant_config(ini_text)
result = sf.legal_moves("capablanca", CAPA, moves)
self.assertIn("f1i1", result)
+ # Check that chess960 castling notation is used for otherwise ambiguous castling move
+ # d1e1 is a normal king move, so castling has to be d1f1
+ result = sf.legal_moves("diana", "rbnk1r/pppbpp/3p2/5P/PPPPPB/RBNK1R w KQkq - 2 3", [])
+ self.assertIn("d1f1", result)
+
def test_get_fen(self):
result = sf.get_fen("chess", CHESS, [])
self.assertEqual(result, CHESS)