# Space War: a Star Trek strategy game written in Clojure

> Space War is the Clojure implementation that accompanies Episode 55 of the cleancoders.com course, a playable Star Trek economy game with three sensor views, warp and impulse flight, and a single long-term goal. It is a teaching codebase first, and the documentation is written as a player manual rather than as a developer guide.

**unclebob/spacewar** — Space War starting in Episode 55 of cleancoders.com

- Repository: https://github.com/unclebob/spacewar
- Stars: 679 · Forks: 68
- Language: Clojure
- License: not declared
- Published: 2026-10-21 · Updated: 2026-10-21 · Language: en
- Canonical page: https://hysenlabs.com/projects/unclebob-spacewar

## A playable game that exists to be read

Space War is the repository for the Space War game built starting in Episode 55 of cleancoders.com, and the primary language is Clojure. That framing decides what the project is for. A course episode needs working software that demonstrates design decisions as they happen, not a game with a business model, so the value here is the source rather than the entertainment. The current release is played at cleancoder.com/space-war, and the project also links an older version hosted by Mike Fikes at spacewar.fikesfarm.com/spacewar.html, which is a useful reference for how the design evolved. The README is written as a player manual. It explains the mission, the controls, the sensors, the engines, the weapons, the status meters, the damage model, docking and the base types in that order, and it says nothing about module structure, build tooling or test strategy. A developer wanting to learn from the code has to derive that part themselves.

## Three sensor views that deliberately hide different things

The sensor design is the clearest example of the game's information economy. There are three views. The front view shows a picture of stars and is described as otherwise useless, which is a deliberate dead end rather than a missing feature. The strategic view, labelled STRAT., shows the whole galaxy and can be zoomed with a slider; it shows Klingons, Romulans, stars, bases, transports and transport routes, but no weapons, explosions or debris. The tactical view, labelled TACT., shows what is nearby, including all weapons fired by you or your enemies, and explosions. The split forces choices. A commander who watches only the strategic view knows where the enemy fleet is but cannot see a torpedo already in flight, while a player working in the tactical view has limited situational awareness of the larger battle. The three views are the game's answer to the classic problem of a single camera that can show nothing, everything, or one scale.

## Warp and impulse price movement differently

Two movement modes with different costs shape every trip in the game. Warp moves the ship in a sequence of leaps, each leap the same size, and the more power used the faster the leaps happen, but the energy consumed is not linear. The documentation is blunt about this: Warp 10 uses a lot more antimatter than Warp 1. Rapid consumption also raises core temperature, particularly when dilithium is low. Impulse is the opposite: reaction thrust engines that consume antimatter and reach speeds that are a significant fraction of C, at which point space itself has a viscosity, so the ship feels drag that limits velocity and slows rapidly when the engines are off. A heading control turns the ship, and both engines move it in the direction it faces. The practical lesson for a player is that impulse is for the last stretch of a journey, not the trip itself, which is also how docking works.

## Antimatter, dilithium and core temperature are one coupled system

Four things need watching at all times, and they are not independent. Antimatter is the fuel for everything, and running out strands the ship. Dilithium is the catalyst for the antimatter reaction and is gradually consumed by all operations. Core temperature has to stay out of the red, or the ship blows. Shields absorb incoming energy and automatically replenish by consuming antimatter, with real damage beginning once shields drop below 50%. The interesting link is the feedback loop between dilithium and heat: when dilithium runs low the core temperature rises, because the antimatter reaction becomes less efficient. So the same shortage that slows your economy also pushes you toward overheating. This is the kind of closed loop that makes a small game feel like a system rather than a checklist, and it explains why the base types exist: antimatter factories draw power from nearby O, B or A class stars, and dilithium factories harvest from the atmospheres of nearby K or M class stars.

## Six damage indicators with four states each

Damage is modelled as six named subsystems, LIF, HUL, SEN, WPN, WRP and IMP, each in one of four states, green, yellow, red and black, where black means the system is entirely non-functional. The consequences are specific rather than a single health bar. LIF covers life support, and the more damaged it is the slower repair operations run. HUL is the hull, repaired first after LIF. SEN covers sensors, and going black means you are blind. WPN degrades your weapons until they misfire and misbehave. IMP covers impulse engines, whose degradation shows up as a tendency for the ship to stall. WRP covers warp engines, whose degradation makes the warp leaps erratic. As long as either LIF or HUL are not black, the other systems are repaired gradually, which the documentation turns into tactical advice: warp away from a bad situation and wait the repairs out. The repair priority is therefore the real health metric, and a green hull with a black sensor is a different emergency from the reverse.

## The Corbomite device gives the game a single finish line

The mission is stated plainly: the Borg have disrupted the antimatter and dilithium transport network, the federation fleet is destroyed, and the Enterprise is the only ship in service. You must reconstitute a network of bases, harvest what you can from crippled Klingon ships, and build The Corbomite Device before the invasion fleet arrives. The structure is a chain: find The Pulsar, build the Corbomite factory there, surround that factory with enough antimatter and dilithium bases so it can manufacture enough Corbomite, and once the factory is filled to capacity it transforms into The Corbomite Device. Docking with the device makes your ship much more capable. Docking in general requires warping close to a base, using impulse to approach as closely as possible, putting the ship on top of the base, and pressing the DOCK button that appears in the Engine Control Panel. Three weapons fill the gap between scouting and the endgame: phasers for short range damage, slow heavy torpedoes, and cheap relativistic kinetics.

## Where to play it and what the repository layout shows

Based on the repository layout, this is a Clojure project with a conventional Clojure structure. There is a deps.edn at the root, a src/ directory for the code, spec/ and spec-property/ directories for specifications, resources/ for assets, and an index.html at the top level that presumably serves the browser build. The presence of both spec/ and spec-property/ is the notable detail: the project keeps example-based specifications and property-based specifications side by side, which fits a codebase whose purpose is to demonstrate disciplined development. There is no package manifest, no Dockerfile, no CI configuration listed at the top level, and no Makefile or build script. That is consistent with a Clojure project run through the standard tooling from deps.edn, but the repository gives no install steps for a local run, no required Clojure version and no entry point namespace, so the only route the project itself offers is the hosted game at cleancoder.com/space-war. The absence of a recorded licence, plus no GitHub releases, also means there is nothing to point at for versioning or reuse terms.

## Conclusion

Space War suits developers who want to read a complete game in Clojure and see how a domain model, a rendering layer and a simulation loop fit together, since the whole thing is playable in a browser and the rule set is documented in detail. It is a poor fit for a production game project, because the documentation explains play and not architecture, and there is no release history or recorded licence to lean on when you need redistribution rights. Before building on it, open the repository and check the src/ and spec/ layout, since the published pages describe rules that the code is free to contradict.

## FAQ

### How do I play Space War?

The current release is played at cleancoder.com/space-war, and the project links an older version hosted by Mike Fikes at spacewar.fikesfarm.com/spacewar.html. The game itself is a browser play with buttons and sliders.

### What is the difference between the STRAT. and TACT. views in Space War?

STRAT. is the strategic view of the whole galaxy and shows Klingons, Romulans, stars, bases, transports and routes, but no weapons or explosions. TACT. shows what is nearby, including all weapons fired by either side, and explosions.

### How do you dock with a base in Space War?

Warp close to the base, use the impulse engines to approach as closely as you can, place the ship on top of the base, and press the DOCK button when it appears in the Engine Control Panel. Docking refuels and restocks the ship.

### What happens when you run low on dilithium in Space War?

Dilithium is the catalyst for the antimatter reaction and is consumed by all operations. When it runs low the core temperature starts to increase, because the reaction becomes less efficient, and a core in the red will blow the ship.

## Sources

- [Issues](https://github.com/unclebob/spacewar/issues)
- [README](https://github.com/unclebob/spacewar/blob/master/README.md)
- [unclebob/spacewar on GitHub](https://github.com/unclebob/spacewar)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/unclebob-spacewar
