kjchess is a simple chess-playing engine, implemented in Swift.
I've wanted to write a chess program since I was a teenager. I'm finally doing it. I don't expect this to play a strong game, and it won't be using any advanced chess implementation techniques. It's a toy, but it's all mine.
kjchess is usable, but not great. The following features are implemented:
- Can determine legal moves for a given position.
- Uses minimax with alpha-beta pruning to determine best move.
- Implements enough of the UCI protocol that a game can be played with these chess UIs:
The biggest weaknesses right now is that the move search is slow (a search depth of 6 takes a few seconds per move on my 2013 MacBook Pro). The engine also doesn't save any information between moves, or ponder during the opponent's move.
kjchess is written in Swift, and requires features of macOS 10.12 Sierra.
The easiest way to build everything is to run this command from the top-level directory:
The binaries will be in the
To run unit tests, execute this command:
kjchess-cli is the executable program. It does not provide its own GUI or command-line playing interface: It must be run as a chess engine with a GUI chess application that implements the UCI (Universal Chess Interface) protocol.
Note: On macOS, XBoard and PolyGlot can be installed from Homebrew with
brew install xboard polyglot.
kjchess-cli may work with other UCI user interfaes, but its UCI implementation is very rudimentary and has only been tested with XBoard and PolyGlot, Scid vs Mac, and ChessX.
kjchess-cli accepts these command-line options:
--help: Show command-line help
--concurrent-tasks=N: Number of concurrent tasks (default 4)
--enable-log: Enable system log output
--input-path=PATH: Read from file instead of standard input
--search-depth=N: Search depth (default 6)
--version: Show version information