python-chess supports several chess variants.
>>> import chess.variant >>> >>> board = chess.variant.GiveawayBoard()
>>> # General information about the variants. >>> type(board).uci_variant 'giveaway' >>> type(board).xboard_variant 'giveaway' >>> type(board).starting_fen 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w - - 0 1'
Variant | Board class | UCI/XBoard | Syzygy |
---|---|---|---|
Standard | chess.Board |
chess/normal | .rtbw, .rtbz |
Suicide | chess.variant.SuicideBoard |
suicide | .stbw, .stbz |
Giveaway | chess.variant.GiveawayBoard |
giveaway | .gtbw, .gtbz |
Antichess | chess.variant.AntichessBoard |
antichess | .gtbw, .gtbz |
Atomic King of the Hill Racing Kings Horde Three-check Crazyhouse |
|
atomic kingofthehill racingkings horde 3check crazyhouse |
.atbw, .atbz |
chess.variant.find_variant
See chess.Board.is_variant_end()
, ~chess.Board.is_variant_win()
, ~chess.Board.is_variant_draw()
, or ~chess.Board.is_variant_loss()
for special variant end conditions and results.
Note that if all of them return False
, the game may still be over and decided by standard conditions like ~chess.Board.is_checkmate()
, ~chess.Board.is_stalemate()
, ~chess.Board.is_insufficient_material()
, move counters, repetitions, and legitimate claims.
Chess960 is orthogonal to all other variants.
>>> chess.Board(chess960=True) Board('rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1', chess960=True)
See chess.BaseBoard.set_chess960_pos()
, ~chess.BaseBoard.chess960_pos()
, and ~chess.BaseBoard.from_chess960_pos()
for dealing with Chess960 starting positions.
chess.variant.CrazyhousePocket
chess.variant.CrazyhouseBoard
chess.variant.ThreeCheckBoard
Multi-Variant Stockfish and other engines have an UCI_Variant
option. XBoard engines may declare support for variants
. This is automatically managed.
>>> import chess.engine >>> >>> engine = chess.engine.SimpleEngine.popen_uci("stockfish-mv") >>> >>> board = chess.variant.RacingKingsBoard() >>> result = engine.play(board, chess.engine.Limit(time=1.0))
Syzygy tablebases are available for suicide, giveaway and atomic chess.
>>> import chess.syzygy >>> import chess.variant >>> >>> tables = chess.syzygy.open_tablebase("data/syzygy", VariantBoard=chess.variant.AtomicBoard)