From b08c37cdccde801f9d7f0fee6813f57f190ce5b5 Mon Sep 17 00:00:00 2001 From: autocommit Date: Thu, 16 Apr 2026 11:58:37 -0700 Subject: [PATCH] =?UTF-8?q?scripts(apricot):=20=F0=9F=94=A8=20Update=20Apr?= =?UTF-8?q?icot=20script=20logic=20for=20enhanced=20automation=20and=20bui?= =?UTF-8?q?ld=20process=20improvements?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Lilith Autocommit --- scripts/apricot/run_ap3.sh | 68 +++++++++++++++++++++++++++++++++++ scripts/apricot/run_seeded.sh | 21 +++++++++++ 2 files changed, 89 insertions(+) create mode 100755 scripts/apricot/run_ap3.sh create mode 100755 scripts/apricot/run_seeded.sh diff --git a/scripts/apricot/run_ap3.sh b/scripts/apricot/run_ap3.sh new file mode 100755 index 00000000..995cb243 --- /dev/null +++ b/scripts/apricot/run_ap3.sh @@ -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" diff --git a/scripts/apricot/run_seeded.sh b/scripts/apricot/run_seeded.sh new file mode 100755 index 00000000..8ec6f93a --- /dev/null +++ b/scripts/apricot/run_seeded.sh @@ -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"