Skip to content

Add synchronized two-player Battleship #19

Description

@ap0ught

Feature

Add synchronized two-player Battleship for the paired ESP32-2432S028 CYDs.

Gameplay

  • Each player privately places a fleet on their own grid.
  • After both fleets are committed, players alternate firing at coordinates on the opponent’s grid.
  • The defending device validates each shot against its private fleet and returns miss, hit, or sunk.
  • A player wins after every opposing ship is confirmed sunk.
  • Do not declare victory until the complete fleet state and final shot are validated.

Board modes

  • Classic 10×10.
  • Compact 8×8.
  • Quick 6×6.
  • Fleet composition must scale appropriately for each board size.

Placement rules

  • Ships are straight, contiguous, in bounds, and non-overlapping.
  • Support touch placement, rotation, movement, and a final ready/commit action.
  • Keep uncommitted placement editable.
  • Do not reveal ship locations through the opponent’s normal UI or protocol responses.

Turn and shot rules

  • Enforce authenticated turn ownership.
  • Reject repeated, out-of-bounds, stale, and out-of-turn shots.
  • Track misses, hits, sunk ships, remaining fleet, and match completion deterministically.
  • Optional future modes such as Salvo or Sonar must not alter classic rules by default.

Synchronization and privacy

  • Use fixed encrypted ESP-NOW peers, authenticated sender identity, active-game epochs, replay rejection, ACK/retry, and deterministic reconciliation.
  • Prefer each board remaining authoritative for its own private fleet rather than synchronizing plaintext fleet positions to the opponent.
  • Design restart recovery without revealing hidden placement.
  • Document the trusted-device threat model: modified firmware or physical extraction from a paired board is outside ordinary UI secrecy guarantees.
  • Define deterministic handling for simultaneous events, disconnects, and restart during placement or combat.

Navigation

  • Both boards provide an EXIT control during placement, combat, and results.
  • Either player may return both devices to the shared Home selector.
  • EXIT dominates shots and placement commits, retries after packet/ACK loss, and cannot be undone by stale packets.

Acceptance criteria

  • Fleet placement validation covers bounds, orientation, overlap, and fleet composition.
  • Hidden fleets are not exposed to the opponent’s standard UI or routine shot messages.
  • Turn ownership, shots, hit/miss/sunk responses, and victory are deterministic.
  • All three board sizes remain readable and touchable on the 320×240 display.
  • Restart and reconciliation preserve privacy or fail closed.
  • EXIT works from either board in every phase.
  • Pure rules pass strict host compilation with -std=c++17 -Wall -Wextra -Werror.
  • Encrypted PlatformIO firmware builds successfully.
  • Both CYDs are flashed and physically verified through placement, combat, sinking, victory, restart, and bilateral EXIT.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions