anastasop/ostap

Error when the .pgn file ends with a checkmate

Closed this issue · 0 comments

If I provide a .pgn file that ends with a checkmate, the application breaks when trying to evaluate the last position.

Traceback (most recent call last):
  File "/home/dt/projects/ostap/venv/bin/ostap", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/dt/projects/ostap/venv/lib/python3.11/site-packages/ostap/cli.py", line 54, in main
    game = ostap.analyze(engine, pgn, analysis_options = analysis_options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dt/projects/ostap/venv/lib/python3.11/site-packages/ostap/ostap.py", line 76, in analyze
    last_ev = evaluation(engine, board, analysis_options = analysis_options)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dt/projects/ostap/venv/lib/python3.11/site-packages/ostap/ostap.py", line 94, in evaluation
    evaluations = [
                  ^
  File "/home/dt/projects/ostap/venv/lib/python3.11/site-packages/ostap/ostap.py", line 96, in <listcomp>
    Move(board.san(info['pv'][0]), info['pv'][0].uci())) for info in infos])
                   ~~~~^^^^^^
KeyError: 'pv'

Contents of infos:

[{'string': 'NNUE evaluation using nn-b1a57edbea57.nnue', 'depth': 0, 'score': PovScore(Mate(-0), BLACK)}]

Example .pgn file:

[White "Mr. White"]
[Black "Mr. Black"]
[Result "1-0"]

1. e4 f5 2. exf5 g5 3. Qh5#