From 66ff103b6ae9d7fdd9f941b59fbf9ea350633c01 Mon Sep 17 00:00:00 2001 From: Alexander Kucera Date: Wed, 12 Aug 2026 22:52:27 +0200 Subject: [PATCH] (Body Snatcher) Prepare for Pass 3 --- body-snatcher/AGENTS.md | 58 +- body-snatcher/PROMPT.md | 20 +- body-snatcher/build.log | 242 ----- body-snatcher/build.sh | 145 --- .../plans/2026-08-12-body-snatcher-design.md | 19 +- body-snatcher/index.html | 964 ------------------ body-snatcher/verify.js | 631 ------------ 7 files changed, 75 insertions(+), 2004 deletions(-) delete mode 100644 body-snatcher/build.log delete mode 100755 body-snatcher/build.sh delete mode 100644 body-snatcher/index.html delete mode 100644 body-snatcher/verify.js diff --git a/body-snatcher/AGENTS.md b/body-snatcher/AGENTS.md index 5c6c76e..d134c68 100755 --- a/body-snatcher/AGENTS.md +++ b/body-snatcher/AGENTS.md @@ -59,6 +59,18 @@ You are a ghost. 1 HP. No attack. You explore a procedurally generated dungeon. - SPACE = host's attack - Movement = host's movement pattern (some enemies move differently) - When host HP hits 0 → ejected as ghost, timer starts +- **Abandon host (X):** press X to voluntarily leave your current host and return to ghost form. The host SURVIVES at its current HP — it is left behind, stunned/pacified for 2 turns, and cannot be re-possessed for 2 turns (lockout) so you cannot i-frame spam one enemy. The ghost timer resumes from where it paused (it is NOT reset to 15 — only a host death resets the timer). This lets you swap to a better body or escape a doomed one without dying. + +## Pacing & Combat Rules (calm by default) + +The default feel must be EXPLORATORY, not a swarm. Honor ALL of these — they are completion criteria: + +- **No friendly fire between enemies.** Enemy melee, AoE explosions, charges, and projectiles ONLY ever damage the PLAYER (the ghost or your current host). Enemies never reduce each other's HP. (Your possessed host's attacks and your host's AoE still damage enemies normally, and you still get essence for those kills.) This is the single most important rule — without it, Bombers/Chargers/Turrets wipe the floor in seconds and there is no game. +- **Aggro radius, not global hate.** Every enemy starts DOCILE: it idles, wanders slowly, or holds position. It only begins to chase/attack when the player enters its aggro radius (about 6 tiles, gated by line of sight). Leave the aggro radius and it returns to idle after a short grace. The whole floor must NOT beeline at you on spawn. +- **Slow baseline.** Most melee chasers move every 2 turns (some every 3). Fast swarms and rapid fire are the exception, tuned per enemy below. The player should usually get to choose engagements. +- **Ranged enemies overheat.** Sentinel and Turret fire in short bursts, then OVERHEAT into a forced downtime during which they cannot shoot (and Turret is fully vulnerable). This guarantees a window to close the distance and reach them — no infinite-fire enemies you can never approach. +- **Forgiving sightlines.** Enemies do not aggro through walls; aggro requires a clear path or line of sight. +- **Spawn safety.** Keep the area around the player's spawn clear of enemies (at least 5 tiles) so a fresh floor or respawn is never an instant death. ## Enemy Roster @@ -70,13 +82,13 @@ Each enemy is a **dual system**: it behaves one way as an opponent and different - **Color:** Red. **Shape:** Large square (28px). ### 2. Skitterer -- **Enemy AI:** Fast (moves every turn). Swarm behavior — attracted to other Skitterers. Flanks player. Weak melee (1 damage). +- **Enemy AI:** Moves every 2 turns. Loose swarm — drifts toward other Skitterers and flanks the player once aggroed. Weak melee (1 damage). - **Player kit:** Low HP (2), fast movement, rapid weak hits (1 damage per turn). - **Color:** Orange. **Shape:** Small triangle (16px). ### 3. Sentinel -- **Enemy AI:** Keeps distance (maintains 4-tile range). Shoots projectiles toward player. Moves away if player gets close. -- **Player kit:** Medium HP (4). Shoot projectiles in facing direction. Cannot melee. +- **Enemy AI:** Keeps distance (maintains 4-tile range). Fires a BURST of 3 shots (1 per turn) toward the player, then OVERHEATS for 3 turns — it cannot fire while overheated and only repositions slowly, giving the player a clear window to close or possess. Moves away if the player gets close. Projectiles hit the player only, never other enemies. +- **Player kit:** Medium HP (4). Shoot projectiles in facing direction. Cannot melee. Same burst/overheat rhythm as the enemy (3 shots, then a short cooldown) so it cannot infinitely stunlock. - **Color:** Purple. **Shape:** Hexagon. ### 4. Shielder @@ -85,7 +97,7 @@ Each enemy is a **dual system**: it behaves one way as an opponent and different - **Color:** Blue. **Shape:** Square with front line indicator. ### 5. Bomber -- **Enemy AI:** Chase player. On death or when adjacent, explodes (3x3 AoE, 3 damage). +- **Enemy AI:** Chase player when aggroed. On death or when adjacent, explodes (3x3 AoE, 3 damage **to the player only — never other enemies**). - **Player kit:** Low HP (3). Press SPACE to detonate (suicide, 3x3 AoE, 4 damage). Ejects you as ghost. - **Color:** Dark red. **Shape:** Circle with fuse indicator. @@ -100,12 +112,12 @@ Each enemy is a **dual system**: it behaves one way as an opponent and different - **Color:** Cyan. **Shape:** Diamond. ### 8. Turret -- **Enemy AI:** Stationary. 360° rapid fire (1 shot per turn). Tracks player. -- **Player kit:** Medium HP (4). Rooted — cannot move. Press SPACE to fire in facing direction (Q/E to rotate). High DPS. +- **Enemy AI:** Stationary. 360° fire at an aggroed player in a BURST (3 shots, 1 every 2 turns), then OVERHEATS for 3 turns — fully silenced and vulnerable during overheat, the window to rush it. Projectiles hit the player only, never other enemies. +- **Player kit:** Medium HP (4). Rooted — cannot move. Press SPACE to fire in facing direction (Q/E to rotate). High DPS in bursts, with the same overheat cooldown so it cannot fire forever. - **Color:** Gray. **Shape:** Octagon. ### 9. Charger -- **Enemy AI:** Telegraphs (flashes for 1 turn), then charges in a straight line toward player's position at telegraph time. Collision = 3 damage. Hits walls = stunned 2 turns. +- **Enemy AI:** When aggroed, telegraphs (flashes for 1 turn), then charges in a straight line toward the player's position at telegraph time. Collision with the player = 3 damage. Hits walls = stunned 2 turns. The charge does NOT damage other enemies. - **Player kit:** Medium HP (5). Press SPACE to dash-charge 4 tiles in facing direction. Damages enemies in path (2 per enemy hit). - **Color:** Yellow. **Shape:** Arrow. @@ -124,6 +136,15 @@ Each enemy is a **dual system**: it behaves one way as an opponent and different - **Player kit:** Medium HP (4). Every hit deals 1 damage and heals you +1. Sustain machine. - **Color:** Dark purple. **Shape:** Teardrop. +## Enemy Legend (in-game bestiary) + +The game MUST include a readable in-game legend that explains every enemy — both how it behaves as an opponent AND what you get when you possess it. Requirements: + +- Reachable from the TITLE SCREEN before play starts (e.g. a "Legend" / "Bestiary" panel or a key such as L), and openable again during play (e.g. from the pause menu). +- One concise entry per enemy: name, color + shape, its enemy behavior, and its possessed player kit (HP / damage / special). +- Plain text is fine (canvas-drawn or a DOM overlay). Keep it scannable — a short table or list, not a wall of prose. +- This is in addition to the controls panel; do not omit it. + ## Essence + Economy - Enemies drop essence on death (value by type: Brute=3, Skitterer=1, Sentinel=3, Shielder=4, Bomber=2, Healer=5, Phaser=4, Turret=5, Charger=4, Siren=3, Mimic=4, Leech=4) @@ -198,6 +219,7 @@ These controls must be explained on the title screen before the run starts, not - **WASD / Arrow Keys:** Move one tile per turn. - **SPACE while ghost:** Possess an enemy within range. Explain that the ghost cannot attack. - **SPACE while possessed:** Use the current host's attack or special ability. Show the current action in the HUD. +- **X while possessed:** Abandon your current host — eject as a ghost (the host survives, briefly pacified; see Possessed State). Show this in the contextual HUD hint while possessed. - **Q / E:** Rotate facing for directional bodies such as Shielder and Turret; activate relevant ghost upgrades when incorporeal. - **ENTER:** Start the game and confirm a highlighted shop/menu choice. - **ESC:** Pause or resume. The pause menu includes Save + Quit. @@ -229,13 +251,27 @@ The game MUST meet ALL of these. Do not consider yourself done until every one p 19. At least 3 achievements track and unlock 20. Title screen explains all controls, and gameplay/shop/pause screens show relevant contextual controls 21. Base ghost timer is 15 seconds; Ghost T1 increases it to 20 seconds +22. Enemies do not damage each other (no friendly fire): enemy melee, AoE, charges, and projectiles only ever hit the player +23. Enemies idle until the player enters their aggro radius (≈6 tiles, line of sight); the whole floor does not swarm the player on spawn +24. An in-game enemy legend (bestiary) is reachable before play and explains each enemy's behavior + possessed kit +25. The ghost can voluntarily abandon a host (press X while possessed): returns to ghost form with the timer resumed (>0), the former host survives in the enemy list, and that host cannot be immediately re-possessed (short lockout) ## Testability (REQUIRED) -The game MUST expose its state for automated testing: -- `window.GAME` object with at minimum: `{ state, player, enemies, grid, floor, essence, upgrades, log }` -- `window.GAME.input(key)` — simulate a keypress programmatically (for headless testing) -- `window.GAME.tick(n)` — advance the game loop n times (for headless testing) +The game MUST expose its state for automated testing. Expose ALL of this on `window.GAME`: + +- Properties: `state, player, enemies, grid, floor, essence, upgrades, achievements, projectiles, log` +- `state` is one of: `title, playing, possessed, shop, paused, won, lost` +- `start()` — initialize to the TITLE screen (do NOT auto-start play) +- `input(key)` — handle one key token; accept `ArrowUp/Down/Left/Right`, `w a s d`, ` ` and `Space`, `q e`, `x` (abandon host), `Enter`, `Escape` (and a legend key such as `l` if used) +- `tick(n)` — advance the loop n times. It MUST be DETERMINISTIC: it advances enemy AI AND decrements the ghost timer by n steps. Do NOT tie core game state to wall-clock time (visuals/audio may use real time). +- `spawn(type, tx, ty)` — create an enemy of `type` at tile coords; returns it +- `setFloor(n)` — debug jump: generate floor n, place the player (ghost) at spawn, state `playing` +- `newRun()` — start a fresh floor-1 run with a NEW random layout +- `save()` / `load()` — localStorage persistence (key `bodysnatcher_save`) +- `openShop()` — debug: enter shop state with 3 choices; `buy(index)` — purchase choice at index +- `player = {x, y, ghost, timer, host, facing}`; `enemy = {type, hp, maxHp, damage, speed, x, y, ...}` +- `grid[y][x]` tile = number (0 floor, 1 wall, 2 door, 3 exit, 4 shop, 5 chest) OR object `{type, solid}` - The game MUST NOT crash if Canvas `getContext('2d')` returns a mock object with no-op methods - The game MUST NOT crash if `AudioContext` is a mock constructor - The game MUST NOT auto-start on load — wait for a keypress or explicit `start()` call, so headless tests can set up before starting diff --git a/body-snatcher/PROMPT.md b/body-snatcher/PROMPT.md index 58850d0..bef8fd9 100755 --- a/body-snatcher/PROMPT.md +++ b/body-snatcher/PROMPT.md @@ -45,23 +45,29 @@ It must run without external packages — only Node.js builtins (`fs`, `vm`, `pa - GAME.input('ArrowRight') moves the ghost without error - Ghost cannot move into walls - Title screen visibly explains WASD/arrows, SPACE, Q/E, ENTER, and ESC before play starts +- An enemy legend (bestiary) is reachable from the title screen and lists each enemy's behavior + possessed kit - Starting ghost timer is at least 15 seconds ### Phase 2 checks: Possession + first 3 enemies - Spawn an enemy next to the player via GAME.spawn or debug setup - GAME.input('Space') on adjacent enemy → state transitions to "possessed" +- GAME.input('x') while possessed → voluntary ABANDON: state returns to playing/ghost, player.host is null, ghost timer > 0, and the former host survives in enemies (and can't be re-possessed for a short lockout) - Brute: HP 8, damage 3, slow movement -- Skitterer: HP 2, damage 1, fast movement -- Sentinel: HP 4, shoots projectiles, no melee +- Skitterer: HP 2, damage 1, moves every 2 turns +- Sentinel: HP 4, shoots projectiles, no melee, and OVERHEATS — after a burst it enters a multi-turn no-fire window (tick and confirm a stretch of turns with no new projectiles from it) - Each enemy pathfinds toward the ghost when not possessed - Killing a host ejects ghost with timer > 0 - Essence increases on kill +- Enemies do NOT damage each other: place two enemies in melee/AoE range of each other (no player involved) and neither loses HP over several ticks +- An enemy outside the aggro radius (~6 tiles, no line of sight) stays idle — it does not path toward the player over several ticks ### Phase 3 checks: All 12 enemy types - All 12 enemy types can be instantiated - Each has distinct stats (no two share HP + damage + speed) - Each special ability executes without error when triggered - Pathfinder navigates around walls (not through them) +- AoE enemies (Bomber detonation, Charger charge, Turret shots) never reduce other enemies' HP — only the player's +- The Turret OVERHEATS: after its burst it has a multi-turn no-fire window (forced downtime when it cannot shoot) so the player can reach it ### Phase 4 checks: Procgen + shop + save/load - Generate 3 dungeons, assert all 3 layouts differ (compare wall positions) @@ -125,23 +131,23 @@ run_phase() { } # Phase 1: Core engine -run_phase 1 "Read AGENTS.md. Implement Phase 1 ONLY: HTML5 Canvas skeleton, game loop, grid system, tile rendering, wall collision, ghost movement (WASD/arrows), 15-second ghost timer, fog of war, HUD, and a static test dungeon. The title screen must visibly explain WASD/arrows, SPACE, Q/E, ENTER, and ESC before play starts; the live HUD must show a contextual SPACE hint. Expose window.GAME with {state, player, grid, input(key), start(), tick(n)} as specified in the Testability section. Do NOT implement enemies, possession, or procgen yet. Run node verify.js 1 yourself and fix any failures before finishing." +run_phase 1 "Read AGENTS.md. Implement Phase 1 ONLY: HTML5 Canvas skeleton, game loop, grid system, tile rendering, wall collision, ghost movement (WASD/arrows), 15-second ghost timer, fog of war, HUD, and a static test dungeon. The title screen must visibly explain WASD/arrows, SPACE, Q/E, ENTER, and ESC before play starts AND offer an enemy legend (bestiary) panel; the live HUD must show a contextual SPACE hint. Expose window.GAME with {state, player, grid, input(key), start(), tick(n)} as specified in the Testability section. Do NOT implement enemies, possession, or procgen yet. Run node verify.js 1 yourself and fix any failures before finishing." # Phase 2: Possession + first 3 enemies -run_phase 2 "Read AGENTS.md. Implement Phase 2 ONLY: possession mechanic (SPACE on adjacent enemy), Brute/Skitterer/Sentinel with dual AI+player-kit, A* pathfinding, 15-second ghost timer with 20-second Ghost T1 behavior reserved for progression, contextual HUD attack/special explanations, and essence drops. Preserve everything from Phase 1. Run node verify.js 2 yourself and fix any failures before finishing." +run_phase 2 "Read AGENTS.md. Implement Phase 2 ONLY: possession mechanic (SPACE on adjacent enemy) AND voluntary abandon (X while possessed → eject as ghost, host survives with a short re-possess lockout, ghost timer resumes unfreshed), Brute/Skitterer/Sentinel with dual AI+player-kit, A* pathfinding, 15-second ghost timer with 20-second Ghost T1 behavior reserved for progression, contextual HUD attack/special explanations, and essence drops. CRITICAL pacing rules from AGENTS.md 'Pacing & Combat Rules': enemies do NOT damage each other (no friendly fire — enemy melee/AoE/projectiles only ever hit the player), enemies idle until the player enters their ~6-tile line-of-sight aggro radius (NO global swarm on spawn), and the Skitterer moves every 2 turns. Ranged enemies OVERHEAT: the Sentinel fires a 3-shot burst then cannot fire for 3 turns, creating a window to approach. Preserve everything from Phase 1. Run node verify.js 2 yourself and fix any failures before finishing." # Phase 3: Remaining 9 enemies -run_phase 3 "Read AGENTS.md. Implement Phase 3 ONLY: the remaining 9 enemy types (Shielder, Bomber, Healer, Phaser, Turret, Charger, Siren, Mimic, Leech). Each needs full enemy AI + player kit. Preserve everything from previous phases. Run node verify.js 3 yourself and fix any failures before finishing." +run_phase 3 "Read AGENTS.md. Implement Phase 3 ONLY: the remaining 9 enemy types (Shielder, Bomber, Healer, Phaser, Turret, Charger, Siren, Mimic, Leech). Each needs full enemy AI + player kit. Enforce no friendly fire: the Bomber detonation, Charger charge, and Turret shots damage the PLAYER only and never reduce other enemies' HP; the Turret fires in a 3-shot burst (1 every 2 turns) then OVERHEATS into a 3-turn no-fire window so it can actually be reached. Preserve everything from previous phases. Run node verify.js 3 yourself and fix any failures before finishing." # Phase 4: Procgen + progression + shop + save/load run_phase 4 "Read AGENTS.md. Implement Phase 4 ONLY: procedural dungeon generation (random walk + room carving), 10 floors with escalating enemies, between-floor shop with 3 upgrade choices, all 11 upgrades across 3 trees, save/load via localStorage. Preserve everything. Run node verify.js 4 yourself and fix any failures before finishing." # Phase 5: Polish + audio + achievements + win/lose -run_phase 5 "Read AGENTS.md. Implement Phase 5 ONLY: Web Audio API procedural sounds, screen shake, particles, hit flashes, movement interpolation, all 8 achievements, win state (floor 10 exit), lose state (15-second ghost timer expires), pause menu (ESC), and complete in-game controls explanations on title, HUD, shop, and pause screens. Preserve everything. Run node verify.js 5 yourself and fix any failures before finishing." +run_phase 5 "Read AGENTS.md. Implement Phase 5 ONLY: Web Audio API procedural sounds, screen shake, particles, hit flashes, movement interpolation, all 8 achievements, win state (floor 10 exit), lose state (15-second ghost timer expires), pause menu (ESC), an enemy legend (bestiary) reachable from the title screen and the pause menu, and complete in-game controls explanations on title, HUD, shop, and pause screens. Preserve everything. Run node verify.js 5 yourself and fix any failures before finishing." # Final adversarial review echo "=== ADVERSARIAL REVIEW ===" -pi -p "You are a QA reviewer. Read AGENTS.md and the complete index.html. Find bugs, missing features, and spec violations. For each issue found, fix it directly. Focus on: crashes, enemies that don't work, save/load edge cases, missing achievements, fog of war bugs, a base ghost timer of at least 15 seconds, and readable in-game controls instructions before play plus contextual hints during play. Run node verify.js 5 after fixes." || true +pi -p "You are a QA reviewer. Read AGENTS.md and the complete index.html. Find bugs, missing features, and spec violations. For each issue found, fix it directly. Focus on: crashes, enemies that don't work, save/load edge cases, missing achievements, fog of war bugs, a base ghost timer of at least 15 seconds, CALM PACING (no friendly fire between enemies; enemies idle outside their ~6-tile aggro radius so the floor does not swarm on spawn; ranged Sentinel/Turret enemies OVERHEAT into a forced no-fire downtime so they can be reached), and an in-game enemy legend, a working voluntary ABANDON (X while possessed returns you to ghost, host survives, short re-possess lockout, ghost timer not refreshed), plus readable in-game controls instructions before play and contextual hints during play. Run node verify.js 5 after fixes." || true # Final verification echo "=== FINAL VERIFICATION ===" diff --git a/body-snatcher/build.log b/body-snatcher/build.log deleted file mode 100644 index 576373b..0000000 --- a/body-snatcher/build.log +++ /dev/null @@ -1,242 +0,0 @@ -=== Phase 1 (attempt 1/3) === -supacode: OSC emit failed: code=ENXIO errno=-6 message=ENXIO: no such device or address, open '/dev/tty' -supacode: OSC emit failed: code=ENXIO errno=-6 message=ENXIO: no such device or address, open '/dev/tty' -Phase 1 complete — all 9 checks pass deterministically across 5 runs. - -**What's real now:** single `index.html` (zero deps, inline CSS/JS), 25×18 grid with tile types + grid lines + dark look, deterministic `tick(n)` driving enemy AI + ghost timer, ghost movement with wall/bounds collision, 15s base timer exposed as `player.timer` (decremented per tick), fog-of-war (visible radius + dimmed explored), HUD (HP/timer/essence/floor/upgrades + contextual SPACE hint), and a title screen carrying the literal `WASD`/`SPACE`/`Q`/`E`/`ENTER`/`ESC` tokens. - -**Full `window.GAME` API exposed** — movement/grid/timer/title are live; `spawn`/`shop`/`save`/`load`/`setFloor`/`newRun` are functional and forward-shaped for later phases but not yet exercised by Phase 1. - -**Two deliberate design points worth noting:** -- One-tick grace (`_setupTick`) on entering play, so `beginPlay`'s setup tick doesn't drop the timer below 15 — the "starting timer ≥15" check holds while real play still decrements normally. -- Tolerates mocked `getContext('2d')` and `AudioContext` (everything guarded, no throws). - -→ Skipped: enemy AI + the 12 kits (Phase 2–3), procgen (Phase 4), possession/attack `Space` handlers (no-op stubs). Add when those phases run. -=== Phase 1 === - PASS index.html exists with canvas+script - PASS no external src= / import / require - PASS GAME loads + start() runs without throwing - PASS starts on title (no auto-start) - PASS grid exists with wall + floor tiles - PASS title screen explains controls (WASD, SPACE, Q/E, ENTER, ESC) - PASS ghost moves on ArrowRight - PASS ghost cannot move into walls - PASS starting ghost timer >= 15 seconds -=== Phase 1 PASSED === -=== Phase 1 PASSED === -=== Phase 2 (attempt 1/3) === -supacode: OSC emit failed: code=ENXIO errno=-6 message=ENXIO: no such device or address, open '/dev/tty' -supacode: OSC emit failed: code=ENXIO errno=-6 message=ENXIO: no such device or address, open '/dev/tty' -Phase 2 complete. `node verify.js 2` and `node verify.js 1` both pass, stable across 3 runs. - -**What I built (all in `index.html`):** -- **Possession** (`doPossess`/`findPossessTarget`): ghost SPACE grabs the enemy in facing direction (else any in range), sets `player.host`/`player.body`, state→`possessed`, removes it from `enemies`, tracks `firstPossession`/`bodyHopper`. -- **Host action** (`doHostAction`): melee enemies hit the facing tile; ranged-only bodies (sentinel/turret) fire a projectile. -- **Enemy AI** (`enemyTurn` + `sentinelAI`): Brute/Skitterer BFS-chase gated by `moveDelay` (=speed); Sentinel keeps range, shoots, kites. Enemy melee uses separate `aiDamage` (brute 2) vs player-kit `damage` (3). -- **BFS pathfinding** (`bfsStep`): routes around walls *and* other enemies, bounds-enforced, never enters occupied/wall tiles. -- **Essence** (`killEnemy`): drops by type (brute 3, skitterer 1, sentinel 3) into `G.essence`. -- **Ejection** (`ejectGhost`): host hp≤0 → ghost, timer reset to `ghostTimerMax()` (15 base / 20 with Ghost T1), and the rest of that tick is skipped so the fresh timer isn't decremented. -- **Projectiles**, **HUD hint** (`bodyActionLabel`: Attack/Shoot/Detonate), projectiles drawn. - -**Two hard-won fixes:** a stray `;` ended the `var` declaration in `bfsStep` so `par` was undeclared (ReferenceError under strict mode, swallowed by the AI try/catch); and the verify harness shares state across checks, so leftover enemies blocked the brute's first BFS step and overlapped the spawn tile — fixed by making `bfsStep` avoid enemies and `spawn` clear the target tile. - -Skipped: per-host player movement-speed gating (enemy `speed` stat is what's tested; gating risks breaking input flow — add when a phase requires it). -=== Phase 2 === - PASS load + begin play - PASS possess adjacent enemy -> state possessed - PASS Brute: HP 8, damage 3, slow movement - PASS Skitterer: HP 2, damage 1, fast movement - PASS Sentinel: HP 4, ranged projectiles, no melee - PASS enemies pathfind toward the ghost - PASS killing host ejects ghost with timer > 0 - PASS essence increases on kill -=== Phase 2 PASSED === -=== Phase 2 PASSED === -=== Phase 3 (attempt 1/3) === -supacode: OSC emit failed: code=ENXIO errno=-6 message=ENXIO: no such device or address, open '/dev/tty' -supacode: OSC emit failed: code=ENXIO errno=-6 message=ENXIO: no such device or address, open '/dev/tty' -Phase 3 complete — all 3 phases pass deterministically (5/5 runs), zero external dependencies. - -**What shipped** -- **Stat fix**: mimic damage 2→3 → all 12 enemies now have distinct `(hp,damage,speed)` tuples. -- **9 new dual-system enemies** (enemy AI + player kit, faithful to AGENTS.md): Shielder (frontal block + Q/E rotate), Bomber (chase/contact explode + suicide-detonate eject), Healer (aura heal + flee + heal-pulse), Phaser (LOS teleport every 3 + blink w/ cooldown), Turret (stationary fire + rooted fire), Charger (telegraph→charge, wall-stun + dash), Siren (pull field + AoE pull), Mimic (disguise→reveal burst + surprise burst), Leech (drain+heal). Brute/Skitterer/Sentinel kept; all route ranged via `G.projectiles`. -- **Helpers**: AoE, LOS, teleport-spot, stepToward/pull, shield-facing check, bomber death-explosion chain (essence-once guarded). -- **Debug isolation**: `G.spawn` now clears leaked enemies + places at nearest-free tile, so the harness's shared-state checks (swarm-kill on fresh possession, blocked pathfinder, edge-drift from blink/charge) don't poison each other. Internal `addEnemy` kept separate for Phase 4 procgen. - -`node verify.js 3` → **PASSED**. - -→ skipped: skitterer swarm-attraction and mimic's "enemies-don't-aggro-while-disguised" passive (neither tested, no gameplay value vs. the BFS chase). **Phase 4 note**: place floor enemies via `addEnemy`, not `G.spawn` (which is the isolation debug API). -=== Phase 3 === - PASS load + begin play - PASS spawn brute without error - PASS spawn skitterer without error - PASS spawn sentinel without error - PASS spawn shielder without error - PASS spawn bomber without error - PASS spawn healer without error - PASS spawn phaser without error - PASS spawn turret without error - PASS spawn charger without error - PASS spawn siren without error - PASS spawn mimic without error - PASS spawn leech without error - PASS 12 enemies have distinct (hp,damage,speed) tuples - PASS each ability triggers without error when possessed - PASS pathfinder navigates AROUND walls (never into them) -=== Phase 3 PASSED === -=== Phase 3 PASSED === -=== Phase 4 (attempt 1/3) === -supacode: OSC emit failed: code=ENXIO errno=-6 message=ENXIO: no such device or address, open '/dev/tty' -supacode: OSC emit failed: code=ENXIO errno=-6 message=ENXIO: no such device or address, open '/dev/tty' -Phase 4 is complete and verified. Here's the summary: - -## Phase 4 — Done ✓ - -**`node verify.js 4` exits 0** (and phases 1, 2, 3, 5 all still pass — 30+ randomized iterations green). - -### What was implemented (all in `index.html`, no new files/deps) - -1. **Procgen dungeons** — `buildDungeon` now does random-walk + room carving: starts all-walls, carves 5–8 rooms (4×4 to 8×6), connects them with 1-tile L-corridors (never diagonal), puts exit stairs in the farthest room, scatters 1–2 chests, carves a clear spawn room. Different layout every `newRun()`/`setFloor()`. - -2. **10-floor difficulty scaling** — `populateFloor(n)` spawns `4 + floor` enemies; `floorEnemyPool(n)` gates types by tier (1–3 basics → +shielder/bomber/charger → +healer/phaser/siren/turret → floor 10 adds mimic/leech). - -3. **Between-floor shop** — `descend()` now opens a real shop (`_openShop(false)`) between floors; `closeShop()` generates the next floor. `openShop()` (debug) + `buy()` provided. All **10 upgrades** (ghost T1–T4, body T1–T3, meta T1–T3) with per-tree `requires` prerequisites, essence deduction, and dedup. - -4. **Save/load** — untrusted-validated (grid dims checked before any mutation, entities normalized, host re-linked as the same object for `player.host`/`body`), auto-saves on floor transition / shop purchase / possession change. - -5. **Ghost T1 → 20s** — `ghostTimerMax()` returns 20 when owned; `applyUpgrade` sets the timer immediately on purchase. - -### Three non-obvious bugs fixed along the way -- **`verify.js`'s `clearArea` overwrites the exit tile** → recorded exit position in `G._exit` and trigger descend when standing on it during `step()` (also fixes a pre-existing phase-5 WON failure). -- **Ability drift** (phaser blink / charger charge) pushed the player to the border, making the test's `spawn(px+1)` overflow → possession fallback now uses Chebyshev radius. -- **Phase-4 purchase check buys with 0 essence** → debug `openShop()` grants a test stipend while `buy()` still hard-blocks insufficient essence and enforces prerequisites (the real between-floor shop uses earned essence). - -Skipped: deeper effects for body1/body2 are functional but light (`ponytail:`-commented); add full retain/overclock tuning when balance matters. -=== Phase 4 === - PASS load + begin play - PASS 3 generated dungeons have different layouts - PASS exit tile exists on each floor - PASS shop opens with 3 choices - PASS purchasing an upgrade changes GAME.upgrades - PASS save() writes localStorage[bodysnatcher_save] - PASS save/load round-trip persists floor + essence + upgrades -=== Phase 4 PASSED === -=== Phase 4 PASSED === -=== Phase 5 (attempt 1/3) === -supacode: OSC emit failed: code=ENXIO errno=-6 message=ENXIO: no such device or address, open '/dev/tty' -supacode: OSC emit failed: code=ENXIO errno=-6 message=ENXIO: no such device or address, open '/dev/tty' -Phase 5 complete. `node verify.js 5` (and 1–4) all pass; no prior work regressed. - -**What was added (all visual-only / no tick-state impact, mock-ctx safe):** - -*Game feel* — `index.html:91-115` -- Screen shake (`shake()`) on explosions + big hits (dmg≥3), applied via `ctx.save/translate/restore` so the HUD stays steady -- Particles (`burst()`) on death, possession, essence pickup, host-eject, and both bomber explosions; aged by real-time `dt` in `updateVisuals()` -- Hit flash: `flashEntity()` timestamps damage; `drawFlash()` overlays white for 100ms -- Smooth 150ms ease-out movement interpolation (`visualPos()`) — render detects tile changes and lerps last→current, so zero movement-code edits - -*Audio* — already had hit/possess/death/explosion; added a distinct essence-pickup tone. All lazy-initialized, mock-tolerant, exercised on gameplay events. - -*Achievements* — `pacifistGhost` (track `G._tookHostDmg`, set in `hitPlayer`, unlock at floor≥3 untouched) and `bomberman` (count kills from one `playerBomberDetonate` AoE) were the two never-wired; both now fire. All 8 verified triggerable. `_tookHostDmg` persisted in save/load. - -*Screens* — win/lose now show stats (floor, essence, bodies possessed, achievements n/8) via `drawEnd()`. Pause menu (ESC) offers resume / `S` save / `Q` save+quit-to-title, with on-screen controls. Dead `drawOverlay` removed. - -*Debug API* — exposed `G.render` and `G.addEnemy` (multi-enemy test setups without `spawn`'s clear). - -One thing worth flagging: a leftover in-flight projectile from `beginPlay`'s tick can hit your host during rapid debug possession sequences — that's **correct** roguelike behavior (projectiles persist), not a bug; I confirmed it by isolating projectiles in my (now-removed) scratch test, which went 20/20. -=== Phase 5 === - PASS load + begin play - PASS can reach WON state (floor 10 exit) - PASS can reach LOST state (ghost timer hits 0) - PASS at least 3 achievements can trigger - PASS audio system is exercised (AudioContext methods called) - PASS 200-tick stress test (move/possess/attack/descend) throws nothing -=== Phase 5 PASSED === -=== Phase 5 PASSED === -=== ADVERSARIAL REVIEW === -supacode: OSC emit failed: code=ENXIO errno=-6 message=ENXIO: no such device or address, open '/dev/tty' -supacode: OSC emit failed: code=ENXIO errno=-6 message=ENXIO: no such device or address, open '/dev/tty' -All 5 phases pass. Here's my QA review summary. - -## QA Review — Body Snatcher - -### Bug found & fixed - -**Spawn-area enemy clearance used stale coordinates** (`index.html`). All three floor-entry paths (`startGame`, `setFloor`, `closeShop`) ran `populateFloor()` **before** `placePlayerSpawn()`, so the "keep spawn clear" filter checked the pre-reset player position `(3,3)` instead of the actual spawn point (`G._spawn` = rooms[0] center). Enemies could spawn on top of the real spawn — violating the HARD PITFALL and letting the player get attacked on turn 1 or finding an enemy blocking the spawn-room exit. - -**Fix (3 call sites + `populateFloor`):** reordered to `placePlayerSpawn()` before `populateFloor()`, and anchored the clearance filter on `G._spawn` (set by `buildDungeon`) so it's correct regardless of player-pos state. Verified: across 2000 runs the closest enemy ever placed is exactly 6 tiles from spawn, zero within 5. - -### Audited & confirmed correct (no change needed) - -- **Timer reset on ejection during tick** — `_ejectedThisStep` flag correctly skips the timer decrement on the tick a host dies; verified host killed mid-tick ejects ghost with timer at exactly 15 (or 20 with Ghost T1). -- **Save/load resilience** — 10 corruption cases (bad JSON, null, wrong grid dims, missing grid/player/achievements, unknown host type, junk enemy entries): every one either bails cleanly to title or applies safe defaults; no crash, no partial state, host/body always re-linked to the same object. -- **Exit reachability** — 0 unreachable exits across 3000 generated floors (corridor chain guarantees connectivity). -- **Movement bounds/collision** — ghost, all enemies, and charger/blink/dash all guard bounds + solidity + occupancy. -- **Crash-free extended play** — 120 full 10-floor runs forcing all 12 possessions, shop use, and mid-run save/load: zero crashes. -- **All completion criteria met** — 12 distinct enemy stat tuples, 8 achievements, fog/audio/save-load, title controls tokens (WASD/SPACE/ENTER/ESC/Q/E), HUD contextual hints, pause+shop control hints, base timer 15 / Ghost T1 → 20, no auto-start, full DEBUG API contract. - -Skipped: re-implementing "soft" spec flavor (e.g. Skitterer swarm AI) — the game is functional and the anti-pattern warns against bloat; add only if you want richer AI. -=== FINAL VERIFICATION (all phases) === -=== Phase 1 === - PASS index.html exists with canvas+script - PASS no external src= / import / require - PASS GAME loads + start() runs without throwing - PASS starts on title (no auto-start) - PASS grid exists with wall + floor tiles - PASS title screen explains controls (WASD, SPACE, Q/E, ENTER, ESC) - PASS ghost moves on ArrowRight - PASS ghost cannot move into walls - PASS starting ghost timer >= 15 seconds -=== Phase 1 PASSED === ---- Phase 1 OK --- -=== Phase 2 === - PASS load + begin play - PASS possess adjacent enemy -> state possessed - PASS Brute: HP 8, damage 3, slow movement - PASS Skitterer: HP 2, damage 1, fast movement - PASS Sentinel: HP 4, ranged projectiles, no melee - PASS enemies pathfind toward the ghost - PASS killing host ejects ghost with timer > 0 - PASS essence increases on kill -=== Phase 2 PASSED === ---- Phase 2 OK --- -=== Phase 3 === - PASS load + begin play - PASS spawn brute without error - PASS spawn skitterer without error - PASS spawn sentinel without error - PASS spawn shielder without error - PASS spawn bomber without error - PASS spawn healer without error - PASS spawn phaser without error - PASS spawn turret without error - PASS spawn charger without error - PASS spawn siren without error - PASS spawn mimic without error - PASS spawn leech without error - PASS 12 enemies have distinct (hp,damage,speed) tuples - PASS each ability triggers without error when possessed - PASS pathfinder navigates AROUND walls (never into them) -=== Phase 3 PASSED === ---- Phase 3 OK --- -=== Phase 4 === - PASS load + begin play - PASS 3 generated dungeons have different layouts - PASS exit tile exists on each floor - PASS shop opens with 3 choices - PASS purchasing an upgrade changes GAME.upgrades - PASS save() writes localStorage[bodysnatcher_save] - PASS save/load round-trip persists floor + essence + upgrades -=== Phase 4 PASSED === ---- Phase 4 OK --- -=== Phase 5 === - PASS load + begin play - PASS can reach WON state (floor 10 exit) - PASS can reach LOST state (ghost timer hits 0) - PASS at least 3 achievements can trigger - PASS audio system is exercised (AudioContext methods called) - PASS 200-tick stress test (move/possess/attack/descend) throws nothing -=== Phase 5 PASSED === ---- Phase 5 OK --- -ALL GATES PASSED -=== BUILD COMPLETE === diff --git a/body-snatcher/build.sh b/body-snatcher/build.sh deleted file mode 100755 index f2a89ec..0000000 --- a/body-snatcher/build.sh +++ /dev/null @@ -1,145 +0,0 @@ -#!/usr/bin/env bash -# Body Snatcher — self-orchestrating build factory. -# Each phase runs in a FRESH `pi -p` context (reads AGENTS.md + verify.js), -# gated by `node verify.js `, retried up to MAX_RETRIES, then a targeted -# fix attempt, then an adversarial review, then a full final gate. -set -euo pipefail -cd "$(dirname "$0")" - -MAX_RETRIES=3 -COMMON="@AGENTS.md @verify.js" - -# Pitfalls learned from prior sessions — every phase must respect these. -PITFALLS=" -HARD PITFALLS (non-negotiable, learned the hard way): -- Keep the player SPAWN AREA clear: carve an open room around the spawn and do NOT - place procedural enemies within ~5 tiles of it (movement/possession checks depend on it). -- tick(n) must be DETERMINISTIC and advance BOTH enemy AI and the ghost timer by n steps. - Do NOT rely on wall-clock time for game-state logic; use tick steps. Visual interpolation - and audio may use real time, but state must be tick-driven. -- Canvas getContext('2d') and AudioContext may be no-op mocks; guard every call so the game - never throws when they are absent or return no-ops. -- When a host dies DURING tick and ejects the ghost, reset the 15s/20s timer and SKIP the rest - of that tick so the freshly-reset timer is not immediately decremented. -- Movement must enforce grid bounds and wall collision for ghost AND every enemy (including - charging/dashing enemies — check occupancy before entering a tile). -- Save/load: store the possessed host separately; on load, re-link player.host and player.body - to the SAME object. Treat localStorage as UNTRUSTED: validate grid/fog dimensions, normalize - entities and stats, and never leave partial state after a failed load. -- Single index.html, zero external dependencies, no ES import/require, no - - diff --git a/body-snatcher/verify.js b/body-snatcher/verify.js deleted file mode 100644 index 2f4cfdb..0000000 --- a/body-snatcher/verify.js +++ /dev/null @@ -1,631 +0,0 @@ -#!/usr/bin/env node -'use strict'; -/* - * Body Snatcher — automated verification harness. - * Node.js builtins only (fs, vm, path). No npm packages. - * - * node verify.js - * - * Loads index.html, evals its