A python chess engine.
Project description
Pyanchetto
A python chess engine.
Running a PGN file from the command line
Specify a PGN file as input and optionally use -v or --verbose to print out each move.
python pyanchetto/driver.py -p examplepgn/1000144.pgn
**************************************************
Pyanchetto - Python Chess Engine.
**************************************************
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . ♟
. . . . . ♚ . ♙
. . . . . . . ♔
. . . . . . . ♙
. . . . . . . .
8/8/8/7p/5k1P/7K/7P/8 w - - 1 76
Programmatically running a PGN string
Executing a PGN string can be done in only a few lines of code.
from pyanchetto.chess import Chess
from pyanchetto.pgn_interpreter import ChessInterpreter
from pyanchetto.pgn_parser import parse_notation
board = Chess()
interpreter = ChessInterpreter(board)
game = "1. Nc3 f5 2. e4 fxe4 3. Nxe4 Nf6 4. Nxf6+ gxf6 5. Qh5#"
tree = parse_notation(game)
interpreter.execute(tree, True)
print(board.fen())
print(board.pgn())
♜ ♞ ♝ ♛ ♚ ♝ ♞ ♜
♟ ♟ ♟ ♟ ♟ ♟ ♟ ♟
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
♙ ♙ ♙ ♙ ♙ ♙ ♙ ♙
♖ ♘ ♗ ♕ ♔ ♗ ♘ ♖
Turn: 1
♜ ♞ ♝ ♛ ♚ ♝ ♞ ♜
♟ ♟ ♟ ♟ ♟ ♟ ♟ ♟
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . ♘ . . . . .
♙ ♙ ♙ ♙ ♙ ♙ ♙ ♙
♖ . ♗ ♕ ♔ ♗ ♘ ♖
♜ ♞ ♝ ♛ ♚ ♝ ♞ ♜
♟ ♟ ♟ ♟ ♟ . ♟ ♟
. . . . . . . .
. . . . . ♟ . .
. . . . . . . .
. . ♘ . . . . .
♙ ♙ ♙ ♙ ♙ ♙ ♙ ♙
♖ . ♗ ♕ ♔ ♗ ♘ ♖
Turn: 2
♜ ♞ ♝ ♛ ♚ ♝ ♞ ♜
♟ ♟ ♟ ♟ ♟ . ♟ ♟
. . . . . . . .
. . . . . ♟ . .
. . . . ♙ . . .
. . ♘ . . . . .
♙ ♙ ♙ ♙ . ♙ ♙ ♙
♖ . ♗ ♕ ♔ ♗ ♘ ♖
♜ ♞ ♝ ♛ ♚ ♝ ♞ ♜
♟ ♟ ♟ ♟ ♟ . ♟ ♟
. . . . . . . .
. . . . . . . .
. . . . ♟ . . .
. . ♘ . . . . .
♙ ♙ ♙ ♙ . ♙ ♙ ♙
♖ . ♗ ♕ ♔ ♗ ♘ ♖
Turn: 3
♜ ♞ ♝ ♛ ♚ ♝ ♞ ♜
♟ ♟ ♟ ♟ ♟ . ♟ ♟
. . . . . . . .
. . . . . . . .
. . . . ♘ . . .
. . . . . . . .
♙ ♙ ♙ ♙ . ♙ ♙ ♙
♖ . ♗ ♕ ♔ ♗ ♘ ♖
♜ ♞ ♝ ♛ ♚ ♝ . ♜
♟ ♟ ♟ ♟ ♟ . ♟ ♟
. . . . . ♞ . .
. . . . . . . .
. . . . ♘ . . .
. . . . . . . .
♙ ♙ ♙ ♙ . ♙ ♙ ♙
♖ . ♗ ♕ ♔ ♗ ♘ ♖
Turn: 4
♜ ♞ ♝ ♛ ♚ ♝ . ♜
♟ ♟ ♟ ♟ ♟ . ♟ ♟
. . . . . ♘ . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
♙ ♙ ♙ ♙ . ♙ ♙ ♙
♖ . ♗ ♕ ♔ ♗ ♘ ♖
♜ ♞ ♝ ♛ ♚ ♝ . ♜
♟ ♟ ♟ ♟ ♟ . . ♟
. . . . . ♟ . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
♙ ♙ ♙ ♙ . ♙ ♙ ♙
♖ . ♗ ♕ ♔ ♗ ♘ ♖
Turn: 5
♜ ♞ ♝ ♛ ♚ ♝ . ♜
♟ ♟ ♟ ♟ ♟ . . ♟
. . . . . ♟ . .
. . . . . . . ♕
. . . . . . . .
. . . . . . . .
♙ ♙ ♙ ♙ . ♙ ♙ ♙
♖ . ♗ . ♔ ♗ ♘ ♖
rnbqkb1r/ppppp2p/5p2/7Q/8/8/PPPP1PPP/R1B1KBNR b KQkq - 1 5
1. Nc3 f5 2. e4 fxe4 3. Nxe4 Nf6 4. Nxf6+ gxf6 5. Qh5#
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyanchetto-0.3.0.tar.gz
(22.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyanchetto-0.3.0.tar.gz.
File metadata
- Download URL: pyanchetto-0.3.0.tar.gz
- Upload date:
- Size: 22.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4cf48fd84143af997b31cf5b14c70ff4b393c3f1130d12350b08e0396023b67
|
|
| MD5 |
5100b1e9a004011045f3e5c39511fa14
|
|
| BLAKE2b-256 |
990eac740e57544eb22eab9e3acf620355053f0263799ff3ec3a0b1fbf24752c
|
File details
Details for the file pyanchetto-0.3.0-py3-none-any.whl.
File metadata
- Download URL: pyanchetto-0.3.0-py3-none-any.whl
- Upload date:
- Size: 23.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf1447d955d789109aeb1fab5982e7181ac74f9714abf6d441f31553bd8446ec
|
|
| MD5 |
074dd9a9d05d4431a565678e3e201f21
|
|
| BLAKE2b-256 |
54fceb6a5054dc917e5038ce5771ad458fff737a281c14c3751f2a256a66df97
|