# My Swift terminal games play themselves. Press an arrow key to take over, in your browser

> Source: <https://dev.to/hideyukimori/my-swift-terminal-games-play-themselves-press-an-arrow-key-to-take-over-in-your-browser-2o46>
> Published: 2026-11-28 08:04:48+00:00

**Recommendation:** Verify a port by replaying identical seeds and scripted inputs and comparing per-frame hashes of characters and colors against the original implementation.
More in the playbook "Verifying model output": <https://wpnews.pro/playbooks/output-verification>

NeNe Swarm is a fixed-screen shooter, and NeNe Bolt is a side-scrolling platformer. In both, an AI plays forever. Press an arrow key and the game is yours from that frame on; leave the keys alone for 30 seconds and the AI takes over again.

They are written in Swift for the Linux terminal, and both also run in the browser. Open [hideyuki-mori.com](https://hideyuki-mori.com/?utm_source=devto&utm_campaign=swift-terminal-games) on a computer with a keyboard (a phone has no arrow keys), click the **swarm** or **bolt** icon on the site's desktop, click inside the window and press an arrow key.

|  | Swarm (fixed shooter) | Bolt (side-scroller) | 
|---|---|---|
| Move | ← → | ← → | 
| Climb ladders | — | ↑ ↓ | 
| Jump | — | Z or Space (hold for higher) | 
| Fire | Space or Z | X (hold to charge) | 
| Theme / difficulty / quit | t / d / q | t / d / q | 

While you are playing, the HUD says so (`YOU AI IN 27` in Swarm, `PLAYER 30s` in Bolt) and counts down to the moment the AI takes the controls back.

In Bolt, hold → and the runner keeps running; let go and it stops on that frame. That isn't a given in a terminal. Hold → in most terminals and the program gets a stream of repeated arrow sequences; let go and it gets nothing.

Windows Terminal has a mode for this. When the game writes `ESC [ ? 9001 h` at startup, the terminal switches to win32-input-mode, and every press and every release arrives as its own sequence, `ESC [ Vk ; Sc ; Uc ; Kd ; Cs ; Rc _`, where `Kd` says whether the key went down or up. These sequences pass through to programs running inside WSL, so the game knows exactly which keys are held on each frame. On exit it writes `ESC [ ? 9001 l` before restoring the screen.

In other terminals the games fall back to key repeats: a key counts as held for 0.6 seconds after it arrives and then for as long as the repeats keep coming, so the runner can overshoot a little. In the browser it's simple again, since `keydown` and `keyup` give the same information as win32-input-mode.

The game itself is a pure function: the current state, the buttons held on this frame and a seeded random source give the next state. Only the outermost layer reads the time, the keys and the seed. Your keys and the AI's decisions become the same set of buttons and go through the same function. Positions are integers (one cell is 16 units), and on screen the ships, runner, enemies, shots and terrain are blocks of color two terminal columns wide, so one "pixel" comes out roughly square.

That is what made the browser versions checkable. They are TypeScript ports, written with Claude Code like the Swift originals, and I don't take a port's word for it: each one replays the same seeds and the same scripted key presses as the Swift code, renders every frame at two terminal sizes, and compares a hash of each frame's characters and colors with what Swift produced. The random generator is the same SplitMix64 on both sides, done in exact integer arithmetic. Swarm's port matches on 240,008 frames, including a script where a human cuts in four times and lets the AI take back over four times. Bolt's matches on 258,010.

So when you take the controls on the site, you are playing the same game the Swift binary runs. [Try Swarm or Bolt at hideyuki-mori.com](https://hideyuki-mori.com/?utm_source=devto&utm_campaign=swift-terminal-games) and see how long you last before the AI gets them back.

Each game has a one-line installer for Linux x86_64 (WSL2 on Windows works). For Swarm:

```
curl -fsSL https://raw.githubusercontent.com/hideyukiMORI/nene-swarm/main/install.sh | bash
```

It checks the 2.7 MB download against `SHA256SUMS` and installs one binary in `~/.local/bin`. The Swift standard library is linked in, so all you need is glibc 2.35 or newer. From PowerShell, `install.ps1` in the same repository runs it inside WSL.

Bolt and Swarm have six siblings, all in Swift and open source: [Gambit](https://github.com/hideyukiMORI/nene-gambit) (four AIs trade insults over chess), [Igo](https://github.com/hideyukiMORI/nene-igo) (the same on a 19×19 Go board), [Wire](https://github.com/hideyukiMORI/nene-wire) (a news ticker), [Reversi](https://github.com/hideyukiMORI/nene-reversi), [Poker](https://github.com/hideyukiMORI/nene-poker) and [Sand](https://github.com/hideyukiMORI/nene-sand) (pour sand with the mouse). Gambit, Igo and Wire run on the site too, to watch rather than play. The sources of the two you can play: [nene-swarm](https://github.com/hideyukiMORI/nene-swarm) and [nene-bolt](https://github.com/hideyukiMORI/nene-bolt).

── Hideyuki Mori 🔗 [hideyuki-mori.com](https://hideyuki-mori.com/?utm_source=devto&utm_campaign=swift-terminal-games)
