A Universe from Three Sectors: Recovering TradeWars 2002's Map from Its RNG Seed

influx1 pts0 comments

Recovering the TradeWars 2002 Universe Seed from Three Sectors | Matt Michie Tell me the sector numbers of StarDock, Terra, and Rylos in your TradeWars 2002 game, and I’ll hand you back the entire map. All thousand sectors. Every warp lane between them. The location and class of all three hundred and eighty ports. Not a good guess. The exact map, the same one your BBS generated the night it ran Big Bang.

That shouldn’t be possible. The map felt like the one unknowable thing about the game, the part you spent turns and whole evenings charting by hand. But it was sitting in plain sight the entire time.

This is the same game I’ve been reconstructing from its binaries for the better part of a year. TradeWars 2002, the BBS door I lost too many teenage nights to. That project is what made this one possible, so I’ll start there.

Big Bang

Every TradeWars game began the same way. Before the door ever opened to callers, the sysop ran a program called BIGBANG.EXE. It laid out the universe: picked the special sectors, strung a thousand-odd warp lanes between random sectors, scattered the ports across the map, and wrote the whole thing into the game’s data files. Then the sysop deleted it, or didn’t, and the universe stood frozen until the next re-bang months later.

The map was random because Big Bang seeded a random number generator and let it run. Everyone knew this much: same seed, same universe. The docs said so, and warned sysops to change the seed every re-bang or they’d get the same galaxy back. The seed was a knob you turned at creation. Forward only. Nobody talked about turning it the other way, because turning it the other way looked pointless. The universe was already sitting in the data files. If you wanted to know it, you explored it.

And explore it people did. A whole ecosystem of helper tools grew up to do exactly this. TWX Proxy, the zero-turn-map scripts, the CIM reports: they sat between you and the game, watched the sectors scroll past as you moved, and quietly filed away everything they saw. That was the state of the art for thirty years. To know the map, walk the map. It works, it’s clever, and it completely sidesteps the question I want to ask, which is: where did the seed go?

Where the seed went

When the sysop left it set to randomize, Big Bang didn’t reach for anything exotic. Turbo Pascal’s Randomize reads the DOS clock. The hour, the minute, the second, the hundredths of a second, packed into one 32-bit value. That’s your seed. From there a plain linear congruential generator grinds it forward, one step at a time:

RandSeed := RandSeed * 134775813 + 1<br>Every call to Random turns the crank once and hands back a slice of the result. Pick two sectors to warp together, two turns of the crank. Place a port, another turn. By the time Big Bang finishes it’s cranked a few thousand times, and every one of those cranks was fixed, completely, by where the crank started.

So the universe is a function of one 32-bit number. That part is obvious. The non-obvious part is how little of that number is real. It came from a clock, and a clock only reads so many values: twenty-four hours, sixty minutes, sixty seconds, a hundred hundredths. Multiply it out and you get 8,640,000 possible seeds. Every TradeWars universe ever generated with a randomized seed is one of those 8.64 million. That’s about twenty-three bits. And really it’s fewer, because the DOS clock’s sub-second field is coarser than it looks. It ticks about eighteen times a second, not a hundred, so a lot of those 8.64 million never actually come up.

Call it twenty-odd bits. The whole thousand-sector galaxy fits in a number smaller than a single frame of a JPEG. You can try every possibility faster than you can read this paragraph. The only question is what you check each guess against.

Three sectors is enough

You need something observable. Something Big Bang produced early, that you can read off the map without charting all of it.

The landmark sectors are the place to look. The very first thing Big Bang does, before a single warp lane, is roll for the special sectors: StarDock, Terra, Rylos, and the Ferrengi homeworld. Those are literally the first four numbers it produces. And they’re exactly the sectors a player knows. You dock at StarDock constantly. You find Terra and Rylos early and never forget where they are. They’re the most-remembered coordinates in the game.

They’re also safe to read, because the map is the one thing that never moves. Ports get busted, ships come and go, sectors change hands, mines and beacons get dropped and cleared. But the warp lanes and the port locations are frozen the instant Big Bang finishes. Those landmarks aren’t game state you have to catch in a particular moment. They’re generator output, fixed for the life of the universe.

So the recovery is brute force, nothing subtler. For each of the ~8.64 million clock seeds, run Big Bang’s opening moves and check whether it puts StarDock at 431, Terra at 186,...

sectors bang universe seed game from

Related Articles