3 ms·
I'm not quite that bad at chess, but bad enough that I wrote a chess game that plays random moves so I could always beat it: http://www.notesfromandy.com/2016/
by cocoadog 10y ago
I'm not quite that bad at chess, but bad enough that I wrote a chess game that plays random moves so I could always beat it:
http://www.notesfromandy.com/2016/09/27/chessfidget/ http://www.notesfromandy.com/2016/09/27/chessfidget/
That got boring, so I added very weak AI by connecting to the chess engine that comes preinstalled on macOS (inside Chess.app).
- kranner 10y ago> connecting to the chess engine that comes preinstalled on macOS Can you elaborate on this please? The presentation at your link doesn't say.
- cocoadog 10y agoOne of the preinstalled apps on macOS is /Applications/Chess.app. Turns out it uses an open-source chess engine called sjeng, the binary for which is inside the app bundle. Chess.app is itself open source, so I tweaked Apple's code for my own purposes. The code launches an sjeng process, opens a pipe to it, and sends commands over the pipe. There's a couple of sentences about this in the _README file here (as well as my tweaked source files): https://github.com/aglee/ChessFidget/tree/master/ChessFidget/Chess%20Engine https://github.com/aglee/ChessFidget/tree/master/ChessFidget... Fun fact: you can play chess in a terminal window by running /Applications/Chess.app/Contents/Resources/sjeng.ChessEngine. You can enter the `help` command for instructions. Note this will create four files with .lrn extensions in your home directory. I forget how to control this behavior -- you can Google "sjeng" for details.
- kranner 9y agoThanks for the explanation!