Skip to main content

Wraps the open-source Stockfish chess engine for easy integration into python.

Project description

Stockfish

Implements an easy-to-use Stockfish class to integrates the Stockfish chess engine with Python.

Install

$ pip install stockfish

Ubuntu or Debian

# apt install stockfish

Mac OS

$ brew install stockfish

Features and usage examples

Initialize Stockfish class

You should install the stockfish engine in your operating system globally or specify path to binary file in class constructor

from stockfish import Stockfish

stockfish = Stockfish("/Users/zhelyabuzhsky/Work/stockfish/stockfish-9-64")

Set position by sequence of moves:

stockfish.set_position(["e2e4", "e7e6"])

Set position by Forsyth–Edwards Notation (FEN):

stockfish.set_fen_position("rnbqkbnr/pppp1ppp/4p3/8/4P3/8/PPPP1PPP/RNBQKBNR w KQkq - 0 2")

Get best move

stockfish.get_best_move()
d2d4

Check is move correct with current position

stockfish.is_move_correct('a2a3')
True

Set current engine's skill level:

stockfish.set_skill_level(15)

Get current engine's parameters:

stockfish.get_parameters()
{'Write Debug Log': 'false', 'Contempt': 0, 'Min Split Depth': 0, 'Threads': 1, 'Ponder': 'false', 'Hash': 16, 'MultiPV': 1, 'Skill Level': 20, 'Move Overhead': 30, 'Minimum Thinking Time': 20, 'Slow Mover': 80, 'UCI_Chess960': 'false'}

Get current board position in Forsyth–Edwards notation (FEN):

stockfish.get_fen_position()
rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1

Get current board visual

stockfish.get_board_visual()
+---+---+---+---+---+---+---+---+
| r | n | b | q | k | b | n | r |
+---+---+---+---+---+---+---+---+
| p | p | p | p | p | p | p | p |
+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+
| P | P | P | P | P | P | P | P |
+---+---+---+---+---+---+---+---+
| R | N | B | Q | K | B | N | R |
+---+---+---+---+---+---+---+---+

Testing

$ python setup.py test

Security

If you discover any security related issues, please email zhelyabuzhsky@icloud.com instead of using the issue tracker.

Credits

License

MIT License. Please see License File for more information.

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

stockfish-3.8.1.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stockfish-3.8.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file stockfish-3.8.1.tar.gz.

File metadata

  • Download URL: stockfish-3.8.1.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.6

File hashes

Hashes for stockfish-3.8.1.tar.gz
Algorithm Hash digest
SHA256 36f49217aa036c6a075c49509f93e9889778b372653d463736297351889d168b
MD5 abda6c5cad6f5b13562ade654c91a991
BLAKE2b-256 7f0a5cc0ed76bdf0204638ae01922025600a1c8b20488420558aaad86a3fd4d3

See more details on using hashes here.

File details

Details for the file stockfish-3.8.1-py3-none-any.whl.

File metadata

  • Download URL: stockfish-3.8.1-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.6

File hashes

Hashes for stockfish-3.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1df71eefd27bd9bfbdfe976a04033b39f1c42ed0e02911eaa15cab9172af5eaa
MD5 4ffee61e23955788e6aed5e3073067a8
BLAKE2b-256 2a8ec73e923ffe84e152e94b321144d13a218a80b8905b8ba72b1c3b0ed515cb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page