Cléchecs

A chess program for the Mac, in Clojure, with hand-drawn pieces standing on a 3D board

View on GitHub

Cléchecs

A chess program for the Mac, written in Clojure with cljfx and JavaFX. The pieces are hand-drawn, and stand on a 3D board like cardboard cutouts. You play against the computer, against another person at the same machine, or watch the computer play itself.

The Cléchecs window: a 3D board of grey and black squares late in a game, with hand-drawn pieces standing on it, and a side panel showing the captured pieces and the list of moves

What it does

Getting it running

To play, download the app from the latest release, unzip it, and drag Cléchecs to your Applications folder. It needs an Apple-silicon Mac and nothing else: no Java, and no security warning, since the app is signed and notarised.

To run it from source, you need an Apple-silicon Mac, a JDK (it is developed with OpenJDK 27, which includes jpackage) and the Clojure CLI.

git clone https://github.com/jonathanhuston/clechecs.git
cd clechecs
clojure -Srepro -M:run

-Srepro keeps a user-level ~/.clojure/deps.edn out of the project’s classpath.

To build a double-clickable app that needs no Java installed:

clojure -Srepro -T:build package

This makes target/dist/Cléchecs.app, about 91 MB with a trimmed Java runtime inside. An app built this way is signed only for the Mac that built it: on another Mac its first launch has to be allowed in System Settings → Privacy & Security. Releasing describes how to make one that opens anywhere.

Playing

The menus

Game  
White vs. Computer ⇧⌘W
Computer vs. Black ⇧⌘B
Human vs. Human ⇧⌘H
Computer vs. Computer ⇧⌘M
Undo, Redo ⌘Z, ⇧⌘Z
Hint ⌘T
Show Highlights  
Touch-Move  
Open PGN…, Save PGN… ⌘O, ⌘S
Copy FEN, Paste FEN ⇧⌘C, ⇧⌘V
Level  
Terrible, Novice, Decent, Strong, Fierce ⌘1 to ⌘5
View  
Flip Board ⇧⌘F
Reset View ⌘0

Choosing one of the four ways to play starts a new game. Against the computer, Undo takes back its reply together with your move, and interrupts it if it is still thinking. In Computer vs. Computer both sides play at the selected level, and any new game stops it.

The level, the way to play, the two toggles and the window size are remembered between launches.

Show Highlights and Touch-Move

With Show Highlights on, as it is to begin with, the board marks where a picked-up piece may go, the last move, a king in check, and the move a hint suggests.

The board with its markings: a tint on the squares of the last move, a dot and a ring on the squares a selected pawn may go to, dashed frames for a hint, and a red frame around a king in check

Switched off, the board is plain, like a physical one: no markings, and no hints. A piece you click rises a little, so you can see what you are holding.

Touch-Move is off to begin with. Switched on, it applies the rule of over-the-board chess: once you take hold of one of your pieces that can move, you must move that piece. You may put it down again, but you cannot pick up another.

The computer opponent

The engine is an alpha-beta search with iterative deepening, a transposition table, quiescence search, null-move pruning, late-move reductions and check extensions, over a board held in primitive arrays. On an Apple M4 it searches a little over a million positions a second. docs/engine-notes.md has the details and the measurements.

The three easy levels are named after the levels of Diamond Chess and tuned to play about as strongly as they did: in self-play against an imitation of Diamond Chess’s engine, each scored between 44 and 50 per cent over 200 games. Each level beats the one below it at least nine games in ten.

clojure -Srepro -M:dev -m clechecs.bench    # search speed
clojure -Srepro -M:dev -m clechecs.ladder   # the self-play ladder

How it is put together

   
src/clechecs/engine/ the board, move generation, evaluation, search, the opening book and the five levels
src/clechecs/engine.clj the one door into the engine: legal moves, making a move, searching
src/clechecs/position.clj, game.clj, notation.clj positions and FEN, the state of a game, algebraic notation and PGN
src/clechecs/ui/logic.clj everything the app does, as one pure function from a state and an event to a new state and a list of effects
src/clechecs/ui/board3d.clj, geometry.clj, cutout.clj the 3D board, its maths, and the code that cuts each drawing into a slab
src/clechecs/ui/app.clj the window, the menus and the side panel
src/clechecs/prefs.clj, main.clj saved settings and the entry point
resources/clechecs/ the piece drawings, the opening book and the stylesheet
dev/ the speed test, the self-play ladder and scripted scenarios that drive the board and the app and take pictures
test/ the tests
build.clj, package/ packaging and the app icon
docs/ notes on the engine, what was learned while building it, the design and the plans it was built from, and screenshots

Each piece is a single drawing. The program traces its outline, builds a slab of that shape, and puts the drawing on both faces. The white pieces are shown with the black pieces’ drawings, colours swapped, because those have the heavier lines.

Tests

clojure -Srepro -M:test -e :slow     # about fifteen seconds
clojure -Srepro -M:test              # everything

The tests cover:

The 3D board and the window have no unit tests. They are checked by scripted scenarios, which write pictures:

clojure -Srepro -M:dev -m clechecs.demo all /tmp/shots
clojure -Srepro -M:dev -m clechecs.demo app /tmp/shots

The scenario names are listed at the top of dev/clechecs/demo.clj.

Releasing

To make an app that opens on other Macs without a warning, it has to be signed with an Apple Developer ID and notarised by Apple. With a “Developer ID Application” certificate in the keychain, and notary credentials stored once with xcrun notarytool store-credentials <profile>:

clojure -Srepro -T:build release \
  :identity '"Developer ID Application: Your Name (TEAMID)"' \
  :notary-profile '"<profile>"'

This signs the app and the JavaFX libraries inside its jar, sends it to Apple, staples the ticket that comes back, and leaves target/dist/Clechecs-<version>-mac-arm64.zip ready to publish.

Things worth knowing before changing it

History and credits

Cléchecs was written in 2026 by Jonathan Huston, using Claude. It is the third of his chess programs to use the same pieces:

The pieces were designed by Ella Huston for Diamond Chess, in 2021.

The evaluation uses the PeSTO piece values and piece-square tables by Ronald Friederich. The app is built on Clojure, cljfx and OpenJFX.

Licence

The code is released under the MIT licence.

The piece artwork in resources/clechecs/pieces/, the app icon made from it in package/, and the pictures in docs/ that show it are not covered by that licence: they are copyright 2021 Ella Huston, all rights reserved.