(Underdepths) Pass 2
This commit is contained in:
37 files changed
+5590
No files matched your search
Executable
+314
@@ -0,0 +1,314 @@
|
||||
#!/usr/bin/env bash
|
||||
# =============================================================================
|
||||
# Underdepths — self-driving build pipeline.
|
||||
#
|
||||
# Drives the full game build with `pi -p` as the primitive:
|
||||
# .build_state (int = last completed phase) -> resume from next phase
|
||||
# each phase: dispatch build via pi -p -> run gate (tests/smoke.py --phase N)
|
||||
# -> on fail, Ralph loop feeds gate errors back, up to MAX_RETRIES
|
||||
# Phase 2 parallelizes the independent trio (FOV, A*, combat) concurrently.
|
||||
# After phase 4: goal backstop verifies EVERY acceptance criterion in plan.md,
|
||||
# dispatches fixes, loops until all pass.
|
||||
#
|
||||
# Usage: ./orchestrate.sh # resume/advance the build
|
||||
# BUILD_STATE=0 ./orchestrate.sh # override start (still reads file)
|
||||
# PI_MODEL=<id> ./orchestrate.sh # force a worker model
|
||||
# Delete .build_state to start over.
|
||||
# =============================================================================
|
||||
set -uo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")" && pwd)"
|
||||
cd "$ROOT"
|
||||
mkdir -p logs
|
||||
|
||||
MAX_RETRIES="${MAX_RETRIES:-3}"
|
||||
WORKER_TIMEOUT="${WORKER_TIMEOUT:-900}" # seconds per pi -p build call
|
||||
STATE_FILE="$ROOT/.build_state"
|
||||
PI="${PI_BIN:-pi}"
|
||||
PYTHON="${PYTHON_BIN:-python3}"
|
||||
|
||||
state() { cat "$STATE_FILE" 2>/dev/null || echo 0; }
|
||||
set_state() { echo "$1" > "$STATE_FILE"; }
|
||||
STATE="$(state)"
|
||||
[ "$STATE" = "" ] && STATE=0
|
||||
|
||||
# Workers get NO context files (so AGENTS.md cannot trick them into re-orchestrating
|
||||
# or recursing) and no skills/extensions for speed + determinism. They still have
|
||||
# the built-in read/write/edit/bash/grep tools.
|
||||
WORKER_FLAGS=(--no-context-files --no-skills --no-extensions --approve)
|
||||
if [ -n "${PI_MODEL:-}" ]; then WORKER_FLAGS+=(--model "$PI_MODEL"); fi
|
||||
|
||||
log() { printf '\033[1;36m[pipeline]\033[0m %s\n' "$*"; }
|
||||
|
||||
# ---- common worker preamble (the API contract + conventions) -----------------
|
||||
read -r -d '' COMMON <<'EOF' || true
|
||||
You are a BUILD WORKER for "Underdepths", a turn-based roguelike in Python 3.13 + pygame-ce. You execute ONE build task. HARD RULES:
|
||||
1. Implement ONLY the files listed in this task. NEVER create/modify/delete: orchestrate.sh, tests/smoke.py, .build_state, .gitignore, AGENTS.md, plan.md, prompt.md.
|
||||
2. Do NOT run ./orchestrate.sh and do NOT spawn other pi sessions. You are a leaf worker.
|
||||
3. Read tests/smoke.py FIRST. Its top-level docstring is the EXACT, binding API CONTRACT: function signatures, dataclass field names, return types, indexing convention (tiles[y][x], TILE_WALL=0, TILE_FLOOR=1). Your implementation MUST match it precisely or the gate fails.
|
||||
4. Read plan.md for the complete game-design spec of the systems in this task.
|
||||
5. Conventions: @dataclass(slots=True) for all entities and state; every tunable lives in data/constants.py (no magic numbers in logic); type hints on every function signature; the message log (list[str]) is the PRIMARY feedback mechanism — log a human-readable line for every combat event, pickup, equip, level-up, status change, miss, crit, death.
|
||||
6. REAL implementations only. No stubs, no `pass`, no TODO, no NotImplementedError. Every function must actually work.
|
||||
7. After writing code, run the gate command given below yourself and iterate on YOUR files until it exits 0.
|
||||
8. Do NOT add: networking, sprite/tile image assets, music or audio asset files, character creation, crafting, shops, NPC dialogue.
|
||||
9. Headless safety: any pygame use must tolerate SDL_VIDEODRIVER=dummy and SDL_AUDIODRIVER=dummy. Game logic must be drivable without opening a window.
|
||||
Finish by printing a one-line summary of what you built.
|
||||
EOF
|
||||
|
||||
# ---- primitives --------------------------------------------------------------
|
||||
# run_worker <phase> <name> <prompt> -> logs to logs/phaseN_name.log
|
||||
run_worker() {
|
||||
local phase="$1" name="$2" prompt="$3"
|
||||
local logf="logs/phase${phase}_${name}.log"
|
||||
log " build phase $phase / $name (timeout ${WORKER_TIMEOUT}s, log $logf)"
|
||||
timeout "${WORKER_TIMEOUT}" "$PI" "${WORKER_FLAGS[@]}" -p "$prompt" > "$logf" 2>&1
|
||||
local rc=$?
|
||||
if [ $rc -eq 124 ]; then log " build phase $phase / $name TIMED OUT"; fi
|
||||
return $rc
|
||||
}
|
||||
|
||||
gate() { # <phase>
|
||||
log " gate: $PYTHON tests/smoke.py --phase $1"
|
||||
"$PYTHON" tests/smoke.py --phase "$1"
|
||||
}
|
||||
|
||||
# run_phase <phase> <build_fn> <repair_prompt>
|
||||
# build_fn builds; then Ralph loop on gate failure re-runs a repair worker.
|
||||
run_phase() {
|
||||
local phase="$1" build_fn="$2" repair="$3"
|
||||
log "=================== PHASE $phase ==================="
|
||||
"$build_fn" "$phase" || log " (build step returned non-zero; proceeding to gate)"
|
||||
local attempt=0
|
||||
while ! gate "$phase"; do
|
||||
attempt=$((attempt + 1))
|
||||
if [ "$attempt" -gt "$MAX_RETRIES" ]; then
|
||||
log "!! PHASE $phase FAILED after $MAX_RETRIES retries — halting pipeline."
|
||||
return 1
|
||||
fi
|
||||
log " ralph: phase $phase retry $attempt/$MAX_RETRIES (feeding gate errors to worker)"
|
||||
local err; err="$("$PYTHON" tests/smoke.py --phase "$phase" 2>&1 | tail -60)"
|
||||
run_worker "$phase" "repair${attempt}" "$repair
|
||||
|
||||
--- GATE FAILURE (tests/smoke.py --phase $phase), tail of output: ---
|
||||
$err
|
||||
|
||||
Fix ONLY the phase-$phase files so every gate assertion passes. Re-run the gate yourself until exit 0." || true
|
||||
done
|
||||
log "=================== PHASE $phase GATE PASSED ==================="
|
||||
set_state "$phase"
|
||||
STATE="$phase"
|
||||
return 0
|
||||
}
|
||||
|
||||
# ---- phase builders ----------------------------------------------------------
|
||||
build_phase_1() { run_worker 1 foundation "$P1"; }
|
||||
|
||||
build_phase_2() {
|
||||
# FOV / A* / combat are independent pure modules. Run them SEQUENTIALLY
|
||||
# (reliable + debuggable) and skip any whose output file already exists from
|
||||
# a prior partial run. behaviors depends on the trio landing first.
|
||||
[ -f engine/fov.py ] || run_worker 2 fov "$P2_FOV" || true
|
||||
[ -f engine/pathfinding.py ] || run_worker 2 path "$P2_PATH" || true
|
||||
[ -f engine/combat.py ] || run_worker 2 combat "$P2_COMBAT" || true
|
||||
[ -f ai/behaviors.py ] || run_worker 2 behaviors "$P2_BEHAV" || true
|
||||
}
|
||||
|
||||
build_phase_3() { run_worker 3 content "$P3"; }
|
||||
build_phase_4() { run_worker 4 polish "$P4"; }
|
||||
|
||||
# ---- prompts -----------------------------------------------------------------
|
||||
read -r -d '' P1 <<'EOF' || true
|
||||
PHASE 1 — FOUNDATION. Gate: `python3 tests/smoke.py --phase 1` (BSP map generation).
|
||||
|
||||
Create these files (and the empty __init__.py package markers: data/, entities/, engine/, ai/, render/):
|
||||
- data/constants.py: MAP_W=80, MAP_H=50, TILE_WALL=0, TILE_FLOOR=1, SIGHT_RADIUS=8; LEVEL_XP=[0,30,70,140,250,400,600,850,1150,1500]; LEVEL_HP_GAIN=[10,10,10,10,15,15,15,15,20]; LEVEL_POWER_GAIN=[1,1,1,1,2,2,2,2,3]; PLAYER_BASE (hp50,max_hp50,power4,armor0,accuracy5,evasion2,crit_chance0.10,speed1); COLORS dict per plan.md; ROOM_MIN_W=4,ROOM_MIN_H=4,ROOM_MAX_W=10,ROOM_MAX_H=8; BSP splits 5-8; per-floor ENEMY/ITEM spawn ranges per the plan.md table (Floors 0-1:3-4/2-3 ... Floor 9:0 enemies/2 potions).
|
||||
- entities/entity.py: @dataclass(slots=True) Rect(x:int,y:int,w:int,h:int) with read-only .center property -> (x+w//2,y+h//2) and .intersects(other)->bool (true if interiors overlap). @dataclass(slots=True) Entity(x:int,y:int,name:str,glyph:str,color:tuple,blocks:bool=True,is_alive:bool=True).
|
||||
- entities/player.py: Player as @dataclass(slots=True) + make_player(x,y)->Player. Fields per contract: hp,max_hp,power,armor,accuracy,evasion,crit_chance,speed,level(=1),xp(=0),inventory(list),weapon(None),armor_item(None),effects(dict),x,y,name,glyph,color. Methods: total_power()-> power+weapon bonus; total_armor()-> armor+armor_item bonus; gain_xp(amount,log=None) using LEVEL_XP that calls level_up on threshold cross; level_up(log=None) applying LEVEL_HP_GAIN/LEVEL_POWER_GAIN and full heal; equip(item,log=None) for weapon/armor slots returning previous to inventory; heal(amount). Match tests/smoke.py exactly.
|
||||
- entities/enemy.py: Enemy as @dataclass(slots=True) + make_enemy(kind,x,y)->Enemy. Look up stats from data/enemies.ENEMIES if it exists, else an inline fallback dict with all 7 kinds (rat,goblin,skeleton_archer,orc_warrior,wraith,green_slime,ancient_dragon,small_slime) matching plan.md Enemy Roster (rat:hp8,power3,armor0,speed1,wander,xp5; goblin:hp15,power5,armor1,speed1,chase,xp12; skeleton_archer:hp12,power4,ranged_power6,armor1,speed1,ranged,xp15; orc_warrior:hp30,power8,armor3,speed1,flee,xp25; wraith:hp20,power10,armor0,speed2,phase,xp30; green_slime:hp18,power5,armor1,speed1,split,xp18; ancient_dragon:hp120,power15,armor8,speed1,chase,xp200; small_slime:hp9,power3,armor1,speed1,wander,xp6). Enemy fields: x,y,name,glyph,color,kind,hp,max_hp,power,armor,speed,behavior,xp,is_alive(True),last_known_pos(None), plus ranged_power for archer and can_split flag for slime.
|
||||
- engine/map_gen.py: GameMap as @dataclass(slots=True) (width,height,tiles:list[list[int]],rooms:list[Rect],explored:list[list[bool]],visible:list[list[bool]],entities:list,stairs_down:tuple|None,floor_index:int). generate_floor(floor_index=0,width=80,height=50,seed=None)->GameMap: full-wall start; recursive BSP split alternating axis, 5-8 splits; carve a random room (shrink 1-2 from leaf edges, size within ROOM_MIN/MAX) in each leaf; connect sibling leaf rooms with L-shaped corridors (carve floor); place stairs_down in the LAST/farthest room from spawn (None only on floor 9 boss arena). Floor 9: single 20x15 room boss arena, no stairs, two healing potions near entrance. Spawn enemies+items per the constants spawn table scaled by floor_index (use data/enemies + data/items if present, else skip spawning entities — entities list may be empty for phase 1; the gate only checks geometry). is_walkable(gm,x,y)->bool = in-bounds and TILE_FLOOR. seed seeds a local random.Random. tiles indexed tiles[y][x].
|
||||
- main.py: minimal REAL pygame loop: init (respect SDL_VIDEODRIVER=dummy), create window ~ MAP_W*16 x MAP_H*16, generate floor 0, render colored rects per tile, place an Entity player, handle arrows/hjkl to move (basic collision), Esc to quit, and cap framerate. Full menus/audio/save come in phase 4 — keep main.py small but runnable. Must not crash under dummy drivers.
|
||||
|
||||
Run `python3 tests/smoke.py --phase 1` and fix until exit 0.
|
||||
EOF
|
||||
|
||||
read -r -d '' P2_FOV <<'EOF' || true
|
||||
PHASE 2 / FOV — create engine/fov.py ONLY. Gate includes `python3 tests/smoke.py --phase 2`.
|
||||
Implement recursive shadowcasting (8 octants), from scratch, no library. Function EXACTLY:
|
||||
compute_fov(width:int, height:int, tiles, ox:int, oy:int, radius:int=8) -> set[tuple[int,int]]
|
||||
tiles is list[list[int]] indexed tiles[y][x]; wall = (tile == 0). Returns the set of (x,y) visible from origin within radius (Chebyshev/Euclidean within radius). Rules: a tile is visible if an unobstructed line reaches it; walls block sight beyond them; a wall tile is itself visible if adjacent (8-neighbour) to a visible floor tile; the origin tile is always visible. Do not mutate tiles. Pure function, no pygame.
|
||||
Add a small self-check under `if __name__ == '__main__'`. Then run `python3 tests/smoke.py --phase 2` and ensure the FOV assertions pass (it also runs A*/combat/AI which other workers own — those may still fail, that is fine; just ensure FOV passes).
|
||||
EOF
|
||||
|
||||
read -r -d '' P2_PATH <<'EOF' || true
|
||||
PHASE 2 / PATHFINDING — create engine/pathfinding.py ONLY. Gate includes `python3 tests/smoke.py --phase 2`.
|
||||
Implement grid A* with Manhattan heuristic, from scratch. Function EXACTLY:
|
||||
astar(width:int, height:int, tiles, start:tuple, goal:tuple, blocked:frozenset=...) -> list[tuple[int,int]] | None
|
||||
tiles indexed tiles[y][x]; walkable = in-bounds and tile==1 and not in blocked. 4-neighbour moves only. Returns the path from start to goal INCLUSIVE (list of (x,y)), or None if unreachable. Lowest-cost first; ties broken deterministically. No mutation. Pure, no pygame.
|
||||
Self-check under `__main__`. Then run `python3 tests/smoke.py --phase 2` (FOV/combat/AI owned by others may fail — ensure the A* assertions pass).
|
||||
EOF
|
||||
|
||||
read -r -d '' P2_COMBAT <<'EOF' || true
|
||||
PHASE 2 / COMBAT — create engine/combat.py ONLY. Gate includes `python3 tests/smoke.py --phase 2`.
|
||||
Implement melee combat resolution per plan.md. Function EXACTLY:
|
||||
resolve_attack(attacker, defender, log=None) -> dict
|
||||
Read attacker.power, defender.armor, attacker.accuracy, defender.evasion, attacker.crit_chance, attacker.weapon_bonus (getattr default 0). Formulas:
|
||||
hit_chance = clamp(0.7 + (attacker.accuracy - defender.evasion) * 0.05, 0.1, 0.95)
|
||||
on hit: base = attacker.power + weapon_bonus; reduced = max(0, base - defender.armor); is_crit = random() < attacker.crit_chance; damage = reduced * (2 if is_crit else 1); defender.hp -= damage; if defender.hp <= 0: defender.is_alive = False (if it has that attr).
|
||||
on miss: damage = 0.
|
||||
Return {"hit":bool,"crit":bool,"damage":int,"killed":bool}. When log is a list, append human-readable lines (e.g. "X hits Y for N damage!", "Critical hit! ...", "X misses Y"). Pure logic, no pygame. The defender may be any object with hp/armor/evasion/is_alive attrs.
|
||||
Self-check under `__main__`. Then run `python3 tests/smoke.py --phase 2` (ensure the combat assertions pass).
|
||||
EOF
|
||||
|
||||
read -r -d '' P2_BEHAV <<'EOF' || true
|
||||
PHASE 2 / AI — create ai/behaviors.py ONLY. Gate includes `python3 tests/smoke.py --phase 2`.
|
||||
Implement enemy AI dispatch. Function EXACTLY:
|
||||
take_enemy_turn(enemy, game_map, player, enemy_visible:set) -> list[str]
|
||||
game_map has .width,.height,.tiles (tiles[y][x]). player has .x,.y,.hp,.max_hp. enemy_visible is the set of (x,y) tiles the enemy currently sees (caller computes FOV from the enemy). enemy has .behavior,.x,.y,.hp,.max_hp,.power,.armor,.speed,.last_known_pos,.kind,.is_alive.
|
||||
Implement behaviors (one action per call):
|
||||
wander: move 1 tile to a random walkable neighbour or wait (50/50). Never seek player.
|
||||
chase: if player in enemy_visible -> A* (engine.pathfinding.astar) one step toward player; update enemy.last_known_pos to player tile. Adjacent (Chebyshev 1) to player -> melee via engine.combat.resolve_attack(enemy, player). If not visible: move toward last_known_pos; if reached/none -> wander.
|
||||
flee: if enemy.hp < 30% max -> step away from player (maximize Chebyshev distance); else behave as chase.
|
||||
ranged: if player visible and distance>3 -> resolve a ranged attack (use enemy.ranged_power if present else power, with a distance hit penalty) logging "fires at you". If visible and distance<=2 -> step away (kite). Not visible -> wander.
|
||||
phase: move one step toward player IGNORING walls (can occupy wall tiles), but only ACT every 2 turns (track an internal turn counter, e.g. enemy.phase_cooldown or a module-level set; simplest: act when game turn parity matches — but you lack the turn, so use an attribute enemy._phase_toggled). Adjacent -> melee. (Keep it simple and deterministic for the gate: the gate only chases a goblin; phase just must not crash.)
|
||||
split: normal chase/wander; splitting-on-death is handled by the death handler, not here — but if enemy.can_split and it would die, the caller spawns copies. Here just behave as chase.
|
||||
Return list of log strings; mutate enemy/player positions and player.hp as needed. Do not mutate game_map. No pygame.
|
||||
The gate places a goblin at (2,1) and player at (8,1) in a 12x3 corridor with the whole row visible and calls take_enemy_turn once, expecting enemy.x to advance to 3. Make that pass.
|
||||
Self-check under `__main__`, then run `python3 tests/smoke.py --phase 2` and ensure the AI assertion passes.
|
||||
EOF
|
||||
|
||||
read -r -d '' P3 <<'EOF' || true
|
||||
PHASE 3 — CONTENT. Gate: `python3 tests/smoke.py --phase 3` (enemy roster stats, item equip, XP/leveling).
|
||||
|
||||
Create/finalize:
|
||||
- data/enemies.py: ENEMIES: dict[str, dict] with EXACT keys for all 8 kinds (rat,goblin,skeleton_archer,orc_warrior,wraith,green_slime,ancient_dragon,small_slime). Each value dict: hp,power,armor,speed,behavior,xp and for archer ranged_power, for slime can_split=True. Values MUST match plan.md Enemy Roster exactly (rat 8/3/0/1/wander/5; goblin 15/5/1/1/chase/12; skeleton_archer 12/4/1/1/ranged/15 ranged_power6; orc_warrior 30/8/3/1/flee/25; wraith 20/10/0/2/phase/30; green_slime 18/5/1/1/split/18 can_split; ancient_dragon 120/15/8/1/chase/200; small_slime 9/3/1/1/wander/6). Also ENEMY_FLOORS mapping kind->(min_floor,max_floor). make_enemy(kind,x,y) MUST live in entities/enemy.py and read this roster (update entities/enemy.py to import ENEMIES from here; keep the make_enemy signature identical).
|
||||
- data/items.py: ITEMS: dict[str,dict] for the full plan.md catalog (Rusty Dagger power+2; Short Sword power+4; Battle Axe power+7; War Hammer power+10 crit_chance-0.05; Leather Armor armor2; Chain Mail armor4; Plate Armor armor7 evasion-0.10; Healing Potion heal30; Strength Potion +5 power/20 turns; Invisibility Potion invisible/15 turns; Scroll of Fireball 20dmg r3; Scroll of Teleport; Scroll of Mapping). Each entry: category in {weapon,armor,potion,scroll}, stats dict, effect dict. ITEM_BY_FLOOR helper for depth-scaled distribution (better gear deeper; potions/scrolls uniform).
|
||||
- entities/item.py: Item as @dataclass(slots=True) + make_item(name,x,y)->Item reading ITEMS. Fields: name,category,x,y,stats(dict),effect(dict),glyph,color. category EXACTLY one of weapon|armor|potion|scroll.
|
||||
- entities/player.py: ensure make_player + equip/quaff/read methods work against real Items. equip(item): weapon->weapon slot (apply stats.power, crit_chance delta), armor->armor_item slot (apply armor, evasion delta), returning the previous item to inventory. total_power()/total_armor() reflect equipped gear. gain_xp/level_up already from phase 1 — verify level-up fully heals and grants stats from LEVEL_HP_GAIN/LEVEL_POWER_GAIN.
|
||||
- inventory & use: add player methods or a small module for: quaff(potion_idx, log) applying heal / strength(inventory timer effects['strength']=20,power+5) / invisibility(effects['invisibility']=15) and consuming the item; read_scroll(scroll_idx, session_or_target, log) for fireball(AoE 20 dmg radius 3 around player or chosen tile), teleport(random walkable tile on current floor), mapping(set whole floor explored=True). At least 4 distinct effects must function.
|
||||
- spawning: ensure engine/map_gen generate_floor spawns enemies drawn from ENEMIES gated by floor, and items from ITEMS by depth, per the plan.md per-floor tables. Floor 9 = boss arena with the ancient_dragon + 2 healing potions, no other enemies, no stairs.
|
||||
- XP/leveling + death: a helper to apply enemy death (award enemy.xp to player via gain_xp, remove enemy, handle green_slime split into 2 small_slime at adjacent walkable tiles, only if can_split). Player death sets state appropriately if a session is passed (phase 4 owns GameSession; here just ensure hp<=0 path is safe).
|
||||
|
||||
Run `python3 tests/smoke.py --phase 3` and fix until exit 0. Do not break phases 1-2 gates (re-run --phase 1 and --phase 2 to be safe).
|
||||
EOF
|
||||
|
||||
read -r -d '' P4 <<'EOF' || true
|
||||
PHASE 4 — POLISH, AUDIO, PERSIST. Gate: `python3 tests/smoke.py --phase 4` (save/load round-trip, menus/actions, pickup, descent, audio safety).
|
||||
|
||||
Build the game shell that ties every system together:
|
||||
- engine/game_state.py: GameSession as @dataclass(slots=True) — the SINGLE source of truth. Fields: player, dungeon (list[GameMap], all 10 floors), current_floor, log (list[str], cap 50), turn, state (one of menu|playing|dead|victory|saved), plus rng seed. Functions:
|
||||
new_game(seed=None)->GameSession : generate all 10 floors, spawn player at floor 0 first room center, state='playing'.
|
||||
apply_action(session, action)->result : action is a tuple; implement ('move',dx,dy) [walk into floor / attack adjacent enemy via engine.combat / blocked], ('pickup',) [move item under player into inventory, log "You pick up X"], ('descend',) [only if standing on stairs_down of current floor; current_floor+=1; reposition player; log], ('save',) [serialize + state='saved'], ('quaff',idx), ('read',idx), ('equip',idx), ('wait',) [turn+=1]. After each player action, run all live enemies on the current floor via ai.behaviors.take_enemy_turn (compute each enemy's FOV with engine.fov.compute_fov from the enemy position, treating the player as invisible if player.effects has 'invisibility'), then update player.visibility/explored with compute_fov from the player, then check death (player.hp<=0 -> state='dead') and victory (ancient_dragon dead on floor 9 -> state='victory'). Return a result dict if useful.
|
||||
to_dict(session)->dict, from_dict(d)->GameSession (JSON-safe; convert tuples/sets; DO persist effects timers; recompute visible on load, do not persist visible grids), save(session,path), load(path)->GameSession.
|
||||
- engine/serializers.py: thin JSON helpers used by game_state (or fold into game_state — your call, but keep the plan's module intent).
|
||||
- engine/audio.py: AudioEngine class. __init__ tries pygame.mixer.init() inside try/except; on any failure set self.enabled=False and continue. Pre-generate a few short tones in memory with stdlib `array` + pygame.sndarray / numpy-free buffers (hit, miss, damage, pickup, stairs, levelup, death, victory) — if a tone fails to build, skip it silently. play(name): no-op if not enabled or muted. toggle_mute(). Has .enabled attr. MUST NEVER raise. Must construct cleanly under SDL_AUDIODRIVER=dummy with mixer unavailable.
|
||||
- render/renderer.py + render/camera.py: draw the map (colored 16x16 rects per plan.md colors), entities, and UI panels (top bar: Floor N/10, HP bar, Level, XP bar; right panel: last ~8 log lines color-coded; bottom: equipment + sound state). Camera follows player, viewport ~50x30 tiles. Context prompt: when player stands on an item show "Press G to pick up <name>"; on stairs show "Press > (Shift+.) to descend".
|
||||
- main.py (rewrite to full game): main menu (New Game / Continue [only if save.json exists] / How to Play / Quit) with mouse or keyboard selection; New Game shows How to Play before the first turn; '?' reopens How to Play during play; 'g' pickup, '>' (Shift+.) descend on stairs, 'i' inventory, 'e' equipment, 'q' quaff, 'r' read scroll, 'S' save+quit, 'm' mute, Esc close menus. Death screen ("You died on floor N. You reached level M.") deletes save.json then returns to menu on keypress. Victory screen ("You slew the Ancient Dragon! You conquered Underdepths.") likewise. Map keys to the apply_action tuples. Headless-safe: must init and run under SDL_VIDEODRIVER=dummy / SDL_AUDIODRIVER=dummy without crashing; respect an Env where the display is dummy.
|
||||
|
||||
Run `python3 tests/smoke.py --phase 4` AND `python3 tests/smoke.py --phase all` and fix until exit 0. Re-run phases 1-3 gates to ensure nothing regressed.
|
||||
EOF
|
||||
|
||||
read -r -d '' GOAL <<'EOF' || true
|
||||
GOAL BACKSTOP — verify EVERY acceptance criterion in plan.md ("Acceptance Criteria" section: Floor must-haves, Systems Depth, Video Requirements) and fix any failure.
|
||||
|
||||
Do this:
|
||||
1. Read plan.md, focus on the "Acceptance Criteria" checkboxes.
|
||||
2. Run, and read the output of:
|
||||
python3 tests/smoke.py --phase all
|
||||
python3 tests/smoke.py --phase play
|
||||
SDL_VIDEODRIVER=dummy SDL_AUDIODRIVER=dummy timeout 6 python3 main.py (expect it to RUN without a Python traceback; timeout-kill is success)
|
||||
3. For EACH acceptance criterion, decide PASS/FAIL with one line of evidence.
|
||||
4. For any FAIL, edit the relevant source files to fix it. You may touch any game file EXCEPT orchestrate.sh, tests/smoke.py, .build_state, AGENTS.md, plan.md, prompt.md.
|
||||
5. Re-run the three commands above until: smoke --phase all exits 0, smoke --phase play exits 0, and main.py launches headless without a traceback.
|
||||
6. Print a final checklist mapping every acceptance criterion to PASS/FAIL.
|
||||
|
||||
Focus areas judges check: A* pathfinding visibly routes enemies around walls; recursive-shadowcasting FOV limits sight and remembers explored tiles darker; BSP floors differ each playthrough; >=4 distinct AI behaviors (wander/chase/ranged/phase, +split +boss breath); combat hit/damage/crit/armor messages; XP+levelup+full heal; pickup+equip+quaff+read with >=4 effects; S saves and Continue restores exact state; the automated g-pickup and >-descent input tests pass; generated audio needs no asset files, mute works, forced mixer failure does not crash; clear How to Play + contextual pickup/stairs prompts; win state (kill dragon floor 10) and lose state (death -> game over, save deleted).
|
||||
EOF
|
||||
|
||||
# ---- goal backstop loop ------------------------------------------------------
|
||||
run_goal_backstop() {
|
||||
log "=================== GOAL BACKSTOP ==================="
|
||||
local attempt=0
|
||||
while :; do
|
||||
# quick evidence gather
|
||||
local all_ok play_ok launch_ok
|
||||
"$PYTHON" tests/smoke.py --phase all > logs/goal_all.log 2>&1 && all_ok=1 || all_ok=0
|
||||
"$PYTHON" tests/smoke.py --phase play > logs/goal_play.log 2>&1 && play_ok=1 || play_ok=0
|
||||
SDL_VIDEODRIVER=dummy SDL_AUDIODRIVER=dummy timeout 6 "$PYTHON" main.py > logs/goal_launch.log 2>&1
|
||||
launch_ok=1
|
||||
grep -qiE "traceback|error|exception" logs/goal_launch.log && launch_ok=0 || true
|
||||
log " evidence: smoke --all=$all_ok --play=$play_ok headless-launch=$launch_ok"
|
||||
|
||||
if [ "$all_ok" = 1 ] && [ "$play_ok" = 1 ] && [ "$launch_ok" = 1 ]; then
|
||||
log "=================== ALL ACCEPTANCE GATES GREEN ==================="
|
||||
set_state 5
|
||||
return 0
|
||||
fi
|
||||
attempt=$((attempt + 1))
|
||||
if [ "$attempt" -gt "$MAX_RETRIES" ]; then
|
||||
log "!! GOAL BACKSTOP exhausted $MAX_RETRIES retries. Inspect logs/goal_*.log and phase logs."
|
||||
return 1
|
||||
fi
|
||||
log " goal: retry $attempt/$MAX_RETRIES — dispatching fix worker"
|
||||
local evidence
|
||||
evidence="$(printf '== smoke --phase all (tail) ==\n'; tail -30 logs/goal_all.log;
|
||||
printf '\n== smoke --phase play (tail) ==\n'; tail -20 logs/goal_play.log;
|
||||
printf '\n== headless launch (tail) ==\n'; tail -20 logs/goal_launch.log)"
|
||||
run_worker 5 "goalrepair${attempt}" "$GOAL
|
||||
|
||||
--- CURRENT EVIDENCE (auto-gathered) ---
|
||||
$evidence
|
||||
|
||||
Fix the failing acceptance criteria now. Then re-run the three evidence commands yourself." || true
|
||||
done
|
||||
}
|
||||
|
||||
# ---- main driver -------------------------------------------------------------
|
||||
# STOP_AFTER=<N> caps the highest phase this run will attempt (1..4, or 5 for the
|
||||
# goal backstop). Defaults to running everything. .build_state still advances,
|
||||
# so re-running without STOP_AFTER resumes from where this run stopped.
|
||||
main() {
|
||||
local stop="${STOP_AFTER:-5}"
|
||||
log "Underdepths pipeline — start state = $STATE stop_after = $stop (pi=$PI python=$PYTHON)"
|
||||
|
||||
local repair
|
||||
if [ "$STATE" -lt 1 ] && [ 1 -le "$stop" ]; then
|
||||
repair="$COMMON
|
||||
|
||||
$P1"
|
||||
run_phase 1 build_phase_1 "$repair" || exit 1
|
||||
fi
|
||||
if [ "$STATE" -lt 2 ] && [ 2 -le "$stop" ]; then
|
||||
repair="$COMMON
|
||||
|
||||
$P2_BEHAV
|
||||
|
||||
(Phase 2 also includes engine/fov.py, engine/pathfinding.py, engine/combat.py — repair any of those four files as needed.)"
|
||||
run_phase 2 build_phase_2 "$repair" || exit 1
|
||||
fi
|
||||
if [ "$STATE" -lt 3 ] && [ 3 -le "$stop" ]; then
|
||||
repair="$COMMON
|
||||
|
||||
$P3"
|
||||
run_phase 3 build_phase_3 "$repair" || exit 1
|
||||
fi
|
||||
if [ "$STATE" -lt 4 ] && [ 4 -le "$stop" ]; then
|
||||
repair="$COMMON
|
||||
|
||||
$P4"
|
||||
run_phase 4 build_phase_4 "$repair" || exit 1
|
||||
fi
|
||||
if [ "$STATE" -lt 5 ] && [ 5 -le "$stop" ]; then
|
||||
run_goal_backstop || exit 1
|
||||
fi
|
||||
|
||||
if [ "$(state)" -ge 5 ]; then
|
||||
log "=================== BUILD COMPLETE (state=5) ==================="
|
||||
log "Play it: python3 main.py"
|
||||
log "Test it: python3 tests/smoke.py --phase all"
|
||||
else
|
||||
log "=================== STOPPED at state=$(state) (STOP_AFTER=$stop) ==================="
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
main "$@"
|
||||
Reference in new issue
Block a user