2

I'm trying to analyze a game with the python-chess package, and for that I want to turn off the "Analysis Contempt" option in Stockfish. However, it seems it doesn't work, and I don't know why. Neither configuring the engine nor setting the option did the job - the evaluation flips every move in a simple opening line (Spanish) - it gives white the advantage on white move and the same for black. Any idea what I'm doing wrong? I tried with both Stockfish 12 and Komodo 11 as the engine (where I set "White Contempt" to 0 instead of "Analysis Contempt".

def get_best_move_score(board: chess.Board) -> int:
    engine_path = os.environ.get('STOCKFISH')
    engine = chess.engine.SimpleEngine.popen_uci(engine_path)
    engine.configure({'Analysis Contempt': 'Off', 'Contempt': "0"})
    analysis = engine.analyse(board, chess.engine.Limit(depth=20),
                              options={'Analysis Contempt': 'Off', 'Contempt': "0"})
    return analysis['score']


os.environ["STOCKFISH"] = "coach/charts/stockfish12"
file = open("coach/charts/game.pgn", encoding="utf-8-sig")

game = chess.pgn.read_game(file)
board = game.board()
previous_move = None
for move in game.mainline_moves():
    score = get_best_move_score(board)
    board.push(move)
    print(previous_move, score)
    previous_move = move
file.close()
1

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.