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
+54
View File
@@ -0,0 +1,54 @@
extends TestCase
## The balance pass's report (H3): match length quantiles, weapon shares, survivors
## over time, and the verdict against the BALANCE_* targets.
func _match(seed_value: int, minutes: float, kills: Dictionary, winner: String = "normal") -> Dictionary:
var deaths: Array = []
for index: int in Tuning.SOLO_PLAYERS - 1:
deaths.append(minutes * 60.0 * (index + 1) / Tuning.SOLO_PLAYERS)
return {
"seed": seed_value, "finished": true, "winner": -1, "winner_difficulty": winner, "timed_out": false,
"causes": {"weapon": Tuning.SOLO_PLAYERS - 1}, "places": {"normal": [1, 2]}, "eliminations": {"normal": 2},
"weapon_kills": kills, "death_seconds": deaths, "shots": 10, "ticks": roundi(minutes * 60.0 * Tuning.TICK_RATE_HZ),
"timing": {"p99_us": 100, "over_budget": 0}, "state_hash": "x",
}
func test_quantiles_interpolate() -> void:
var values: Array[float] = [1.0, 2.0, 3.0, 4.0]
assert_eq(BalanceReport.quantile(values, 0.0), 1.0)
assert_eq(BalanceReport.quantile(values, 0.5), 2.5)
assert_eq(BalanceReport.quantile(values, 1.0), 4.0)
assert_eq(BalanceReport.quantile([] as Array[float], 0.5), 0.0)
func test_a_balanced_batch_passes() -> void:
var results: Array[Dictionary] = []
for index: int in Tuning.BALANCE_MIN_MATCHES:
results.append(_match(index, 13.0 + (index % 5) * 0.5, {"dock_carbine": 8, "signal_revolver": 8, "rivet_repeater": 7}))
var a: Dictionary = BalanceReport.analyse(results)
assert_eq(a["problems"], [], "no problems: %s" % [a["problems"]])
assert_eq(a["minutes"]["median"], 14.0)
assert_true(absf(a["weapon_share"]["dock_carbine"] - 8.0 / 23.0) < 0.001)
assert_true(a["standing"][12] > 1.0 and a["standing"][2] > a["standing"][12], "survivors fall over time: %s" % [a["standing"]])
assert_true(BalanceReport.format(a).contains("balance: ok"))
func test_short_matches_a_dominant_weapon_and_a_small_batch_fail() -> void:
var results: Array[Dictionary] = []
for index: int in 10:
results.append(_match(index, 6.0, {"rivet_repeater": 20, "dock_carbine": 3}))
var a: Dictionary = BalanceReport.analyse(results)
var text: String = BalanceReport.format(a)
assert_eq(a["problems"].size(), 3, "count, length and weapon: %s" % [a["problems"]])
assert_true(text.contains("only 10 matches"))
assert_true(text.contains("median match length 6.0 min"))
assert_true(text.contains("rivet_repeater took 87%"))
func test_every_match_ends_inside_the_longest_target() -> void:
var seconds: float = float(Tide.new(0).time_limit_offset()) / Tuning.TICK_RATE_HZ
assert_true(seconds <= Tuning.BALANCE_MEDIAN_MINUTES_MAX * 60.0, "the tide and sudden death take %.0f s" % seconds)
assert_true(seconds >= Tuning.BALANCE_MEDIAN_MINUTES_MIN * 60.0, "and leave room for a %.0f-minute match" % Tuning.BALANCE_MEDIAN_MINUTES_MIN)