chess-engine
chess-engine copied to clipboard
Implement UCI protocol
https://en.m.wikipedia.org/wiki/Universal_Chess_Interface
https://www.shredderchess.com/download.html
As this is crate is no_std, the first step would be to implement a message parser and state machine with an API to send commands to the engine. This API can then be used to wire up to stdin/stdout for chess GUIs for example.
I've whipped up a potential state diagram for the ICU engine, transitions are denoted with gui=* when they are transitions that are to be made on receipt of a command and engine=* for commands to be sent by us to the GUI as a side effect of a transition:
mermaid.js src
stateDiagram-v2
[*] --> Ready: gui=uci
Ready --> Identifying: engine=id
note right of Ready
Identify itself with the engine name,
author, and options. Finally sending the
uciok command.
end note
Identifying --> Idle
Idle-->[*]: gui=quit
# Idle --> Idle: gui=debug
Idle --> Syncing: gui=isready
Idle --> Configuring: gui=setoption
Configuring --> Configuring: gui=setoption
Configuring --> Syncing
Syncing --> Idle: engine=readyok
Idle-->Playing: gui=ucinewgame
Idle-->Playing: gui=position
Playing-->Playing: gui=position
Playing-->Searching: gui=go
Searching-->Playing: gui=stop
Searching-->Playing: engine=bestmove
Thinking a little more, ICU might be more of a frontend (like web or terminal), than something that's built into the engine itself.