-
-
Notifications
You must be signed in to change notification settings - Fork 510
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
Support uci go perft
#951
Comments
I ended up writing this code: async def uci_perft(engine, depth):
class UciPerftCommand(BaseCommand[UciProtocol, None]):
def __init__(self, engine: UciProtocol):
super().__init__(engine)
self.moves = []
def start(self, engine: UciProtocol) -> None:
engine.send_line(f"go perft {depth}")
def line_received(self, engine: UciProtocol, line: str) -> None:
match = re.match("(\w+): (\d+)", line)
if match:
move = chess.Move.from_uci(match.group(1))
cnt = int(match.group(2))
self.moves.append((move, cnt))
match = re.match("Nodes searched: (\d+)", line)
if match:
self.result.set_result(self.moves)
self.set_finished()
return await engine.communicate(UciPerftCommand) |
This is mostly Stockfish and derivates, right? Maybe not standardized enough to add to the API, but your snippet makes for a good example of custom engine communication. Then again, adding it to the documentation means that |
I noticed it in a few other engines:
But I guess it's bad to support non-standard syntax. A supported way to do non-standard communication would be nice though. It allows writing general tools for testing chess engines. The engines only have to support a few "debug" commands (like perft) and the testing tool can run a suite of tests. Btw, did you see this effort to formalize uci? https://talkchess.com/forum3/viewtopic.php?f=7&t=81233 |
Many engines, such as Stockfish, support a non-standard UCI command
go perft <depth>
. This would be very useful to have in python-chess as a way to test engines.This could be implemented using a
Limit()
. Alternatively, is there a good way to send custom commands and read the output through python-chess?The text was updated successfully, but these errors were encountered: