3 ms·
Chess engines are a good reference for this. The decision-making part is a CLI that plugs into a GUI like WinBoard[0] or Arena[1]. There’s a protocol the engine
by halfcat 3y ago
Chess engines are a good reference for this. The decision-making part is a CLI that plugs into a GUI like WinBoard[0] or Arena[1]. There’s a protocol the engine and GUI follow, such as the WinBoard or UCI[2] protocols, which just exchange text commands via STDIN/STDOUT.
The main challenges are the same problems you’d run into with multithreading, like deadlock where the GUI and CLI are both waiting on the other. So both sides typically need to be running their I/O in a separate thread from the “business logic”, so both sides remain responsive.
A second common issue is idiosyncrasies around each OS’s handling of pipes, things like making sure you flush the buffer, or just the different OS-level API calls that differ between Linux, Mac, and Windows.
[0] http://hgm.nubati.net/ http://hgm.nubati.net/
[1] http://www.playwitharena.de/ http://www.playwitharena.de/
[2] https://gist.github.com/DOBRO/2592c6dad754ba67e6dcaec8c90165bf https://gist.github.com/DOBRO/2592c6dad754ba67e6dcaec8c90165...
- hiAndrewQuinn 3y agoMuch obliged! Chess GUIs are a very natural extension of a CLI, thank you!