Skip to content

feat(battleship): frontend on SDK v2 + vs-bot via gameKit#110

Merged
daniellam258 merged 19 commits into
feat/battleship-commit-revealfrom
feat/battleship-frontend-v2
Jun 29, 2026
Merged

feat(battleship): frontend on SDK v2 + vs-bot via gameKit#110
daniellam258 merged 19 commits into
feat/battleship-commit-revealfrom
feat/battleship-frontend-v2

Conversation

@Aaron1924

@Aaron1924 Aaron1924 commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator

Two stacked changes to Battleship's frontend, both on the SDK battleship.v2 protocol. Base is feat/battleship-commit-reveal (the SDK v2 / PR #106) — merge that first, then this can be rebased onto dev-raid.


Part 1 — Migrate frontend/agent/bench off battleship.v1 (Merkle) → SDK battleship.v2

The SDK now owns the canonical commit-reveal Battleship (single board-hash commit + terminal legal-fleet reveal_board). The frontend still ran its own v1 (Merkle root + per-cell-salt per-shot proofs), so the legal-fleet fix wasn't live and the bench measured v1. This repoints every consumer to the SDK, keeping the existing game design (bot/pvp modes, many games per tunnel with a fresh fleet each game, manual placement, smart bot, resume).

  • Move shapes → v2 (kind): commit{commitment} (raw Uint8Array), shoot{cell}, answer{isHit, next?}, terminal reveal_board{board, salt}. No type:/merkle/proveCell/per-cell-salt anywhere.
  • Single-salt secret: FleetSecret { board, salt, commitment }; salts from crypto.getRandomValues(16).
  • Per-game silent terminal reveal: vs-bot auto-reveals both boards at game end then rematches with a fresh fleet; PvP serializes the two terminal reveals A-then-B so the seats never propose at the same nonce.
  • Migrated: engine/selfPlay.ts, protocol/multiGameBattleship.ts (battleship.multi.v2), agent/games/battleship/kit.ts (battleship.v2), engine/pvpDriver.ts, battleshipResumeAdapter.ts, view.ts+engine/bot.ts (type repoint), useBattleship.ts, useBattleshipPvp.ts.
  • Deleted: protocol/battleship.ts (v1) + engine/merkle.ts (+ tests). loadbench Dockerfile drops the SDK-backed protocol COPY.

Part 2 — Route vs-bot through the gameKit (kit = single bot-move source)

Battleship was the only arena game whose solo/vs-bot UI did not route through its gameKit (every other game does; PvP is bespoke in all of them, incl. blackjack v1 on dev). This unifies it, mirroring Quantum Poker's pokerSelfPlay.ts.

  • kit.BattleshipBot.plan is now the single source of commit/answer/reveal_board/shoot for vs-bot + bench. New games/battleship/battleshipSelfPlay.ts (makeSeatBot / stepBattleshipAuto / stepBattleshipWithHuman / applyHumanShot / isHumanShootTurn / runBattleshipSelfPlayToEnd) is a thin wrapper.
  • Per-seat pipeline flag on the kit bot (default true): the human seat A is built pipeline:false (bare answers → the human fires its own shot); the bot seat B + bench are pipeline:true (folds the return shot for TPS).
  • useBattleship.ts drives via two kit bots (rebuilt each game with the fresh fleet); the human's shot goes through applyHumanShot. Deleted the duplicate engine/selfPlay.ts#nextMove/playToCompletion/DrivenMove.
  • PvP untouched (useBattleshipPvp.ts / engine/pvpDriver.ts have zero production diff) — matches every game's bespoke-PvP convention.

Tests

  • tsc --noEmit green; battleship + gameKit suite passes (38/38 after Part 1; 43/43 after Part 2).
  • Engine tests drive real games via kit bots over a mock multi-game tunnel (balance conservation + decisive 17-hit terminal). Manual two-tab PvP + vs-bot multi-game smoke confirmed.

Out of scope (follow-ups)

  • The Quantum-Poker "auto lane" / persistent bots / human-takeover / Auto-mode window (descoped).
  • Tier-2 ZK legal-placement.

@Aaron1924 Aaron1924 changed the title feat(battleship): migrate frontend to sdk v2 protocol feat(battleship): frontend on SDK v2 + vs-bot via gameKit Jun 28, 2026
…ntend-v2

# Conflicts:
#	frontend/src/agent/gameKit.test.ts
@daniellam258 daniellam258 merged commit 5bd6089 into feat/battleship-commit-reveal Jun 29, 2026
1 check failed
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.

2 participants