A browser-first multiplayer trading and territorial-control game on Cloudflare Workers, a spiritual successor to Diaspora, a game I played as a kid. With AI making coding so fast, I wanted to see how easy it would be to replicate.
I'm still not sharing the code or a link to the game, but there's a trailer now.
Picking it back up
The repo sat from March until October. When I came back to it, the local build
was still serving March's code. Twelve compiled .js files from an old
tsconfig were still sitting next to the .ts sources, gitignored, and Vite
resolves .js before .ts. Nothing the July dependency update changed in the
web client had ever shown up locally. Moving those files out fixed it.
Then the question was who would play it. I don't have players, so I made some.
Nine pilots
Each pilot is Claude Haiku 5.5, called through OpenRouter, with one tool: run a command in the game's CLI as itself. The CLI already covered most of the game (dock, jump, buy, sell, fight), so the agents play through the same API a human client uses. Every tool call also carries one sentence of in-character narration. That's where the trailer's dialogue comes from.
The cast is LEDGER, a careful trader; REDJACK and BLACKFIN, rival pirates; NIGHTJAR, a smuggler; WARRANT, a bounty hunter; MARSHAL, who hunts wanted pilots; MERCY, a relief runner who pleads with every pirate it meets; GILT, a tycoon; and SPROCKET, a rookie who spends a good part of every game asking sector chat for safe routes. A 50-turn game with all nine costs about 40 cents in model calls. The 90-turn game in the trailer cost 82 cents.
The first playtests were mostly the agents tripping over the game:
- The status screen listed every NPC under "Hostiles," neutral traders included, so the pirate attacked one.
- After a jump the drive read "charging (22%)," and the trader spent four turns waiting to arrive somewhere it had already arrived.
- A fight with one NPC took about ten
attackcommands.fightnow fires until something breaks, or breaks off at a hull threshold. - Nobody could find anybody, so PvP never happened.
scannow lists every pilot's sector, hull and credits.
A person would have hit every one of those.
Something worth fighting over
A full hold of cargo earned about what one NPC bounty paid, after six or more jumps, so the trader always came last. Each station now has an industry, plus exports it sells cheap and imports it pays well for. Hearthfire grows food on a volcanic moon and has to ship circuitry in. The Registry Lane shipyard makes circuitry and eats ore and fuel. The Warlord Citadel pays the most for nearly everything. The best runs went from about +30 a unit to +100 or more, and the most profitable ones cross lawless space. Station stock drifts back toward normal now too, so one pilot dumping a hold doesn't ruin a route for the rest of the game.
The pirates still couldn't catch anyone. A target only sits in a sector for a
few seconds between jumps, and one model turn takes about that long. So pirates
can lie in wait now: ambush in a lawless sector, and the next pilot to arrive
in flight takes a free opening shot. Destroying a pilot seizes half
their cargo and costs ten reputation. Anyone below zero shows up as WANTED with
a bounty on them, which gave MARSHAL something to do.
That's the game the trailer comes from. REDJACK and BLACKFIN went after each other early: BLACKFIN destroyed REDJACK's ship three and a half minutes in. About two minutes later REDJACK was back at Drift Crossing, lying in wait, and SPROCKET, freshly repaired at Registry Lane, flew straight into it. BLACKFIN broke off its own ambush to come hunt REDJACK. Thirty seconds after the ambush sprang, REDJACK reported in: "Sprocket is tougher than expected; I'm at 22 hull, so I'm retreating to repair." REDJACK got BLACKFIN back at the seven-minute mark.
The prompts only describe each pilot's role and the rules.
Making the trailer
I started from the music, "Dark Sci-Fi Cyberpunk Trailer" by SigmaMusicArt on Pixabay. Claude can't listen to anything, so it mapped the track's loudness every half second and cut to that map: drums enter at 5.0 s for the first title card, the peak at 32 s for the ambush, near silence at 37 s for the twist, the last hit at 56 s for the title.
The narration is Gemini 3.8 Flash TTS with the gravelly Algenib voice, one call per line. The first mix buried it. Measured, the worst line sat 6.8 dB above the music; after normalizing each line and ducking the music harder, every line is at least 11 dB above it. The star-chart shots replay the recorded game, which the orchestrator snapshots once a second.
The cockpit shots are staged, since the agents never had a screen. A script logs into the real UI as REDJACK and SPROCKET in two browsers and acts out the ambush, with an on-screen cursor for each pilot that moves to every button before clicking it. The same scene recorded at phone size became the side-by-side shot. Staging it also turned up a gap in the game: a pilot under attack had no idea, because only the attacker's side of a fight was stored. The UI now shows an Under attack card with a Fight back button.
The first cockpit shots looked like a debug page, so the HUD now has a painted canopy, targeting brackets, a radar and one instrument cluster instead of scattered readouts. The canopy and about fifty other images come from Gemini's image model.
What's missing
Real accounts, factions, guilds and territorial control. I haven't balanced anything past three playtests either, and trading might pay too well now.
One PvP bug I found writing this up: when a pirate loses a fight it started, the server treats it like losing to an NPC. The pirate's dropped cargo just disappears, and the pilot who won gets nothing.
Why on Workers
Sector state, market state, ship state and encounters all benefit from running close to the player, and Workers + D1 + Durable Objects handles that well. It's also an interesting technical excuse on its own.
And it's easy to ship things to Cloudflare. You can play with them, share them, and ignore them until you're ready to pick them up again.