#!/usr/bin/env bash set -euo pipefail if [[ ! -f /opt/rct2-assets/Data/g1.dat && ! -f /opt/rct2-assets/Data/G1.DAT ]]; then echo "Mount a complete Steam RCT2 installation at /opt/rct2-assets." >&2 exit 1 fi mkdir -p "$HOME/.config/OpenRCT2" # The supervisor installs the controller per try, with that try's number in it. mkdir -p "$HOME/.config/OpenRCT2/plugin" if [[ ! -f "$HOME/.config/OpenRCT2/config.ini" ]]; then # allow_early_completion makes the objective succeed on the day the park # value target is reached, instead of only at the deadline month. # USD keeps the on-screen objective reading exactly $100,000. # A try's park is thrown away when the next try starts, so autosave is set # to the shortest interval the engine offers (1 = every five minutes) and # kept for 30 files. The controller also saves at the moment a try settles, # which is what actually gives each try a save to be graded against. cat > "$HOME/.config/OpenRCT2/config.ini" <<'EOF' [general] autosave = 1 autosave_amount = 30 window_width = 1280 window_height = 800 fullscreen_mode = 2 play_intro = false drawing_engine = SOFTWARE_HWD use_vsync = false multithreading = false allow_early_completion = true currency_format = USD confirmation_prompt = false save_plugin_data = true [sound] master_sound = false EOF fi openrct2 set-rct2 /opt/rct2-assets export T37_AUDIT_DIR=/logs/artifacts/audit # Three tries of the two-year park in one session; 1 gives a single-try run. export T37_TRIES="${T37_TRIES:-3}" mkdir -p "$T37_AUDIT_DIR" pids=() cleanup() { trap - EXIT INT TERM python3 /usr/local/lib/t37/collect.py --screenshot || true kill "${pids[@]}" 2>/dev/null || true wait || true } trap cleanup EXIT trap 'exit 0' INT TERM Xvfb "$DISPLAY" -screen 0 1280x800x24 -nolisten tcp & pids+=("$!") ready=false for ((attempt=0; attempt<100; attempt++)); do if xdpyinfo >/dev/null 2>&1; then ready=true; break; fi sleep 0.1 done "$ready" || { echo "Virtual display failed to start." >&2; exit 1; } openbox & pids+=("$!") x11vnc -display "$DISPLAY" -localhost -rfbport 5900 -forever -shared -nopw -quiet & pids+=("$!") websockify --web=/usr/share/novnc 6080 localhost:5900 & pids+=("$!") # The supervisor owns the engine: it plays the seed park for each try and resets # the park between tries. Nothing else may start or reset a scenario. python3 /usr/local/lib/t37/try-supervisor.py "$@" & pids+=("$!") # Host-mounted checkpoints survive container removal. Screenshots and saves # are collected every two minutes, within the suite's two/five-minute limits. ( while true; do sleep 120 python3 /usr/local/lib/t37/collect.py --screenshot || true done ) & pids+=("$!") # Closing the game, or failure of a desktop service, stops this container. wait -n "${pids[@]}"