A python chess library with legal move generation, custom chess variant support, move making and unmaking, PGN/FEN loading/generating, and many other features
Python 2.7 or Python 3
The library can be installed directly from GitHub using pip: pip install git+https://github.com/DanielMiao1/chess
.
See the features section of the wiki for a list of features
>>> game = chess.Game()
To load a custom FEN, use the fen argument:
>>> game = chess.Game(fen="fen text")
Or, use the loadFEN
function to load a FEN after the game is initialized:
>>> game.loadFEN("fen text")
To generate a unicode representation of the board, use the Game.visualized()
function.
To make a move, use the Game.move()
function:
>>> game.move("e4")
e4
To undo (takeback) a move, use the Game.takeback()
function:
>>> game.takeback()