Skip to content

DanielMiao1/chess

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

95 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

chess

A python chess library with legal move generation, custom chess variant support, move making and unmaking, PGN/FEN loading/generating, and many other features

Requirements

Python 2.7 or Python 3

Installation

The library can be installed directly from GitHub using pip: pip install git+https://github.com/DanielMiao1/chess.

Basic Features

See the features section of the wiki for a list of features

Creating a new game

>>> 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")

Printing the board

To generate a unicode representation of the board, use the Game.visualized() function.

Making a move

To make a move, use the Game.move() function:

>>> game.move("e4")
e4

Undo move

To undo (takeback) a move, use the Game.takeback() function:

>>> game.takeback()