Sink Ships – How It Works
This page explains the game systems, AI mode, peer-to-peer play, and spectating. It also outlines current limitations and planned improvements.
Boards & Ships
- Two 10×10 grids: your board and your opponent's.
- Fleet types: Carrier (5), Battleship (4), Cruiser (3), Submarine (3), Destroyer (2).
- Placement rules: no overlap and no touching (including diagonals). Ships can be placed horizontally or vertically.
- Hits and misses are tracked per cell; a ship is sunk when all its cells are hit.
Single-Player AI Mode
- The AI places ships randomly following the no-touch rule.
- You can toggle Reveal AI ships for debugging in the AI tab.
- Manual placement: enable Manual placement, rotate with the Rotate button, clear placements, and Lock placement to preserve your setup across restarts.
- AI turn logic: AI fires at your board after your shot resolves; win/loss messages appear when a fleet is sunk.
Peer-to-Peer (PvP) with Copy/Paste Signaling
We use WebRTC data channels for direct communication without servers. Signaling is done manually by copy/paste:
- Host: Create offer, copy the code, send it to your opponent. Paste their answer to connect.
- Join: Paste the host's offer, create an answer, copy the code, and send it back.
- Once connected, messages are relayed over a reliable data channel. Spectators connect to a separate spectate channel.
Spectating
- Host can create a spectate offer; each spectator provides an answer.
- Spectators receive broadcast updates from both players.
- UI shows both boards for viewers; messages can be relayed to spectators.
Temporary Chat
We provide text inputs and Send buttons on Host, Join, and Spectate views. For test purposes, the Send buttons are currently non-functional (no network calls or UI updates). This allows UI layout validation without backend logic.
Limitations & GitHub Pages Notes
- No centralized matchmaking or TURN server; copy/paste signaling required.
- GitHub Pages can host static assets but cannot run a signaling service; use manual exchange or GitHub Actions to publish builds.
- NATs without public STUN reachability may fail to connect.
Roadmap
- Functional chat with message relay for players and spectators.
- Spectator view enhancements and replay mode.
- SVG ship visuals, animations, and accessibility improvements.
Tip: open this Docs page from the header link in the app.