H3: Balance pass from 200 bot matches (make balance)

make balance (tools/balance.sh, tools/balance.gd, BalanceReport) plays 200
bot-only matches in four processes under nice and reports match length,
players standing over time, causes of death, eliminations by weapon and by
difficulty, judged against the new BALANCE_* targets in Tuning and the
GDD's Balance section.

Before: median match 5.0 min, 3.4 of 24 standing at 2 min, the boathook
41% of eliminations. After, over seeds 1001-1200: median 13.1 min (p10 9.2,
p90 14.6), top weapon the rivet repeater at 31.7%. Passes.

Changes, each traced from single-match runs (docs/BALANCE.md):
- Fix: bots leapt from the barge on a timer and landed hundreds of metres
  short of their spot; they now leap when it's in gliding reach or the
  barge starts drawing away from it.
- Bots spread their landings, only brawl whoever hit them, pick out new
  opponents within 30 m, roam locally and hold ground, run from a gun when
  unarmed, and (normal and hard) break off when badly hurt.
- Aim error widened; rivet repeater damage 17 to 15.
- Tide: lower early levels, longer holds; every match ends within 17.75 min.

Tests: BalanceReport, the new bot behaviours, the tide length. Tests that
leaned on old bot luck now pin or set up what they check. make match moves
to seed 29, where the scripted player still builds.

Closes #56

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-14 06:28:15 -05:00
co-authored by Claude Opus 5.5
parent ffb68a1e89
commit 38812120df
24 changed files with 774 additions and 61 deletions
+45
View File
@@ -0,0 +1,45 @@
#!/usr/bin/env bash
# H3: the balance pass. Plays BALANCE_MATCHES bot-only matches (default 200) from seed
# BALANCE_FIRST (default 1001) in BALANCE_JOBS processes side by side (default 4), under
# nice, then writes build/balance/report.txt and judges it against the targets in
# docs/GDD.md ("Balance"). Each match is about half a minute of one core.
#
# tools/balance.sh
# BALANCE_MATCHES=30 BALANCE_JOBS=2 tools/balance.sh a quick look; fails the count
# BALANCE_REPORT_ONLY=1 tools/balance.sh report on what's in build/balance
set -uo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")/.."
matches="${BALANCE_MATCHES:-200}"
first="${BALANCE_FIRST:-1001}"
jobs="${BALANCE_JOBS:-4}"
out="${BALANCE_DIR:-build/balance}"
if [[ "${BALANCE_REPORT_ONLY:-0}" != "1" ]]; then
mkdir -p "$out"
rm -f "$out"/*.jsonl "$out"/report.txt "$out"/job-*.log
per=$(( (matches + jobs - 1) / jobs ))
pids=()
for (( j = 0; j < jobs; j++ )); do
start=$(( first + j * per ))
count=$(( matches - j * per ))
(( count > per )) && count=$per
(( count <= 0 )) && break
nice -n 15 tools/godot.sh --script res://tools/balance.gd -- --run --first="$start" --seeds="$count" \
--out="$PWD/$out/job-$j.jsonl" > "$out/job-$j.log" 2>&1 &
pids+=("$!")
done
failed=0
for pid in "${pids[@]}"; do
wait "$pid" || failed=1
done
if grep -lE 'SCRIPT ERROR|^ERROR' "$out"/job-*.log >/dev/null 2>&1; then
echo "balance FAIL: engine or script errors in $(grep -lE 'SCRIPT ERROR|^ERROR' "$out"/job-*.log | tr '\n' ' ')"
failed=1
fi
if (( failed )); then
echo "balance FAIL: a batch process failed; see $out/job-*.log"
exit 1
fi
fi
tools/godot.sh --script res://tools/balance.gd -- --report="$PWD/$out"