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
+93
View File
@@ -39,6 +39,14 @@ func _bot(at: Vector3, level: int = BotBrain.NORMAL, yaw: int = 0) -> BotBrain:
return brain
## Keeps an idle bot where it stands, facing as it was put, instead of roaming off and
## turning its back on whoever the test placed.
func _pin(brain: BotBrain) -> void:
brain._hunt_goal = sim.entities.find(brain.player_id).position
brain._holding = true
brain._hunt_until = 1 << 30
func _arm(player: SimEntity, weapon: String = "dock_carbine", ammo: String = "cartridges", rounds: int = 150) -> void:
assert_eq(Inventory.give(player, ItemCatalog.code_of(weapon), 1), 0)
Inventory.give(player, ItemCatalog.code_of(ammo), rounds)
@@ -144,6 +152,7 @@ func test_an_armed_bot_eliminates_an_opponent_it_can_see() -> void:
_arm(sim.entities.find(brain.player_id))
var victim: SimEntity = _player(HOME + Vector3(25.0, 0.0, 0.0))
_ready_world()
_pin(brain)
_run(30 * TICKS, func() -> bool: return victim.eliminated)
assert_true(victim.eliminated, "the opponent fell (health %d)" % victim.health)
assert_eq(victim.last_attacker, brain.player_id)
@@ -191,6 +200,7 @@ func test_bots_wait_out_their_reaction_time() -> void:
_arm(sim.entities.find(brain.player_id))
_player(HOME + Vector3(20.0, 0.0, 0.0))
_ready_world()
_pin(brain)
_run(4 * TICKS, func() -> bool: return not first_shot.is_empty())
assert_true(first_shot.has(brain.player_id), "%s fired" % brain.difficulty_name())
var reaction: int = roundi(float(Tuning.BOT_DIFFICULTIES[level]["reaction"]) * TICKS)
@@ -330,6 +340,8 @@ func test_an_unarmed_bot_closes_in_and_swings_its_boathook() -> void:
var victim: SimEntity = _player(HOME + Vector3(4.5, 0.0, 0.0))
var start: int = victim.health
_ready_world()
# Unarmed bots only brawl someone who hit them (H3).
Weapons.damage_player(sim, sim.entities.find(brain.player_id), 5, victim.id)
var swings: Array[int] = [0]
for _tick: int in 6 * TICKS:
_run(1)
@@ -353,3 +365,84 @@ func test_an_unarmed_bot_leaves_a_distant_opponent_alone() -> void:
_run(3 * TICKS)
assert_ne(brain.state, "brawl")
assert_eq(victim.health, Tuning.PLAYER_MAX_HEALTH)
func test_an_unarmed_bot_does_not_start_a_brawl() -> void:
_setup()
var brain: BotBrain = _bot(HOME, BotBrain.HARD, FACING_X)
var other: SimEntity = _player(HOME + Vector3(4.5, 0.0, 0.0))
_ready_world()
_run(3 * TICKS)
assert_ne(brain.state, "brawl")
assert_eq(other.health, Tuning.PLAYER_MAX_HEALTH, "nobody was hit")
func test_a_bot_ignores_a_far_opponent_until_it_is_shot() -> void:
_setup()
var brain: BotBrain = _bot(HOME, BotBrain.HARD, FACING_X)
var me: SimEntity = sim.entities.find(brain.player_id)
_arm(me)
# In sight (hard bots see 90 m) but further than a bot picks out a new opponent.
var other: SimEntity = _player(HOME + Vector3(Tuning.BOT_ENGAGE_METRES + 15.0, 0.0, 0.0))
_ready_world()
_pin(brain)
_run(2 * TICKS)
assert_eq(brain.target_id, 0, "it doesn't go looking for a fight that far off")
assert_true(shots_by.is_empty())
Weapons.damage_player(sim, me, 10, other.id)
_run(3 * TICKS)
assert_eq(brain.target_id, other.id, "but answers one who shoots at it")
assert_true(int(shots_by.get(me.id, 0)) > 0, "and fires back")
func test_an_unarmed_bot_runs_from_a_gun() -> void:
_setup()
var brain: BotBrain = _bot(HOME, BotBrain.EASY, FACING_X)
var me: SimEntity = sim.entities.find(brain.player_id)
var gunner: SimEntity = _player(HOME + Vector3(12.0, 0.0, 0.0), FACING_X * 3)
_arm(gunner)
gunner.selected = 1
_ready_world()
_pin(brain)
_run(2 * TICKS)
assert_eq(brain.state, "retreat", "an unarmed bot breaks away from a held gun")
_run(4 * TICKS)
assert_true(me.position.distance_to(gunner.position) > 16.0, "and gets further off (%.1f m)" % me.position.distance_to(gunner.position))
func test_a_badly_hurt_bot_breaks_off_but_an_easy_one_does_not() -> void:
for level: int in [BotBrain.HARD, BotBrain.EASY]:
_setup()
var brain: BotBrain = _bot(HOME, level, FACING_X)
var me: SimEntity = sim.entities.find(brain.player_id)
_arm(me)
Inventory.give(me, ItemCatalog.code_of("sailcloth_bandage"), 2)
me.health = 30
var other: SimEntity = _player(HOME + Vector3(20.0, 0.0, 0.0), FACING_X * 3)
_arm(other)
other.selected = 1
_ready_world()
_pin(brain)
var states: Dictionary = {}
for _tick: int in 2 * TICKS:
_run(1)
states[brain.state] = true
if level == BotBrain.HARD:
assert_true(states.has("retreat"), "hard breaks off at 30 health with bandages: %s" % [states.keys()])
else:
assert_false(states.has("retreat"), "easy fights on: %s" % [states.keys()])
assert_true(states.has("fight"), "easy fights: %s" % [states.keys()])
func test_a_bot_with_nothing_to_do_holds_its_ground() -> void:
_setup()
var brain: BotBrain = _bot(HOME)
var me: SimEntity = sim.entities.find(brain.player_id)
_arm(me)
_ready_world()
_run(60 * TICKS, func() -> bool: return brain.state == "hold")
assert_eq(brain.state, "hold", "it roams somewhere and settles")
var at: Vector3 = me.position
_run(roundi(Tuning.BOT_HOLD_SECONDS * 0.8) * TICKS)
assert_true(me.position.distance_to(at) < 3.0, "and stays put while holding (moved %.1f m)" % me.position.distance_to(at))
assert_true(at.distance_to(HOME) <= Tuning.BOT_ROAM_METRES + 5.0, "it didn't roam far (%.1f m)" % at.distance_to(HOME))