Skip to content

Stronger engine: cover rule for the Destroyer hunt, a placer that hides ship by ship, a model of reused fleets - #13

Merged
AdminGodZ merged 7 commits into
mainfrom
t3/improve-battleship-ai
Nov 27, 2026
Merged

AdminGodZ merged 7 commits into
mainfrom
t3/improve-battleship-ai

Conversation

@AdminGodZ

Copy link
Copy Markdown
Owner

What changes

Shooting: the cover rule. A game lasts until the last ship is found, and most games end with a hunt for the Destroyer alone. Finding a two-cell ship is a covering problem, so while no hit is open the engine now prefers cells of a smallest set that touches every place the Destroyer can still be (minimum vertex cover by bipartite matching, ai/cover.rs). Such a cell counts as 10 points likelier to be a hit; the search plays its lines the same way. The bonus is a fixed amount, so a cell that a learned belief makes far likelier is still shot first. The rule also holds under a learned belief.

Placement: hiding ship by ship. The adaptive placer records when the opponent's hunting reaches each cell and places a fleet whose best-hidden ship would be found latest; a bandit chooses between that and the equilibrium mix. The earlier placer stays available as lateness to measure against.

Learning: reused fleets. Per ship, the engine counts where it lay in earlier games and trusts the counts only as far as they predicted the next fleet better than assuming nothing (ai/repeats.rs). The play page starts at a 20% belief, because it offers the player's last fleet again.

Tools. compare A [A2 ...] B measures several shooters against the last one; repeat/repeatN placers; hunt_probe example that logs every decision for the hit-value analysis.

Measurements (all on the 24-core Windows box)

Cover rule, shots saved per game against the same engine without it, same layouts:

Search Placement Saved Games
none random 0.36 ± 0.03 * 100,000
up to 3,000 placements random 0.30 ± 0.04 30,000
up to 30,000 random 0.16 ± 0.04 * 40,000
default random 0.21 ± 0.12 4,000
default random 0.14 ± 0.06 * 12,000
3,000, learning equilibrium mix 0.24 ± 0.10 6,000
3,000, learning equilibrium mix 0.26 ± 0.06 * 20,000
3,000, learning new fleet every 3 games 0.15 ± 0.04 * 12,000

* measured with earlier forms of the rule (only cover cells shot, or their chance doubled). On the same 30,000 layouts the doubling form and the present one differ by 0.002 shots.

Hiding placer, Broadside (3,000 placements) against the density bot with random placement: 82.7% ± 0.4 of games in matches of 100 (earlier placer 64.3%, random placement 50.9%); 67.8% against 58.6% in matches of 10.

Repeat model, shots saved: 4.91 ± 0.09 against a new fleet every 3 games (6.10 with the play page's 20% belief), 0.00 against random placement and the equilibrium mix (−0.06 ± 0.03 with the 20% belief).

Known limits

  • Over matches of 100 against the learning engine itself, the hiding placer wins 48.4% ± 0.7 against the earlier placer (it wins 59.9% over matches of 10). Listed in the roadmap.
  • The README's strength table for the two search rows predates the cover rule; a full rerun is pending. With the rule the default needed 43.96 ± 0.13 over 4,000 games.
  • Weighting hits by ship (+0.07 ± 0.05 on top of the rule) and a cover bonus while finishing a ship (+0.03 ± 0.04) are not adopted; noted in the roadmap.

Checks

cargo fmt --all --check, cargo clippy --all-targets -- -D warnings, cargo test --release (71 tests), cargo test --release -- --ignored, npm run check and npm run build in site/: all pass.

@vercel

vercel Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
broadside Ready Ready Preview Nov 27, 2026 10:15pm UTC

@AdminGodZ
AdminGodZ merged commit d4a8e1e into main Nov 27, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant