PlayPendium

Salvo · Food for Thought

Inside Salvo

Beneath the simple act of clicking cells lies a deterministic engine that models hidden fleets, probability-weighted reasoning, and the classic duel of concealment and discovery.3

The Two Boards

At the heart of the game sits a pair of Board objects, one representing your hidden position and the other representing the opponent's hidden position. Each board carries a fleet of ships placed on a ruled grid, but the locations remain concealed from the other side. You fire at the enemy grid while the AI fires at yours, and each shot either strikes a ship or falls into empty water. This dual-board architecture establishes the fundamental information asymmetry of the hidden-fleet duel: each side knows its own board completely, but can only infer the other's configuration from the pattern of its shots.3

The symmetry of this setup is what gives the game its character. Neither side sees the other's ships directly. Instead, both sides must construct a mental model of the hidden grid from the sparse feedback of hits and misses. Every shot becomes data, every hit narrows the possibilities, and every miss eliminates territory from consideration. The engine's game coordinator manages these two boards, ensuring that shots are recorded, that hits are properly attributed, and that the game only ends when one side's entire fleet has been sunk.3

A deterministic model turns blind guessing into informed search.

Random Layout, Deterministic Rules

Before play begins, the engine calls randomFleet to lay out the AI's ships in a randomized fashion. This randomness is not arbitrary; it is seeded, meaning that a given seed value will always produce the same layout. This seeded determinism is a design choice that makes the game reproducible and testable. If you run the game with the same seed, you will get the same ship placements, the same sequence of AI decisions, and the same outcome. This property is valuable for debugging and for understanding how the AI behaves under different conditions.3

Once the fleet is laid out, the rules that govern play are fixed and deterministic. The AI does not roll dice, and the engine does not introduce randomness mid-game. Every decision the AI makes follows from the probability model it maintains, and every shot you fire is recorded and analyzed. The only source of variation is the seed that determines the initial fleet placement. This means that the game is ultimately a puzzle: given the constraints of the rules and the feedback from shots, can you deduce the hidden configuration before the AI deduces yours?3

Firing the Shot

When you fire a shot, the engine records it on the target board and checks whether the shot hit or missed. This is done through the fire function, which updates the state of the board and determines the outcome. A hit marks the cell as occupied by a ship, while a miss marks it as empty water. The engine then checks whether the ship containing that cell has been completely sunk by examining all of its cells. If all cells of a ship have been hit, the ship is sunk, and this information is communicated to both sides.3

The win condition is straightforward but consequential. A side wins when the opponent's ships are all sunk. This is checked through the allSunk function, which examines whether every ship on the opponent's board has been completely hit. The game ends immediately when this condition is met. This all-or-nothing nature of the win condition means that every shot matters, and that the pressure to sink ships quickly is balanced against the need to avoid giving away your own configuration.3

The AI hunts by likelihood and closes by targeting.

The Probability Engine

The opponent in this game is not a simple random shooter. It is a probability-targeting AI that weighs how likely each hidden cell is to contain a ship. The AI maintains a probability model of the enemy grid, updating it as shots are fired and feedback is received. Cells that cannot contain ships due to the placement constraints of remaining ships are marked as unlikely, while cells that must contain ships to accommodate remaining placements are marked as likely. The AI then fires at the cell with the highest probability, turning blind guessing into informed search.3

This probability model is grounded in the mathematics of likelihood, where events are described by numbers between zero and one2. A probability of zero means an event cannot occur, while a probability of one means it must occur. The AI uses these numerical descriptions to guide its shots, favouring cells where the probability of finding a ship is highest. This approach is what distinguishes the AI from a purely random shooter and gives it its characteristic hunting behaviour.

Hunt and Target

The AI's behaviour can be described in two phases: hunt and target. In the hunt phase, the AI searches for ships by firing at cells where undiscovered ships are most likely to sit. This is a broad search that aims to find the first contact with enemy ships. Once a hit is registered, the AI transitions to the target phase, where it focuses on the neighbouring cells of the hit to finish sinking that ship. This two-phase approach mirrors the way human players approach the game: first find the ships, then sink them.3

The transition between hunt and target is determined by whether the last shot was a hit or a miss. If the last shot missed, the AI returns to hunt mode and searches for cells with the highest probability. If the last shot hit, the AI enters target mode and fires at the neighbouring cells of the hit. This simple rule, combined with the probability model, creates a coherent strategy that balances exploration and exploitation. The AI explores the grid to find ships and exploits its knowledge of a hit to sink that ship efficiently.3

Three difficulty strengths tune the AI's behaviour.

Three Strengths

The AI has three difficulty strengths that tune its behaviour. These strengths affect how the AI weighs probabilities and makes decisions. At lower strengths, the AI may make more mistakes or be less aggressive in its targeting. At higher strengths, the AI is more consistent in its probability calculations and more ruthless in its targeting. This variety of strengths allows players to find a challenge level that suits them, from casual play to serious competition.

The exact implementation of these strengths lives in the engine's AI component, the SalvoAI class. The difficulty levels modify how the AI interprets the probability model and how it balances exploration against exploitation. This design allows the AI to be both accessible to casual players and challenging to experienced ones, without changing the fundamental mechanics of the game.3

Sonar Ping

On top of the classic rules sits a twist: the sonar ping. This ability allows a side to reveal a 3×3 readout of the enemy grid at the cost of that turn's shot. The sonar ping reveals whether each cell in the 3×3 area contains a ship or is empty water. This information can be invaluable for narrowing down the location of ships, but it comes at the price of losing your shot for that turn.3

The decision to use the sonar ping is a strategic one. When is the information worth the cost? If you are struggling to find ships, the sonar ping can provide the breakthrough you need. If you are close to sinking a ship, the cost of losing your shot might be too high. The sonar ping adds a layer of resource management to the game, forcing players to weigh the value of information against the value of action.3

Reposition is a one-time defensive option.

Once-Per-Game Reposition

Another twist on the classic rules is the once-per-game reposition. Each side may move one of its own ships once during the game. This defensive dodge does not cost a turn, meaning you can reposition and still fire a shot on your turn. The reposition ability allows you to move a ship out of danger when it is under threat, or to reposition it to a more defensible location.3

The reposition ability is a one-time option, which makes it precious. When should you use it? If a ship is about to be sunk, repositioning can save it. If you are confident in your current position, repositioning might be wasteful. The decision to reposition is a strategic one that requires careful consideration of the current state of the game and the likely actions of your opponent.3

One Shot Per Turn

Underlying all of these mechanics is the classic rule of one shot per turn. Each side fires exactly one shot per turn, alternating back and forth. This rule establishes the rhythm of the game and ensures that both sides have an equal opportunity to act. The one-shot-per-turn rule is what makes the game a duel of wits rather than a race of speed.3

This classic rule is what grounds the game in the tradition of Battleship, a strategy-type guessing game for two players played on ruled grids where each player's fleet is concealed from the opponent1. The one-shot-per-turn rule is what makes the game a test of deduction and probability rather than a test of reflexes. It is a simple rule, but it is one that gives the game its character and its challenge.

Pure determinism makes the game testable.

Seeded Determinism

The engine is pure and seeded-deterministic, driven by its own seeded random-number generator. This means that every aspect of the game is determined by the seed value provided at the start. Given the same seed, the game will always produce the same sequence of events, from the initial fleet placement to the final shot. This property makes the game testable, as the same scenario can be reproduced and examined.3

Seeded determinism also has implications for understanding the game. If you want to understand how the AI behaves in a particular scenario, you can run the game with a specific seed and observe the outcome. If you want to test a particular strategy, you can run the game multiple times with the same seed and see how it performs. This reproducibility is a valuable feature for both players and developers.

Sources & notes

  1. "Battleship (game)," Wikipedia, a strategy-type guessing game for two players, played on ruled grids on which each player's fleet of warships is marked and concealed from the opponent; players alternate calling shots at the other's grid to hit and sink ships, aiming to sink the entire fleet; the game evolved from a pencil-and-paper game dating to around the World War I era; the first commercial version was called Salvo, published by the Starex company in 1931, and in 1967 Milton Bradley published a version using plastic pegboards and miniature ships; and in the "salvo" variant a specified number of squares are targeted at one time, all attacked simultaneously. en.wikipedia.org/wiki/Battleship_(game).
  2. "Probability," Wikipedia, a branch of mathematics concerning numerical descriptions of how likely events are to occur; the probability of an event is a number between 0 and 1, where 0 indicates impossibility and 1 indicates certainty, and the larger the probability the more likely the event (for example, a fair coin flip has probability 0.5 for each outcome). en.wikipedia.org/wiki/Probability.
  3. This game's engine: a Battleship game where each side has a Board with a hidden fleet, the human fires at the enemy fleet and the AI at the human's, one shot per turn (classic rules), fire records a hit or miss, and a side wins when the opponent's ships are all sunk (allSunk); the opponent is a probability-targeting SalvoAI with three difficulty strengths that "hunts" for ships by favouring the cells where an undiscovered ship is most likely to sit and then "targets" the neighbours of a hit to finish it; two twists sit on the classic rules, a sonar ping reveals a 3×3 ship/empty readout but costs that turn's shot, and each side may reposition one of its own ships once per game (a dodge that does not cost the turn); and the engine is pure and seeded-deterministic.
  4. Further reading on Probability, Interpretations of Probability (Stanford Encyclopedia of Philosophy/Winter 2012 Edition). plato.stanford.edu.
  5. Further reading on Probability, Probability -- from Wolfram MathWorld. mathworld.wolfram.com.
  6. Further reading on Probability, Logical foundations and measurement of subjective probability. doi.org.
Was this worth reading?
Play Salvo
PlayPendium · About · Contact · Privacy · Terms · Cookies · Accessibility · Copyright · Browse all games · Classic arcade games · © 2026