-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstockfish_test.py
More file actions
28 lines (22 loc) · 863 Bytes
/
stockfish_test.py
File metadata and controls
28 lines (22 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import chess.engine
# Replace this with the path to your Stockfish binary
stockfish_path = "../stockfish-11-linux/Linux/stockfish_20011801_x64"
def test_stockfish(stockfish_path):
try:
# Initialize the engine
with chess.engine.SimpleEngine.popen_uci(stockfish_path) as engine:
# Create a new board
board = chess.Board()
print("Initial position:\n", board)
# Ask Stockfish for the best move
result = engine.play(board, chess.engine.Limit(time=0.1))
print(f"Stockfish suggests the move: {result.move}")
return True
except Exception as e:
print(f"Error: {e}")
return False
# Run the test
if test_stockfish(stockfish_path):
print("Stockfish is working!")
else:
print("Stockfish test failed.")