zhelyabuzhsky / Stockfish
Licence: mit
Integrates the Stockfish chess engine with Python
Stars: ✭ 75
Programming Languages
python
139335 projects - #7 most used programming language
Labels
Projects that are alternatives of or similar to Stockfish
Realchess
Mod for Minetest to play a realistic chess game (GUI-based)
Stars: ✭ 5 (-93.33%)
Mutual labels: chess
Download
UI mod for Dota 2 Auto Chess that adds several QoL improvements to the UI
Stars: ✭ 65 (-13.33%)
Mutual labels: chess
Pgnstats
parses PGN files and extracts statistics for chess games
Stars: ✭ 16 (-78.67%)
Mutual labels: chess
Colamone js
A two-player strategy board game /オリジナルのボードゲームを作ってみる。
Stars: ✭ 13 (-82.67%)
Mutual labels: chess
Ostinato
A chess library that runs on the server (Scala) and on the browser (ScalaJS).
Stars: ✭ 42 (-44%)
Mutual labels: chess
Cc65 Chess
Portable chess game in C. Commodore 64, Apple 2, Atari, Oric, Commander X16, curses terminal, etc.
Stars: ✭ 21 (-72%)
Mutual labels: chess
Chessli
A free and open source chess improvement app that combines the power of Lichess and Anki.
Stars: ✭ 64 (-14.67%)
Mutual labels: chess
Chess Variants Training
Chess Variants Training is a website where you can improve at chess variants.
Stars: ✭ 18 (-76%)
Mutual labels: chess
Game Server
Distributed Java game server, including cluster management server, gateway server, hall server, game logic server, background monitoring server and a running web version of fishing. State machine, behavior tree, A* pathfinding, navigation mesh and other AI tools
Stars: ✭ 916 (+1121.33%)
Mutual labels: chess
Reddit Pgn To Gif
Converts PGN from /r/chess into gifs hosted on imgur and leaves a reddit comment
Stars: ✭ 16 (-78.67%)
Mutual labels: chess
Lila
♞ lichess.org: the forever free, adless and open source chess server ♞
Stars: ✭ 10,315 (+13653.33%)
Mutual labels: chess
Lichs
♟ Play chess against real players in your terminal using Lichess
Stars: ✭ 70 (-6.67%)
Mutual labels: chess
Galvanise zero
Learning from zero (mostly based off of AlphaZero) in General Game Playing.
Stars: ✭ 60 (-20%)
Mutual labels: chess
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")
There are some default engine's settings:
{
"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",
}
You can change them during your Stockfish class initialization:
stockfish = Stockfish(parameters={"Threads": 2, "Minimum Thinking Time": 30})
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
Get best move based on a time constraint
stockfish.get_best_move_time(1000)
Time constraint is in milliseconds
e2e4
Check is move correct with current position
stockfish.is_move_correct('a2a3')
True
Set current engine's skill level:
stockfish.set_skill_level(15)
Set current engine's depth:
stockfish.set_depth(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 |
+---+---+---+---+---+---+---+---+
Get current board evaluation in centipawns or mate in x
stockfish.get_evaluation()
Positive is advantage white, negative is advantage black
{"type":"cp", "value":12}
{"type":"mate", "value":-3}
Get current major version of stockfish engine
stockfish.get_stockfish_major_version()
11
Testing
$ python setup.py test
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
License
MIT License. Please see License File for more information.
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].