97 lines
3.5 KiB
Bash
Executable file
97 lines
3.5 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# p2-72 Option B — Drive the Claude-vs-AI render proof scene on apricot
|
|
# and fetch the resulting demo-run directory back to plum.
|
|
#
|
|
# Spawns flatpak Godot headless with the claude_vs_ai_render_proof scene.
|
|
# The scene runs CP_TURNS turns of Claude-vs-AI gameplay, writes per-turn
|
|
# screenshots + a transcript + a recap markdown into the CP_OUTPUT_DIR
|
|
# (default `user://demo-runs/p2-72-option-b`), then quits.
|
|
#
|
|
# Run on apricot (via apricot-run.sh or direct ssh) AFTER `build-gdext.sh`
|
|
# has produced a fresh .so on the apricot worktree.
|
|
#
|
|
# Env vars (forwarded into the sandbox):
|
|
# CP_SEED (default 42)
|
|
# CP_PLAYERS (default 3)
|
|
# CP_CLAUDE_SLOT (default 0)
|
|
# CP_MAP_SIZE (default duel)
|
|
# CP_TURNS (default 25)
|
|
# CP_SCREENSHOT_EVERY (default 1)
|
|
# CP_OUTPUT_DIR (default "user://demo-runs/p2-72-option-b")
|
|
# CP_HOST_OUTPUT (default ".local/demo-runs/2026-05-12-phase13-screenshots")
|
|
# relative to PROJECT_DIR — final landing spot for
|
|
# copied screenshots after the run.
|
|
#
|
|
# Exit 0 on PROOF_DONE marker present; non-zero otherwise.
|
|
|
|
set -uo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
|
|
|
: "${CP_SEED:=42}"
|
|
: "${CP_PLAYERS:=3}"
|
|
: "${CP_CLAUDE_SLOT:=0}"
|
|
: "${CP_MAP_SIZE:=duel}"
|
|
: "${CP_TURNS:=25}"
|
|
: "${CP_SCREENSHOT_EVERY:=1}"
|
|
: "${CP_OUTPUT_DIR:=user://demo-runs/p2-72-option-b}"
|
|
: "${CP_HOST_OUTPUT:=.local/demo-runs/2026-05-12-phase13-screenshots}"
|
|
: "${CP_TIMEOUT_SEC:=600}"
|
|
|
|
LOG_FILE="${LOG_FILE:-/tmp/p2-72-option-b-render.log}"
|
|
|
|
# Flatpak sandbox layout — `user://` resolves here.
|
|
GODOT_USERDATA="$HOME/.var/app/org.godotengine.Godot/data/godot/app_userdata/Magic Civilization"
|
|
|
|
echo "=== p2-72 Option B render proof ==="
|
|
echo "Seed=$CP_SEED Players=$CP_PLAYERS Map=$CP_MAP_SIZE Turns=$CP_TURNS"
|
|
echo "Output (in sandbox): $CP_OUTPUT_DIR"
|
|
echo "Log: $LOG_FILE"
|
|
|
|
# Pure-headless — no Wayland (renderer draws into the headless framebuffer,
|
|
# Image.save_png reads from get_viewport().get_texture()).
|
|
timeout "$CP_TIMEOUT_SEC" flatpak run --user \
|
|
--env=CP_SEED="$CP_SEED" \
|
|
--env=CP_PLAYERS="$CP_PLAYERS" \
|
|
--env=CP_CLAUDE_SLOT="$CP_CLAUDE_SLOT" \
|
|
--env=CP_MAP_SIZE="$CP_MAP_SIZE" \
|
|
--env=CP_TURNS="$CP_TURNS" \
|
|
--env=CP_SCREENSHOT_EVERY="$CP_SCREENSHOT_EVERY" \
|
|
--env=CP_OUTPUT_DIR="$CP_OUTPUT_DIR" \
|
|
--env=FORCE_DISABLE_FOGOFWAR="true" \
|
|
--env=MC_USE_PROCEDURAL_SPRITES="1" \
|
|
org.godotengine.Godot \
|
|
--path "$PROJECT_DIR/src/game" \
|
|
--headless \
|
|
--rendering-driver opengl3 \
|
|
--rendering-method gl_compatibility \
|
|
res://engine/scenes/tests/claude_vs_ai_render_proof.tscn \
|
|
> "$LOG_FILE" 2>&1
|
|
RC=$?
|
|
|
|
echo "--- Tail of log ---"
|
|
tail -40 "$LOG_FILE"
|
|
echo "-------------------"
|
|
|
|
if ! grep -q "PROOF_DONE" "$LOG_FILE"; then
|
|
echo "ERROR: PROOF_DONE marker missing — run aborted (rc=$RC)"
|
|
exit 1
|
|
fi
|
|
|
|
OUTPUT_DIR_ABS=$(grep -m1 "OUTPUT_DIR_ABS:" "$LOG_FILE" | sed 's/.*OUTPUT_DIR_ABS://')
|
|
if [ -z "$OUTPUT_DIR_ABS" ] || [ ! -d "$OUTPUT_DIR_ABS" ]; then
|
|
# Fall back to deriving from CP_OUTPUT_DIR.
|
|
OUTPUT_DIR_ABS="$GODOT_USERDATA/${CP_OUTPUT_DIR#user://}"
|
|
fi
|
|
echo "Run output dir: $OUTPUT_DIR_ABS"
|
|
ls -la "$OUTPUT_DIR_ABS" | head -40 || true
|
|
|
|
HOST_OUTPUT_ABS="$PROJECT_DIR/$CP_HOST_OUTPUT"
|
|
mkdir -p "$HOST_OUTPUT_ABS"
|
|
cp -a "$OUTPUT_DIR_ABS/." "$HOST_OUTPUT_ABS/"
|
|
echo "Copied to: $HOST_OUTPUT_ABS"
|
|
ls "$HOST_OUTPUT_ABS"
|
|
|
|
echo "=== Done ==="
|
|
exit 0
|