3

I have a FEN position and I want to analyze which position is stronger. For example, I have this position

rnbq1bnr/pp2k2N/8/2p1p2Q/4N3/8/PPPP1PPP/R1B1KB1R b KQ - 0 1

How to evaluate a position and get score value using Stockfish? (example, the white score is +9 or black -5)

manlio
  • 18,345
  • 14
  • 76
  • 126
Armen Stepanyan
  • 1,618
  • 13
  • 29

1 Answers1

4

With Python you could use the python-chess library:

import chess
import chess.engine

engine = chess.engine.SimpleEngine.popen_uci("stockfish")

board = chess.Board("rnbq1bnr/pp2k2N/8/2p1p2Q/4N3/8/PPPP1PPP/R1B1KB1R b KQ - 0 1")
info = engine.analyse(board, chess.engine.Limit(depth=20))
print("Score:", info["score"])
# Score: #+9

engine.quit()

Take a look at the engine module for further details.

manlio
  • 18,345
  • 14
  • 76
  • 126