Qirkat (Gleam)
Qirkat, also known as alquerque, is a board game that was popular in medieval Spain and later grew into checkers. This is a stripped-down web version of the full Qirkat app for iPhone, iPad and Mac, written in Gleam with Lustre and compiled to JavaScript. You play against the computer, against another person at the same screen, or watch the computer play itself.
Play it at https://qirkat.com/play/.

Playing
Each side has twelve pieces on a board of five points by five, with only the centre point free. Every point is joined by a line to the points beside, above and below it; diagonal lines meet only at every other point (the corners, the centre and the points in step with them), as on the app’s board. Light moves first.
- A piece moves along a line to the next point, if it is free, forward or sideways but never backward.
- A piece may not step straight back to the point it has just stepped from, however many turns it waits there. Once it has stepped somewhere else, or jumped, that point is open to it again.
- A piece captures by jumping over an opponent’s piece next to it to the free point beyond, in any direction, backward included.
- If you can jump, you must. When more than one jump is open, you choose.
- A piece that can jump again from where it lands must go on jumping until it cannot.
- A player who cannot move loses, unless the other player could not move either: then the game is a draw.
To move, click a piece and then the point it should go to. A multiple jump is made one hop at a time.
The start screen asks how many players there are (0, 1 or 2; with one, you then choose your side) and holds the three settings:
- AI Strength, from 0 to 8, is how many moves ahead the computer looks. At 0 it plays the first move it finds; it starts at 3.
- Show valid moves draws a blue line from each piece that can move to the point it can reach.
- Allow takebacks adds the two arrows beside Resign and Quit, which take back and replay one move at a time.
Resign gives the game to the other side, and Quit goes back to the start screen. The tally above the board counts each side’s wins, and the draws, until the page is reloaded.
What the full app has that this does not
The app comes with documentation, move suggestions, analysis tools and three short stories.
Two other limits of this version:
- Nothing is saved. Reloading the page starts again with the settings as they were at first.
- The computer thinks on the page’s own thread, so at the highest strengths the page can stop responding for many seconds while it does.
Running it from source
You need Gleam (developed with 1.19.2), Erlang/OTP with rebar3 (OTP 29), which Lustre’s development tools run on, and Node (26.13), which runs the tests.
git clone https://github.com/jonathanhuston/qirkat-gleam.git
cd qirkat-gleam/qirkat
gleam test # the tests
gleam run -m lustre/dev start # the page at http://localhost:1234, rebuilt as you edit
gleam run -m lustre/dev build # dist/qirkat.js
The first run of either lustre/dev command downloads Bun into .lustre/, to bundle the JavaScript.
build writes the bundle only, because gleam.toml sets no_html = true. The page that serves it, dist/index.html, is kept by hand, and both are in the repository: qirkat/dist/ is the game as it is served, so after a change to the source, run build and commit dist/qirkat.js with it. The page is this:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta content="width=device-width, initial-scale=1" name="viewport">
<title>Qirkat</title>
<style>*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; } html, body, #app { background: #000; min-height: 100vh; }</style>
<script src="./qirkat.js" type="module"></script>
</head>
<body><div id="app"></div></body>
</html>
How it is built
Everything is in qirkat/src:
qirkat/position.gleam, board.gleam, player.gleam |
the points of the board, what stands on them, and the two sides |
qirkat/move.gleam |
the legal moves: steps, jumps, and every chain of jumps a piece can make |
qirkat/game.gleam |
a game in progress: whose turn it is, the phase, the history behind undo and redo, and the score the search works from |
qirkat/ai.gleam |
the computer: negamax with alpha-beta pruning to a fixed depth |
qirkat/model.gleam |
the app as Lustre sees it: one Model, the messages, and the update function that takes one to the next |
qirkat/view.gleam, view/board_view.gleam, view/controls_view.gleam |
the page as a function of the model: the board in SVG, the buttons in HTML, all styled inline |
qirkat/ffi.gleam, qirkat_ffi.mjs |
the only JavaScript: a timer, for the half-second pause before the computer moves |
A computer move is scheduled half a second ahead and carries a count of the changes made to the game so far. If the game has changed by the time the move arrives (a takeback, a resignation, a new game), it is dropped.
Tests
gleam test runs 58 tests: the rules and the search in test/qirkat_test.gleam; in test/board_lines_test.gleam which points the board’s lines join, in the rules and in the drawing; in test/no_stepping_back_test.gleam the rule against stepping straight back, and that a game between two computers ends; in test/draw_test.gleam how a game ends when a side cannot move; and in test/model_test.gleam when a scheduled computer move is played and when it is dropped.
History
Jonathan Huston wrote Qirkat in Swift for iPhone, iPad and Mac. This version was written in February 2026, using Claude.
Licence
The code in this repository is released under the MIT licence. The full Qirkat app is a separate program and is not part of it.