Desdemona

A game of Reversi for the Mac, built with Tauri and ClojureScript

View on GitHub

Desdemona

A game of Reversi for the Mac, played with Dark and Light stones: place a stone so that it brackets a line of your opponent’s, and they turn over to your colour. You play against the computer, against another person at the same machine, or watch the computer play itself. It was built to try Tauri 2 as the shell of a Mac app with ClojureScript as the whole of its interface.

The Desdemona window in the middle of a game: Dark and Light stones on a board of dark grey squares, faint dots on the squares Dark may play, the counts above and the buttons below

Getting it running

To play, download the disk image from the latest release, open it, and drag Desdemona to your Applications folder. It needs an Apple-silicon Mac with macOS 13.1 or later and nothing else, and it opens without a security warning, since the app is signed and notarised.

To run it from source, you need the same Mac, and:

git clone https://github.com/jonathanhuston/desdemona.git
cd desdemona
npm install
npm run dev      # the app in its window, with hot reload
npm run build    # src-tauri/target/release/bundle/macos/Desdemona.app

The first npm run dev or npm run build compiles Tauri’s Rust crates, which takes a minute or two and leaves a few gigabytes in src-tauri/target/. npm run web runs the same page in an ordinary browser at http://localhost:8280, without the native menu.

An app built without a signing identity is signed only for the Mac that built it. Releasing describes the signed build.

Playing

Dark moves first. A move must bracket at least one line of the opponent’s stones between the new stone and one already on the board, and every stone so bracketed turns over. A side with no move passes; the game ends when neither side can move, and the side with more stones wins.

Game menu Keys
New Game ⌘N or N
Undo ⌘Z or U
Dark ▸ Human, Computer  
Light ▸ Human, Computer  
Level ▸ Easy, Medium, Hard  
Show Legal Moves ⌘L or L

The plain keys N, U and L work in the browser too. ⌘Q quits.

Who plays each side, the level and Show Legal Moves are remembered between launches. The game in progress and the window size are not.

How it is built

   
src/desdemona/rules.cljc the rules behind a small Rules protocol (start, legal moves, play, over, score), with the standard rules as its one implementation
src/desdemona/search.cljc the computer: negamax with alpha-beta pruning, deepened one ply at a time, after the search in the Red version (see History)
src/desdemona/logic.cljc everything the app does, as one pure function from a state and an event to a new state and a list of effects
src/desdemona/view.cljs the page as a pure function of the state, rendered by Replicant
src/desdemona/main.cljs with menu, one of the two impure parts of the page: the state, rendering, effects, keys, saved settings
src/desdemona/menu.cljs the other impure part: the native menu, built from JavaScript when the page runs inside Tauri
src/desdemona/worker.cljs a Web Worker that runs the search, so the window stays live while the computer thinks

Effects are data: start a search, cancel it, save the settings, send an event after so many milliseconds. main carries them out, so every rule of play, from the pass notice to undo during a search, is tested as a plain function, with time driven by hand.

Tauri provides the window, the native menu (through its JavaScript API) and the bundle. There is no Rust beyond what tauri init generated. Settings are kept in the web view’s localStorage, which persists between launches of the packaged app. shadow-cljs compiles the page and the worker as two modules over a shared one, and serves the page in development.

Tests

npm test

This runs the tests of the rules, the search and the logic twice, on the JVM and under node, and the view’s tests under node. The page itself is checked in WebKit, the engine of the Mac window, by scripts that need npm run web running, and Playwright’s WebKit installed once with npx playwright install webkit:

npx playwright install webkit   # once
npm run shots           # pictures of scripted positions in docs/screenshots/
node dev/play.mjs       # plays games by clicking, against the real search
node dev/polish.mjs     # the flips, the keys and the saved settings

Releasing

To open on other Macs without a warning, the app has to be signed with a Developer ID and notarised by Apple. With a “Developer ID Application” certificate in the keychain:

APPLE_SIGNING_IDENTITY="Developer ID Application: <Your Name> (<TEAMID>)" npm run build

The identity’s full name is listed by security find-identity -v -p codesigning. Tauri signs the app with the hardened runtime and, with no Apple ID or API key variables set, skips notarising. Before signing it runs xattr -cr on the bundle, which needs the system’s /usr/bin/xattr: if another xattr comes first on your PATH (Anaconda installs one without -r), put PATH="/usr/bin:$PATH" in front of the command.

Notarising and the disk image are not yet automated. By hand, from src-tauri/target/release/bundle/macos/, with notary credentials stored once with xcrun notarytool store-credentials <profile>:

ditto -c -k --keepParent Desdemona.app Desdemona.zip
xcrun notarytool submit Desdemona.zip --keychain-profile <profile> --wait
xcrun stapler staple Desdemona.app
spctl -a -vv Desdemona.app       # expect: Notarized Developer ID

Then the disk image, with the stapled app beside a link to /Applications:

mkdir <staging> && cp -R Desdemona.app <staging>/ && ln -s /Applications <staging>/Applications
hdiutil create -volname Desdemona -srcfolder <staging> -ov -format UDZO Desdemona.dmg
codesign --sign "<identity>" --timestamp Desdemona.dmg
xcrun notarytool submit Desdemona.dmg --keychain-profile <profile> --wait
xcrun stapler staple Desdemona.dmg
spctl -a -t open --context context:primary-signature -v Desdemona.dmg

The dmg is made by hand because Tauri’s own dmg step builds the app again and would lose the staple. Version 0.1.0 was released this way on 3 December 2026; the results are in docs/risk-check.md. The image is not in the repository: it is built into release/, which git ignores, and published on the releases page.

Things worth knowing before changing it

History and credits

Jonathan Huston first wrote the game in Red in 2019 (begun at the end of 2018), as othello.red, and rewrote it there in 2026 with a dark theme and a negamax opponent. Desdemona, written in 2026 using Claude, is the same game as an experiment in building a Mac app with Tauri and ClojureScript. Its search and its table of square weights come from the Red version.

The app is built on Tauri, ClojureScript, shadow-cljs and Replicant.

Licence

Desdemona is released under the MIT licence.