python-chess.readthedocs.io - python-chess: a chess library for Python — python-chess 1.10.0 documentation

Example domain paragraphs

python-chess is a chess library for Python, with move generation, move validation, and support for common formats. This is the Scholar’s mate in python-chess:

>>> import chess >>> board = chess . Board () >>> board . legal_moves <LegalMoveGenerator at ... (Nh3, Nf3, Nc3, Na3, h3, g3, f3, e3, d3, c3, ...)> >>> chess . Move . from_uci ( "a8a1" ) in board . legal_moves False >>> board . push_san ( "e4" ) Move.from_uci('e2e4') >>> board . push_san ( "e5" ) Move.from_uci('e7e5') >>> board . push_san ( "Qh5" ) Move.from_uci('d1h5') >>> board . push_san ( "Nc6" ) Move.from_uci('b8c6') >>> board . push_san ( "Bc4" ) Move.from_uci('f1c4') >>> board . push_san ( "Nf6" ) Mo

pip install chess Documentation ¶ Core

Links to python-chess.readthedocs.io (1)