Skip to content

Commit fc79be3

Browse files
committed
Sync docs with current implementation
1 parent 402a7e6 commit fc79be3

File tree

5 files changed

+36
-28
lines changed

5 files changed

+36
-28
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ For the comprehensive ruleset detailing movement edge cases, damage tables, and
120120
- [x] **Runtime Payload Validation**: Strict server-side WebSocket payload validation before dispatch.
121121
- [x] **Orbital Bases**: Carrying and emplacing strategic stations during play.
122122
- [ ] **Client-Side Test Coverage**: Browser-facing orchestration, UI, and input flows still need dedicated tests.
123-
- [ ] **Asteroid Map Visuals**: The in-game tactical map should match [docs/map.png](/Users/robertgilks/Source/delta-v/docs/map.png) and visibly render asteroid fields.
123+
- [ ] **Asteroid Map Visuals**: The in-game tactical map should match [docs/map.png](./docs/map.png) and visibly render asteroid fields.
124124
- [ ] **Spectator Mode**: Allowing third-party connections to watch ongoing battles.
125125

126126
---

docs/ARCHITECTURE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Delta-V employs a full-stack TypeScript architecture built around a **shared pur
1010
- **Language**: TypeScript (strict mode) across the entire stack.
1111
- **Frontend**: HTML5 Canvas 2D API for rendering (`client/renderer.ts`), raw DOM/Events for UI and Input. No heavy frameworks (React/Vue/etc.) are used, ensuring maximum performance for the game loop.
1212
- **Backend**: Cloudflare Workers for HTTP routing and Cloudflare Durable Objects for authoritative game state and WebSocket management.
13-
- **Build & Tools**: `esbuild` for lightening-fast client bundling, `wrangler` for local testing and deployment, and `vitest` for unit testing.
13+
- **Build & Tools**: `esbuild` for lightning-fast client bundling, `wrangler` for local testing and deployment, and `vitest` for unit testing.
1414

1515
---
1616

docs/SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Delta-V now has a materially stronger authoritative-server boundary than the ori
99
- WebSocket actions are still resolved server-side against the authoritative game engine.
1010
- Hidden-identity state is filtered per player before broadcast, so the fugitive flag itself is not sent to the opponent.
1111
- Room creation is now authoritative: `/create` initializes the room, locks the scenario up front, and rejects room-code collisions.
12-
- The room creator receives a reserved player token for seat 0, and the copied invite link carries a guest-seat token for seat 1.
12+
- The room creator receives a reserved player token for seat 0, and the copied invite link carries a guest invite token for seat 1.
1313
- Once the guest joins, that invite token is rotated into a private reconnect token for that player.
1414
- Reconnects require the stored player token, which prevents the old "next socket steals the disconnected seat" failure mode.
1515
- Client-to-server WebSocket messages are runtime-validated before any engine handler executes, and malformed payloads are rejected instead of being trusted structurally.

docs/SIMULATION_TESTING.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
# Delta-V Simulation Testing Strategy
22

3-
To ensure game balance, test edge cases, and validate the stability of the Durable Objects backend, we can implement two distinct types of simulation testing: **Headless Engine Simulation (AI vs AI)** and **Network Integration Simulation (PvP Bot Stress Testing)**.
3+
Delta-V now has one established simulation layer and one still-planned layer:
44

5-
Since the core `game-engine.ts` is purely functional and deterministic, creating high-speed simulations is extremely feasible.
5+
- **Headless Engine Simulation (AI vs AI)** is implemented and runs in CI.
6+
- **Network Integration Simulation (PvP Bot Stress Testing)** is still future work.
7+
8+
Since the core `game-engine.ts` is purely functional and deterministic apart from injected RNG, high-speed simulation is practical.
69

710
---
811

912
## 1. Headless Engine Simulation (AI vs AI)
1013

11-
**Goal:** Run thousands of games in seconds to test scenario balance, AI effectiveness, and find crash-inducing edge cases deep in the game tree. (Implemented in `scripts/simulate-ai.ts`).
14+
**Goal:** Run large batches of AI-vs-AI games quickly to test scenario balance, AI effectiveness, and find crash-inducing edge cases deep in the game tree. This is implemented in `scripts/simulate-ai.ts`.
1215

1316
**Approach:**
14-
Create a new Node script (e.g., `scripts/simulate-ai.ts`) that runs outside the browser and the Cloudflare Worker, executing purely in Node.js.
17+
The current runner executes entirely in Node.js, outside the browser and Cloudflare Worker runtime.
1518

1619
1. **Setup:** Initialize `GameState` using `createGame(SCENARIOS[name], map, ...)`.
1720
2. **Game Loop:** Put the engine in a `while (state.phase !== 'gameOver')` loop.
@@ -22,17 +25,22 @@ Create a new Node script (e.g., `scripts/simulate-ai.ts`) that runs outside the
2225
4. **Data Collection:** Track metrics like win rates (Player 0 vs Player 1), average turns to win, fuel consumed, and most common causes of death (combat vs crashes).
2326

2427
**Implementation Details:**
25-
- Because the `game-engine.ts` has no DOM or Canvas dependencies, this can run extraordinarily fast.
28+
- Because the `game-engine.ts` has no DOM or Canvas dependencies, this runs very quickly in practice.
2629
- You can run Monte Carlo simulations (e.g., 10,000 runs of the 'Escape' scenario) to definitively prove if the scenario favors the escaping player or the blockading player.
2730
- **Randomness:** The combat engine relies on `Math.random()`. Passing a seeded random number generator (RNG) into `processCombat` and `processAstrogation` allows for completely reproducible replays when a simulation encounters a crash or an infinite loop.
2831

32+
**Current usage:**
33+
- `npm run simulate` runs 100 headless games of the default scenario.
34+
- `npm run simulate all 100 -- --ci` is the current CI stress pass across all scenarios.
35+
- `--ci` fails the process on engine crashes and prints balance warnings without making them fatal.
36+
2937
---
3038

3139
## 2. Network Integration Simulation (PvP Stress Testing)
3240

3341
**Goal:** Validate the Cloudflare Durable Object lifecycle, WebSocket handling, reconnection logic, and server scaling.
3442

35-
**Approach:**
43+
**Approach (planned):**
3644
Create a headless WebSocket bot client using a library like `ws` in Node.js (e.g., `scripts/load-test.ts`).
3745

3846
1. **Lobby Creation:** The script makes an HTTP POST request to `/create` to get a 5-letter game code.
@@ -48,5 +56,5 @@ Create a headless WebSocket bot client using a library like `ws` in Node.js (e.g
4856
## Summary of Progress
4957

5058
1. **RNG Extraction**: Completed. Engine functions accept optional RNG for deterministic simulations.
51-
2. **AI Runner**: Implemented. `npm run simulate` executes headless matches.
59+
2. **AI Runner**: Implemented. `npm run simulate` executes headless matches, and CI runs the multi-scenario `--ci` pass.
5260
3. **Load Tester**: Planned for future infrastructure stress testing.

docs/SPEC.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static/
4848

4949
**Worker (lobby-worker):**
5050
- `GET /` — Serves the SPA (index.html + bundled JS/CSS)
51-
- `POST /create` — Generates a 5-character invite code plus creator/guest tokens, initializes the Durable Object room, and locks the chosen scenario
51+
- `POST /create` — Generates a 5-character invite code plus a creator reconnect token and a guest invite token, initializes the Durable Object room, and locks the chosen scenario
5252
- `GET /ws/:code` — WebSocket upgrade, proxied to the Durable Object
5353

5454
**Durable Object (game-do):**
@@ -61,7 +61,7 @@ static/
6161

6262
### Invite / Join Flow (No Lobby, No Login)
6363

64-
1. Player 1 clicks "Create Game" → `POST /create` → receives 5-char code plus creator and guest tokens
64+
1. Player 1 clicks "Create Game" → `POST /create` → receives a 5-char code plus a creator reconnect token and a guest invite token
6565
2. UI shows the code prominently + a shareable invite link (`https://delta-v.example.com/?code=K7M2X&playerToken=...`)
6666
3. Player 1 can copy link or share via native Share API
6767
4. Player 2 receives the invite link or an equivalent tokenized join URL
@@ -90,25 +90,24 @@ When a player is planning movement, subtle dot markers or a faint radial guide m
9090
The map represents the inner Solar System along the ecliptic plane:
9191

9292
**Celestial Bodies (with gravity hexes):**
93-
- **Sol** (Sun) — center of map, large body, multiple gravity hexes, any contact = destruction
94-
- **Mercury** — small, 2 bases, gravity hexes
95-
- **Venus** — medium, bases on all 6 sides, gravity hexes
96-
- **Terra** (Earth) — medium, 2 bases, gravity hexes
97-
- **Luna** — small satellite, weak gravity (hollow arrows), 1 base
98-
- **Mars** — medium, 2 bases, gravity hexes
99-
- Has two tiny moons (no gameplay effect in basic scenarios)
100-
- **Jupiter** — large, off-map or map edge, gravity hexes
101-
- **Io** — satellite, weak gravity, 1 base
102-
- **Callisto** — satellite, weak gravity, 1 base
103-
- **Ganymede** — satellite, no base in basic scenarios
104-
- **Ceres** — asteroid, 1 base
105-
- **Asteroid Belt** — scattered asteroid hexes between Mars and Jupiter
93+
- **Sol** (Sun) — center of map, radius-2 body with two full-gravity rings; any contact = destruction
94+
- **Mercury** — single-hex body with one full-gravity ring and 2 base hexes
95+
- **Venus** — radius-1 body with one full-gravity ring and bases on all 6 sides
96+
- **Terra** (Earth) — radius-1 body with one full-gravity ring and bases on all 6 sides
97+
- **Luna** — single-hex moon with one weak-gravity ring and bases on all 6 sides
98+
- **Mars** — single-hex body with one full-gravity ring and bases on all 6 sides
99+
- **Jupiter** — large northern body with two full-gravity rings
100+
- **Io** — single-hex moon with one weak-gravity ring and 1 base
101+
- **Callisto** — single-hex moon with one weak-gravity ring and 1 base
102+
- **Ganymede** — single-hex moon with one weak-gravity ring and no base
103+
- **Ceres** — single-hex asteroid body with 1 base and no gravity
104+
- **Asteroid Belt** — scattered asteroid hexes between the inner planets and Jupiter
106105

107106
**Gravity types:**
108107
- **Full gravity**: mandatory 1-hex deflection toward the body for any object passing through
109-
- **Weak gravity** (Luna, Io): player may choose to use or ignore when passing through a single weak gravity hex. Two consecutive weak gravity hexes = full gravity effect on the second.
108+
- **Weak gravity** (Luna, Io, Callisto, Ganymede): player may choose to use or ignore when passing through a single weak gravity hex. Two consecutive weak gravity hexes = full gravity effect on the second.
110109

111-
**The map data is defined as a static JSON structure** listing every hex with its terrain type (empty, gravity, asteroid, planet surface, base).
110+
**The map data lives in a static TypeScript module** that programmatically builds body surfaces, gravity rings, base hexes, asteroid terrain, and scenario definitions.
112111

113112
### Vector Movement
114113

@@ -790,14 +789,15 @@ interface ScenarioPlayer {
790789
- [x] Server hardening for competitive play (tokenized room access, authenticated reconnect tokens, scenario locking at room creation, and runtime WebSocket payload validation)
791790
- [x] Runtime WebSocket payload validation
792791
- [x] Orbital bases (carrying, emplacing, torpedo launching)
792+
- [x] PWA support (installable shell with offline-capable single-player)
793793
- [ ] Browser-side orchestration and UI test coverage
794+
- [ ] Asteroid map visuals to match `docs/map.png`
794795
- [ ] Advanced features: looting, surrender, rescue, and richer logistics
795796
- [ ] Improved animations (particle effects for thrust, gravity lensing)
796797
- [ ] Turn history replay
797798
- [ ] Spectator mode
798799
- [ ] Game state persistence (resume interrupted games across sessions)
799800
- [ ] Performance optimization for mobile
800-
- [ ] PWA support (installable, offline-capable menu)
801801

802802
## Open Questions
803803

0 commit comments

Comments
 (0)