scripts(apricot): 🔨 Update Apricot script logic for enhanced automation and build process improvements
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
23fbb10954
commit
b08c37cdcc
2 changed files with 89 additions and 0 deletions
68
scripts/apricot/run_ap3.sh
Executable file
68
scripts/apricot/run_ap3.sh
Executable file
|
|
@ -0,0 +1,68 @@
|
|||
#!/bin/bash
|
||||
# Godot autoplay runner with two headless modes.
|
||||
#
|
||||
# RENDER_MODE=headless (default) — Godot --headless, no display server.
|
||||
# Fastest. Screenshots blank. For bulk simulation / data collection.
|
||||
#
|
||||
# RENDER_MODE=weston — weston --backend=headless provides a virtual Wayland
|
||||
# display with software rendering (llvmpipe). Screenshots work.
|
||||
# Requires weston installed on the host.
|
||||
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}"
|
||||
: "${RENDER_MODE:=headless}"
|
||||
|
||||
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
|
||||
|
||||
GODOT_ARGS=("--path" "." "--rendering-method" "gl_compatibility")
|
||||
WESTON_PID=""
|
||||
|
||||
_cleanup() {
|
||||
if [ -n "$WESTON_PID" ]; then
|
||||
kill "$WESTON_PID" 2>/dev/null || true
|
||||
wait "$WESTON_PID" 2>/dev/null || true
|
||||
fi
|
||||
}
|
||||
trap _cleanup EXIT
|
||||
|
||||
if [ "$RENDER_MODE" = "weston" ]; then
|
||||
if ! command -v weston >/dev/null 2>&1; then
|
||||
echo "ERROR: RENDER_MODE=weston but weston not found" >&2
|
||||
exit 1
|
||||
fi
|
||||
WESTON_SOCKET="godot-headless-$$"
|
||||
weston --backend=headless --socket="$WESTON_SOCKET" --width=1920 --height=1080 \
|
||||
>"$AUTO_PLAY_DIR/weston.log" 2>&1 &
|
||||
WESTON_PID=$!
|
||||
sleep 1
|
||||
FLATPAK_ENVS+=(
|
||||
"--socket=wayland"
|
||||
"--env=WAYLAND_DISPLAY=$WESTON_SOCKET"
|
||||
)
|
||||
FLATPAK_ENVS+=("--filesystem=xdg-run/${WESTON_SOCKET}")
|
||||
else
|
||||
GODOT_ARGS+=("--headless")
|
||||
fi
|
||||
|
||||
timeout "$SAFETY" flatpak run --user \
|
||||
--filesystem=home \
|
||||
"${FLATPAK_ENVS[@]}" \
|
||||
org.godotengine.Godot "${GODOT_ARGS[@]}" 2>&1
|
||||
EXIT=$?
|
||||
echo "EXIT_CODE=$EXIT"
|
||||
21
scripts/apricot/run_seeded.sh
Executable file
21
scripts/apricot/run_seeded.sh
Executable file
|
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
# Seeded autoplay runner. Delegates to run_ap3.sh with seed and turn limit.
|
||||
#
|
||||
# Usage: run_seeded.sh [seed=1] [turn_limit=200]
|
||||
# Set RENDER_MODE=weston for screenshot-capable runs (default: headless).
|
||||
set -uo pipefail
|
||||
SEED="${1:-1}"
|
||||
TURN_LIMIT="${2:-200}"
|
||||
|
||||
DIR="$HOME/tmp/ap_seeded_${SEED}"
|
||||
rm -rf "$DIR"
|
||||
mkdir -p "$DIR"
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
AUTO_PLAY=true \
|
||||
AUTO_PLAY_SEED="$SEED" \
|
||||
AUTO_PLAY_TURN_LIMIT="$TURN_LIMIT" \
|
||||
AUTO_PLAY_DIR="$DIR" \
|
||||
RENDER_MODE="${RENDER_MODE:-headless}" \
|
||||
bash "$SCRIPT_DIR/run_ap3.sh"
|
||||
Loading…
Add table
Reference in a new issue