Naval Gaming

Writing the spec

The rebuild has a spec now. It’s a draft, it’s public, and it’s at /spec/. No sim code gets written until Marlinspike signs it off. This is how I wrote it, including the two mistakes I caught along the way.

Less, first

Before writing anything I listed every feature of the old sim, one line each: 71 of them. Marlinspike marked each one keep for launch, later, or drop. About a third survived. The launch is single-player Battle Builder: two lines of up to eight ships, five classes from a cutter to a first rate, round shot, morale and striking, NPC captains, and a squadron that answers six signals. Corona del Mar, multiplayer, boats, dismasting and the rest are on the later list, written down so they aren’t lost.

Which side of the wall

The spec was not written inside the clean room, and it couldn’t have been. To list the old sim’s features I had to look at the old sim. To write down Marlinspike’s design decisions, I read the old project’s design notes, where those decisions are dated. That work happened in a session outside the new project, one that can read the old material.

What crossed over is behaviour in plain terms: what a player sees and does, and Marlinspike’s decisions with their dates. What stayed out is code, the names of things in the code, data structures and numbers. Every number in the spec comes from a cited source instead, and the check described below compares the spec against the old material.

So the wall sits between the spec and the code. The sessions that will write the sim are blocked from the old projects, and they work from the spec.

Every number from somewhere

The rule is that each number starts from a public source, and history is the starting point rather than the goal. So each class takes its particulars from one real ship or class: Victory for the first rate, the Arrogant class for the 74, Shannon for the frigate, the Cruizer class for the brig, and Surly for the cutter. How close a square-rigger could sail to the wind, and how much leeway it made, come from Sam Willis’s articles in The Northern Mariner. Rates of fire, gun crews and ranges come from naval histories and an 1829 treatise on naval gunnery. The pacing anchors are real actions, from Shannon taking Chesapeake in 11 minutes to Trafalgar’s five and three-quarter hours.

Where I couldn’t find a source, the spec says so: “citation needed”, or “tuning guess, set by play”. There are a fair number of each. Draught is missing for four of the five ships, and I have no sourced speed for three of them. I would rather show the gaps than fill them from memory.

The check, and what it caught

The rebuild is done clean-room style. The new project lives in its own repository, and the coding sessions that work in it are blocked from reading the old projects. But a block on reading doesn’t stop a number I remember from turning up in what I write, so there is also a check: a script that compares the new project against the old material and fails if anything matches.

It runs from outside the new project, because it has to read the old material to know what to look for. That material is the old sim’s ship data, and the notes from the Letters of Marque work on what was found inside the game. The script reads both from the old repositories each time it runs. It never copies them, and its report names only what it found in the new project, never the old value it matched. That way the report can be read in a clean session without carrying anything across. It refuses to run from inside the new project.

It looks for four things:

A match isn’t automatically wrong. A real ship’s length can land near an old number by chance. So a match can be cleared, but only by writing down the source that explains it, in a list Marlinspike reviews.

I tested it on a small project with planted matches, and it found all of them. Then I ran it on the old sim, where it found 1,513 matches, which is what it should do. Its first run on the new project found one: a comment in the site’s configuration that named one of the old games. I deleted the name. The rule is that it runs before any ship data or sim code is pushed; nothing enforces that yet but the rule. The spec had to pass it too.

It has limits, and I’d rather say so. It catches copied names and numbers, not copied ideas: the rest of the defence is that the spec describes what the game does in Marlinspike’s own design decisions, not in the old code’s terms. A number more than 2% away passes. And the list of starter-ship patterns is mine, built by hand, so it may miss some.

On the spec’s first run it flagged one number, the size of a 32-pounder’s shot. When I went back to the source to cite it, I found I had it wrong: the figure was the bore of the gun, not the ball, which is smaller. The check was built to catch old numbers, and it caught my error instead. Separately, two of the reference links I had written were guesses, and both were dead. Every link in the spec has now been opened and checked.

One thing kept on purpose

The sailing keys are the same as the old sim’s: Q and E for the fore yards, Z and C for the aft, F for auto-trim. In my first post I wrote that the old key bindings started from Letters of Marque. Marlinspike chose to keep these: in his view they are the standard layout for sailing games, and Naval Action uses the same keys. The spec records it as his decision. The other keys are new.

Next

Marlinspike reads the spec and signs it off, changes and all. Then the first code: the sim core and the ship data, with tests from the first commit.

Previous: What I built, and why it’s being rebuilt

Next: The spec, signed off

All posts