Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

你好,move = info.get("pv")[0],皮卡鱼引擎,第二步或者第三步就 IndexError: list index out of range #7

Open
startnow2024 opened this issue Jan 2, 2025 · 1 comment

Comments

@startnow2024
Copy link

@shinoi2
你好,我前两天问过引擎的问题的,当时是没把nnue文件放在同一个文件夹。
今天准备做一个中国象棋的简单GUI,又报错了,只输出了一步正确的走子。代码如下:

import cchess
import cchess.engine

engine = cchess.engine.SimpleEngine.popen_uci("D:/Windows/pikafish-bmi2.exe")
board = cchess.Board()

for i in range(5):
    info = engine.analyse(board, cchess.engine.Limit(time=1))
    print(info)
    move = info.get("pv")[0]
    print(move)
    board.push(move)

输出的info如下:

{'string': 'NNUE evaluation using pikafish.nnue (52MiB, (25920, 1024, 15, 32, 1))', 'depth': 21, 'seldepth': 33, 'multipv': 1, 'score': PovScore(Cp(+25), RED), 'nodes': 993943, 'nps': 992950, 'hashfull': 423, 'tbhits': 0, 'time': 1.001, 'pv': [Move.from_uci('h2e2')], 'upperbound': True}
h2e2
{'string': 'NNUE evaluation using pikafish.nnue (52MiB, (25920, 1024, 15, 32, 1))', 'depth': 22, 'seldepth': 33, 'multipv': 1, 'score': PovScore(Cp(-27), BLACK), 'nodes': 1016818, 'nps': 1015802, 'hashfull': 395, 'tbhits': 0, 'time': 1.001, 'pv': []}
Traceback (most recent call last):
  File "D:\xiangqi\xiangqi.py", line 10, in <module>
    move = info.get("pv")[0]
           
IndexError: list index out of range

第一步正常,第二步就报错了。试了几次,有时是第三步报错。
谢谢

@startnow2024
Copy link
Author

startnow2024 commented Jan 5, 2025

这个报错与board.push(move)无关。我直接设置一个FEN,然后皮卡鱼就没给出move了。在ubuntu上也试了一下,同样的报错。只有初始位置的FEN,皮卡鱼才返回move(h2e2). 其他的FEN试了好几个,都报错。直接print info 就能看出问题来。

import cchess
import cchess.engine

engine = cchess.engine.SimpleEngine.popen_uci("D:/software/chess AI/pikafish/Pikafish.2024-08-31/Windows/pikafish-bmi2.exe")
board = cchess.Board()
board_fen='rnbakabnr/9/1c5c1/p1p1p1p1p/9/9/P1P1P1P1P/1C2C4/9/RNBAKABNR b - - 1 1'
board.set_fen(board_fen)
print(board.fen())
info = engine.analyse(board, cchess.engine.Limit(time=1))
print(info)

输出如下:

rnbakabnr/9/1c5c1/p1p1p1p1p/9/9/P1P1P1P1P/1C2C4/9/RNBAKABNR b - - 1 1
{'string': 'NNUE evaluation using pikafish.nnue (52MiB, (25920, 1024, 15, 32, 1))', 'depth': 23, 'seldepth': 31, 'multipv': 1, 'score': PovScore(Cp(-26), BLACK), 'nodes': 974194, 'nps': 973220, 'hashfull': 394, 'tbhits': 0, 'time': 1.001, 'pv': []}

'pv': [],最后一项是空的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant