sim: Pitchwell match foundation (open/seed/T1/HQ) + smoke

This commit is contained in:
Hernâni Marques 2026-09-14 01:24:37 +02:00
parent 7358d1ce1a
commit bd5ade8ec4
No known key found for this signature in database
7 changed files with 708 additions and 41 deletions

View file

@ -1,16 +1,9 @@
#!/usr/bin/env bash
# Headless Pitchwell smoke — no Godot GUI. docs/GAMEPLAY.md: 20 Hz sim, seep +0.4/s.
# Headless Pitchwell smoke — no Godot GUI. Uses game.sim.match (20 Hz).
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
N_TICKS="${1:-40}"
HZ=20
# GAMEPLAY.md Economy: Sump Wells slow seep (+0.4/s while claimed)
SEEP_PER_S=0.4
# GAMEPLAY.md Match open: HQ + 4 workers, 500 Pitch start
START_PITCH=500
DT="$(python3 -c "print(1.0/${HZ})")"
STUB="${ROOT}/assets/cinematics/first-contact/out/first-contact-stub.mp4"
fail() {
@ -18,7 +11,6 @@ fail() {
exit 1
}
# Optional cinematic probe (GAMEPLAY.md: briefings ≥1280×720)
if [[ -f "${STUB}" ]]; then
if command -v ffprobe >/dev/null 2>&1; then
wh="$(ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=p=0 "${STUB}" || true)"
@ -31,44 +23,43 @@ if [[ -f "${STUB}" ]]; then
fi
fi
# Pure-Python 20 Hz tick loop: match open — HQ exists, claimed well seeps Pitch
OUT="$(
N_TICKS="${N_TICKS}" HZ="${HZ}" SEEP_PER_S="${SEEP_PER_S}" START_PITCH="${START_PITCH}" DT="${DT}" python3 - <<'PY'
N_TICKS="${N_TICKS}" python3 - <<'PY'
import os, sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2] if "__file__" in dir() else Path.cwd()
# when stdin script, cwd is ROOT from caller
sys.path.insert(0, str(Path.cwd()))
from game.sim.catalog import FACTION_STAFF, HZ, START_PITCH
from game.sim.match import open_match
n = int(os.environ["N_TICKS"])
hz = int(os.environ["HZ"])
seep = float(os.environ["SEEP_PER_S"])
pitch = float(os.environ["START_PITCH"])
dt = float(os.environ["DT"])
hq_alive = True
well_claimed = True # conceptual: refinery radius holds seep (GAMEPLAY.md)
if n < 1:
print("bad N_TICKS", n, file=sys.stderr)
sys.exit(2)
for t in range(n):
if not hq_alive:
print("HQ dead mid-sim", file=sys.stderr)
sys.exit(1)
if well_claimed:
pitch += seep * dt # +0.4 Pitch/s → +0.02/tick at 20 Hz
# Expect: start 500 + N*(0.4/20)
expect = float(os.environ["START_PITCH"]) + n * (seep / hz)
# float tolerance
if abs(pitch - expect) > 1e-6:
print(f"pitch {pitch} != expect {expect}", file=sys.stderr)
m = open_match()
staff = m.side(FACTION_STAFF)
# claim well via finished font so seep applies (match open alone has neutral well)
r = m.enqueue_building(FACTION_STAFF, "pitch_font", well_index=0)
if r != "ok":
print("enqueue font", r, file=sys.stderr)
sys.exit(1)
if not hq_alive:
# finish 15s build
m.tick_hz(int(15 * HZ) + 1)
if not m.wells[0].claimed:
print("well not claimed", file=sys.stderr)
sys.exit(1)
before = staff.pitch
m.tick_hz(n)
# Staff harvest 0.85 * 0.4/s
expect_gain = n * (0.4 / HZ) * 0.85
got = staff.pitch - before
if abs(got - expect_gain) > 1e-6:
print(f"pitch gain {got} != expect {expect_gain}", file=sys.stderr)
sys.exit(1)
if not staff.hq_alive:
print("HQ missing", file=sys.stderr)
sys.exit(1)
print(f"ticks={n} hz={hz} pitch={pitch:.4f} hq=1 seep={seep}/s")
print(f"ticks={n} hz={HZ} pitch={staff.pitch:.4f} hq=1 gain={got:.4f}")
PY
)" || fail "sim ${OUT}"
)" || fail "sim"
echo "SMOKE PASS headless ${OUT}"
exit 0