← All posts

Blind Salvo, a tactical roguelike built on Battleship

Blind Salvo is a tactical roguelike built on Battleship. You command a salvage fleet across a branching campaign, spend Energy each turn on scans, missiles and warp jumps, and hunt enemy fleets you can't see. I built it alone in Godot 4 and GDScript, about 21,000 lines, for desktop, Android and iOS, with online PvP and in-app purchases.

This post is about the engineering decisions that made a one-person project of that size manageable: keeping the rules separate from everything else, an AI that can't cheat, saves that survive quitting in the middle of a turn, deterministic online play, and tests that play the game for me.

A Blind Salvo battle: your fleet's grid, the enemy sector with hits and misses marked, the Energy bar and weapon buttons, and the combat log.
A battle. Each turn is a budget of Energy spent on scans, shots, salvos and warp jumps against a fleet you can't see.

The rules engine

Everything that decides an outcome lives in one class, Battle, which has no dependency on the UI. The player, the AI and an online opponent all act on it through the same two calls, use_weapon() and end_turn(), so there is exactly one implementation of the rules, and the AI can never take an action the player couldn't.

One rules engine, three drivers The player's controller, the AI and the online opponent all act on the Battle engine through the same two calls, use_weapon and end_turn. The AI reads the board only through AIIntel, which exposes what an attacker could legally know. Battle state is serialized by BattleSnapshot into the save file, and the HUD renders whatever Battle reports. DRIVERS Player BattleController: taps, keys AI HuntTargetAI via AIIntel Online opponent PvpController: relayed actions Battle turns, Energy, weapons, statuses, hazards, passives no UI dependencies BattleHud renders state and effects BattleSnapshot save after every action use_weapon() · end_turn()

Scroll sideways to see the whole diagram.

The player, the AI and the online opponent all go through the same two calls on Battle, so they follow exactly the same rules.

Content is added through small, uniform extension points rather than special cases. A weapon is a subclass that implements three methods: its targeting pattern, which targets are valid, and what happens when it fires. The HUD builds its buttons and hotkeys from the loadout list, so a new weapon needs no UI code. Upgrades, items, hull passives, status effects, hazards, events and boss traits work the same way: add an entry to a library, and the shop, the AI and the save system pick it up. A hull is any set of connected tiles, and rotation and rendering are handled for every shape.

The asset preview scene: ten hull classes in two rows, five straight hulls from the 2-tile Interceptor to the Dreadnought and five shaped hulls including the Lancer, Stinger, Hammerhead, Arrowhead and Carrier, above a row of combat effects for hit, miss, sunk, scan, shield, mine, repair, cache, move and status.
The asset preview: five straight hulls and five shaped ones, all placed, rotated and drawn by the same code from their tile shape, plus the combat effects.
A battle with the Venom status active: the Energy bar shows 4 of 5 with minus 2 from Venom, and the combat log lists a chain of interactions including a jammer, a Gunnery Deck free shot, a shield flare, a Spotter Drone, an EMP charge, a mine and the Stinger's Venom Barbs draining the attacker.
Statuses, hull passives and items interacting in one turn. Every effect goes through the same engine and lands in the combat log, which is also how bugs get traced.

An AI that doesn't cheat

The easiest way to make a Battleship AI good is to let it peek. Blind Salvo's AI never sees ship positions. It reads the board only through AIIntel, a set of read-only helpers that expose what an attacker could legitimately know: its own shots, sunk ships and sensor readings. On top of that, it plays a classic hunt-and-target strategy extended to every ability:

  • While there are unfinished hits, it fires along the line of hits, or at their neighbours.
  • Otherwise it hunts with salvos, barrages and sensor pulses, follows up positive readings, and skips tiles a scan has already proved empty.
  • It uses the same consumable items as the player, and sometimes warps a damaged ship away from a spot you've found.

Because the AI and the player share the rules engine, AI-versus-AI battles run headless as a test. A separate balance report fires every attack at thousands of randomly generated fleets and prints tiles covered and expected hits per Energy, so a new weapon's cost can be set from numbers rather than feel.

Saving in the middle of a turn

Mobile players quit whenever their phone tells them to, so the game saves after every map stop, purchase and battle result, and checkpoints a battle after every action and at the start of every turn. BattleSnapshot serializes both boards, every ship, all shots, hazards and intel, Energy, statuses, items and whose turn it is. Derived values like combat stats aren't stored; they're rebuilt from the run and the encounter exactly as when the battle started, which keeps saves small and stops them drifting from the code. Quitting during the enemy's turn replays that turn from its start, so a player can't use a relaunch to dodge a bad outcome.

Deterministic online play

Online PvP uses lockstep rather than a server simulation. A 283-line Python relay pairs players, by random matchmaking or a friend code, and forwards messages; it never runs game logic. The host rolls a setup (a seed, a hazard and who moves first), and both clients build the same match and run the same Battle from that seed. They exchange only their own fleets and their actions.

Lockstep online play Two clients connect to a small relay server, which pairs them and forwards messages. The host rolls a setup with a seed, a hazard and who moves first. Both clients run the same deterministic Battle from that seed, exchange only their own fleets and actions, and send a checksum of the battle state with every action so a desync is detected. HOST CLIENT Rolls the setup seed, hazard, first move Battle seeded RNG, same code checksum after each action GUEST CLIENT Applies the setup same seed, same boards Battle seeded RNG, same code compares checksums Relay server Python, websockets pairs and forwards only setup · own fleet actions + state checksum

Scroll sideways to see the whole diagram.

Lockstep play. The server never simulates anything; both clients run the same deterministic battle and check each other with a checksum per action.

Lockstep only works if every source of randomness that affects gameplay is seeded and consumed in the same order on both machines. Gameplay draws from a battle RNG derived from the match seed, while cosmetic effects like combat particles use their own RNG, so a particle burst can never shift a gameplay roll. Every action carries a checksum of the battle state, and a mismatch is detected and reported instead of two players silently seeing different games.

The online coin toss: heads Alpha, tails Bravo, the result tails wins, Bravo, and opponent goes first, with a note that the opening player uses Basic Shots only on their first turn.
The shared coin toss. Both clients derive the result from the same seed, so they always agree on who moves first.

The trade-off is that each client has to be trusted. Each one holds both fleets, so a modified client could read the opponent's layout from memory. That's acceptable for friendly matches; ranked play would need an authoritative server that holds the fleets and resolves shots.

One store layer for three platforms

Cosmetic fleet skins are sold through each platform's own store. SkinStore picks one backend at startup behind a single interface: Steam DLC through GodotSteam, Google Play Billing on Android, and StoreKit 2 on iOS, with Restore Purchases where Apple requires it. A plain desktop build has no store and simply hides the buttons. A MockStore backend fakes purchases, failures and cancellations, so the whole purchase flow is tested without a real store. Shipping on iOS meant building the StoreKit 2 plugin from source against the exact Godot version.

The Hangar's Fleet Skins tab with the Astral Survey skin set equipped across the player's fleet.
Fleet skins in the Hangar. Skins only change how ships look, so ownership can be checked on the device without a receipt server.

Tests that play the game

A roguelike has too many paths to check by hand, so most of the testing is scripts that drive the real game:

  • Headless simulations run AI battles, save and load round trips, passives, unlocks, map generation and events.
  • UI scripts walk full flows, at phone and desktop sizes: the tutorial from start to finish, quitting mid-battle and resuming on the same turn, the drydock, the store against the mock backend, and the story beats.
  • For PvP, a local relay and two headless clients play the same room, and their final RESULT lines must match: an end-to-end determinism test.
  • A gallery script screenshots every screen at phone and desktop sizes for visual review.
The deploy screen on desktop: three panels with your fleet grid, the enemy sector and the run log, during the Pulsar Sweep hazard. The same deploy screen on a phone: one grid at a time behind Enemy Sector, Your Fleet and Log tabs, with controls wrapped into rows.
The same deploy screen on desktop and on a phone. Portrait screens switch from three panels to tabs that follow the turn, which is why every UI test runs at both sizes.

Every test runs against separate test data, so it can never touch a real save or profile.

The Act 1 sector map, with branching routes through battles, signals, salvage yards, an elite and a flagship.
The campaign map. Each run's seed picks the map, the upgrade pool and the encounters, which is what makes runs reproducible for daily challenges and for debugging.