magicciv/scripts/apricot/run_ap3.sh
Natalie 42aaf38d3e fix(@projects/@magic-civilization): 🐛 update godot headless path and env vars
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
2026-04-16 17:51:23 -07:00

28 lines
926 B
Bash
Executable file

#!/bin/bash
# Godot headless autoplay runner. Uses Godot's --headless flag (no weston,
# no Wayland, no X). Screenshots will be blank but turn_stats.jsonl /
# events.jsonl / saves/ are produced.
set -uo pipefail
pkill -f "flatpak run.*Godot" 2>/dev/null || true
pkill -f godot 2>/dev/null || true
sleep 1
: "${AUTO_PLAY:=true}"
: "${AUTO_PLAY_DIR:=$HOME/tmp/ap_default}"
: "${AUTO_PLAY_TURN_LIMIT:=500}"
mkdir -p "$AUTO_PLAY_DIR"
cd "$HOME/Code/@projects/@magic-civilization/src/game"
SAFETY=$((AUTO_PLAY_TURN_LIMIT * 2 + 300))
FLATPAK_ENVS=(
"--env=AUTO_PLAY=true"
"--env=AUTO_PLAY_DIR=$AUTO_PLAY_DIR"
"--env=AUTO_PLAY_TURN_LIMIT=$AUTO_PLAY_TURN_LIMIT"
)
if [ -n "${AUTO_PLAY_SEED:-}" ]; then
FLATPAK_ENVS+=("--env=AUTO_PLAY_SEED=$AUTO_PLAY_SEED")
fi
timeout "$SAFETY" flatpak run --user \
--filesystem=home \
"${FLATPAK_ENVS[@]}" \
org.godotengine.Godot --path . --headless 2>&1
EXIT=$?
echo "EXIT_CODE=$EXIT"