feat(@projects): add clan rotation for slot 0 in autoplay

Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
Natalie 2026-05-16 23:59:30 -07:00
parent ed2c30be8d
commit e629cd4da5

View file

@ -187,6 +187,38 @@ _run_local() {
_kill_stale_procs
fi
# Per-seed clan rotation for `AI_PIN_PERSONALITY_P{0..4}`:
# without this, slot 0 always holds the same clan (whatever the caller
# set globally), and because `auto_play.gd` impersonates slot 0 with
# extra strategic helpers (rush-buy gold, attack-phase commit, formation
# orders) that one clan wins every game. Rotating which clan holds slot
# 0 across seeds spreads the autoplay-shaped opportunity. Reads
# `AI_PIN_PERSONALITY_P0..4` from caller env to learn the canonical
# ordering, then rotates by `(seed-1) % 5` so position-shift is
# deterministic per seed. Caller can suppress by setting
# `AI_PIN_ROTATION=off`.
local PIN_P0_ENV="${AI_PIN_PERSONALITY_P0:-}"
local PIN_P1_ENV="${AI_PIN_PERSONALITY_P1:-}"
local PIN_P2_ENV="${AI_PIN_PERSONALITY_P2:-}"
local PIN_P3_ENV="${AI_PIN_PERSONALITY_P3:-}"
local PIN_P4_ENV="${AI_PIN_PERSONALITY_P4:-}"
local PINS=("$PIN_P0_ENV" "$PIN_P1_ENV" "$PIN_P2_ENV" "$PIN_P3_ENV" "$PIN_P4_ENV")
local PIN_SEED_P0="$PIN_P0_ENV"
local PIN_SEED_P1="$PIN_P1_ENV"
local PIN_SEED_P2="$PIN_P2_ENV"
local PIN_SEED_P3="$PIN_P3_ENV"
local PIN_SEED_P4="$PIN_P4_ENV"
if [ "${AI_PIN_ROTATION:-on}" != "off" ] && [ -n "$PIN_P0_ENV" ] \
&& [ -n "$PIN_P1_ENV" ] && [ -n "$PIN_P2_ENV" ] \
&& [ -n "$PIN_P3_ENV" ] && [ -n "$PIN_P4_ENV" ]; then
local shift=$(( (seed - 1) % 5 ))
PIN_SEED_P0="${PINS[$(( (0 + shift) % 5 ))]}"
PIN_SEED_P1="${PINS[$(( (1 + shift) % 5 ))]}"
PIN_SEED_P2="${PINS[$(( (2 + shift) % 5 ))]}"
PIN_SEED_P3="${PINS[$(( (3 + shift) % 5 ))]}"
PIN_SEED_P4="${PINS[$(( (4 + shift) % 5 ))]}"
fi
local WESTON_PID=""
local FLATPAK_ENVS=(
"--env=AUTO_PLAY=true"
@ -198,6 +230,11 @@ _run_local() {
"--env=AI_DIFFICULTY_P0=${AI_DIFFICULTY_P0:-}"
"--env=AI_DIFFICULTY_P1=${AI_DIFFICULTY_P1:-}"
"--env=AI_PIN_PERSONALITY=${AI_PIN_PERSONALITY:-}"
"--env=AI_PIN_PERSONALITY_P0=${PIN_SEED_P0}"
"--env=AI_PIN_PERSONALITY_P1=${PIN_SEED_P1}"
"--env=AI_PIN_PERSONALITY_P2=${PIN_SEED_P2}"
"--env=AI_PIN_PERSONALITY_P3=${PIN_SEED_P3}"
"--env=AI_PIN_PERSONALITY_P4=${PIN_SEED_P4}"
"--env=MAP_SIZE=${MAP_SIZE:-}"
"--env=NUM_PLAYERS=${NUM_PLAYERS:-}"
"--env=AI_USE_MCTS=${AI_USE_MCTS:-}"