我正在分析一个国际象棋游戏 PGN 文件。我使用 stockfish 13 API 来执行游戏动作分析,但是引擎正在计算一些垃圾评估分数。对于 e2e4,同一游戏的评价接近 0。但是我使用 python chess 和 stockfish 国际象棋引擎的 python 代码的输出得到了 -3、+111 的评估。为什么是这样?怎么做才对?
PGN 文件:
[Event "Live Chess"]
[Site "Chess.com"]
[Date "2020.06.12"]
[Round "-"]
[White "LooseLoaf"]
[Black "joseines80"]
[Result "0-1"]
[CurrentPosition "6k1/p7/2p2p1p/4p3/8/8/r7/2K4r w - -"]
[Timezone "UTC"]
[ECO "C41"]
[ECOUrl "https://www.chess.com/openings/Philidor-Defense"]
[UTCDate "2020.06.12"]
[UTCTime "23:05:47"]
[WhiteElo "1023"]
[BlackElo "1204"]
[TimeControl "600"]
[Termination "joseines80 won by checkmate"]
[StartTime "23:05:47"]
[EndDate "2020.06.12"]
[EndTime "23:22:19"]
[Link "https://www.chess.com/game/live/4992823751"]
1. e4 e5 2. Nf3 d6 3. c3 Bg4 4. Bb5+ c6 5. Bc4 Bxf3 6. gxf3 b5 7. Bf1 h6 8. d4 Qf6 9. dxe5 dxe5 10. Nd2 Bd6 11. Bh3 Ne7 12. Nb3 Qh4 13. Bf1 Bc7 14. Be3 O-O 15. Nc5 Bb6 16. Nb7 Bxe3 17. Qd6 Qxf2+ 18. Kd1 Qxf3+ 19. Be2 Qxh1+ 20. Kc2 Qxa1 21. Qxe7 Qc1+ 22. Kb3 Na6 23. Bh5 Qf1 24. Nd6 Nc5+ 25. Kb4 Nd3+ 26. Ka3 Bc5+ 27. Kb3 Nc1+ 28. Kc2 Bxd6 29. Qxd6 Qf6 30. Qxf6 gxf6 31. Bxf7+ Rxf7 32. Kxc1 Rd7 33. c4 bxc4 34. Kc2 Rd4 35. b3 cxb3+ 36. Kxb3 Rxe4 37. a4 Rb8+ 38. Ka3 Rbb4 39. Ka2 Rxa4+ 40. Kb2 Reb4+ 41. Kc3 Rh4 42. h3 Rxh3+ 43. Kd2 Ra2+ 44. Kc1 Rh1# 0-1
代码:
import re
import pandas as pd
import numpy as np
from pgn_parser import pgn, parser
from stockfish import Stockfish
stockfish = Stockfish(r"C:\Users\sachi\Downloads\stockfish_13_win_x64_bmi2\stockfish_13_win_x64_bmi2.exe",
parameters={"Threads": 4, "Minimum Thinking Time": 30})
import asyncio
import chess
import chess.engine
board = chess.Board()
for i in moves:
board.push_san(i)
print(board.fen())
stockfish.set_fen_position(board.fen())
print(stockfish.get_fen_position())
print(stockfish.get_evaluation())
info = engine.analyse(board, chess.engine.Limit(.001))
print("Score:", info["score"])
print()
评估输出:
rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq - 0 1
rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq - 0 1
{'type': 'cp', 'value': -3}
Score: PovScore(Cp(-32), BLACK)
rnbqkbnr/pppp1ppp/8/4p3/4P3/8/PPPP1PPP/RNBQKBNR w KQkq - 0 2
rnbqkbnr/pppp1ppp/8/4p3/4P3/8/PPPP1PPP/RNBQKBNR w KQkq - 0 2
{'type': 'cp', 'value': 111}
Score: PovScore(Cp(+46), WHITE)
rnbqkbnr/pppp1ppp/8/4p3/4P3/5N2/PPPP1PPP/RNBQKB1R b KQkq - 1 2
rnbqkbnr/pppp1ppp/8/4p3/4P3/5N2/PPPP1PPP/RNBQKB1R b KQkq - 1 2
{'type': 'cp', 'value': 9}
Score: PovScore(Cp(-29), BLACK)
rnbqkbnr/ppp2ppp/3p4/4p3/4P3/5N2/PPPP1PPP/RNBQKB1R w KQkq - 0 3
rnbqkbnr/ppp2ppp/3p4/4p3/4P3/5N2/PPPP1PPP/RNBQKB1R w KQkq - 0 3
{'type': 'cp', 'value': 59}
Score: PovScore(Cp(+79), WHITE)
rnbqkbnr/ppp2ppp/3p4/4p3/4P3/2P2N2/PP1P1PPP/RNBQKB1R b KQkq - 0 3
rnbqkbnr/ppp2ppp/3p4/4p3/4P3/2P2N2/PP1P1PPP/RNBQKB1R b KQkq - 0 3
{'type': 'cp', 'value': 37}
Score: PovScore(Cp(+6), BLACK)
rn1qkbnr/ppp2ppp/3p4/4p3/4P1b1/2P2N2/PP1P1PPP/RNBQKB1R w KQkq - 1 4
rn1qkbnr/ppp2ppp/3p4/4p3/4P1b1/2P2N2/PP1P1PPP/RNBQKB1R w KQkq - 1 4
{'type': 'cp', 'value': 112}
Score: PovScore(Cp(+69), WHITE)
rn1qkbnr/ppp2ppp/3p4/1B2p3/4P1b1/2P2N2/PP1P1PPP/RNBQK2R b KQkq - 2 4
rn1qkbnr/ppp2ppp/3p4/1B2p3/4P1b1/2P2N2/PP1P1PPP/RNBQK2R b KQkq - 2 4
{'type': 'cp', 'value': -26}
Score: PovScore(Cp(+77), BLACK)
rn1qkbnr/pp3ppp/2pp4/1B2p3/4P1b1/2P2N2/PP1P1PPP/RNBQK2R w KQkq - 0 5
rn1qkbnr/pp3ppp/2pp4/1B2p3/4P1b1/2P2N2/PP1P1PPP/RNBQK2R w KQkq - 0 5
{'type': 'cp', 'value': -12}
Score: PovScore(Cp(+15), WHITE)
rn1qkbnr/pp3ppp/2pp4/4p3/2B1P1b1/2P2N2/PP1P1PPP/RNBQK2R b KQkq - 1 5
rn1qkbnr/pp3ppp/2pp4/4p3/2B1P1b1/2P2N2/PP1P1PPP/RNBQK2R b KQkq - 1 5
{'type': 'cp', 'value': -101}
Score: PovScore(Cp(+62), BLACK)
.
.
,