Phase 5b: player power floor + Phase-3 winners shipped to live

Closes the 'fairly breezy with some death' target the user picked
for Phase 5. Five-piece ship; Phase 1 matrix lands T1 88%, T2 74%,
T4 72%, T5 ~57% in or above band. T3 remains the design hump at
~45% (manor 39, underforge 47) — Wraith promotion to elite was
already done in Phase 4-B, the remaining standard-pool deaths are
the irreducible part of T3.

Pieces:
  1. computeMaxHP × 1.5 (phase5BHPMult in dnd.go). Uniform across
     class/level so the class-balance harness's in-tier parity
     assertion stays green. Bootstrap (bootstrap_phase5b_hp.go)
     refreshes hp_max for existing characters at startup;
     idempotent via db.JobCompleted. hp_current is bumped by the
     same delta so a full-HP character stays at full.
  2. applyPhase5BPlayerFloor (dnd_combat.go): +3 AC, +3 AttackBonus,
     +3 weapon.MagicBonus (damage). Applied at the END of
     applyDnDEquipmentLayer (after computeArmorAC's AC override)
     and inside buildHarnessPlayer so live and harness measurement
     match.
  3. Elite bracket 19 → 23 (resolveCombatInterrupt). Case order
     puts Elite (≥23) before Patrol (≥22) so a 23+ total prefers
     the single dangerous fight. Elite is now effectively a
     high-threat event reachable only via the +1-per-20-threat-
     above-40 mod — Phase 4-B's elite-pool monsters still appear,
     just less often.
  4. dailyThreatDrift base 3 → 1. Slows the threat clock so
     players have the days they need before threat tips zones
     into the new 23+ elite band.
  5. applyDailyBurn default → 50% (phase5BDailyBurnRatePct). Also
     applied in the temporal-override branch in
     dnd_expedition_cycle.go so tidal / unraveling days scale by
     the same 0.5× — otherwise those days would be
     disproportionately harsh against the new baseline.

The harness's expedition_balance.go reads phase5BDailyBurnRatePct
as the default-burn fallback when the override knob is zero, so
Phase 1 matrix measurements now reflect what live players
experience.

Test debt: 13 pinned-numbers unit tests across combat_stats_test,
dnd_test, dnd_xp_test, dnd_equipment_profiles_test,
dnd_expedition_supplies_test, dnd_expedition_cycle_test,
dnd_expedition_extract_test, dnd_expedition_region_cmd_test,
dnd_expedition_combat_test, dnd_expedition_threat_test,
dnd_expedition_temporal_test, expedition_balance_test were
pinning pre-Phase-5-B baselines; updated with comments noting
the cause. Class-balance suite stayed green (uniform buff
preserves spread).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
prosolis
2026-05-15 12:11:27 -07:00
parent d0a8505c76
commit 5ef10e35dc
23 changed files with 627 additions and 94 deletions

View File

@@ -56,9 +56,12 @@ func TestExpeditionBalance_Phase0_Spike(t *testing.T) {
if res.Completions == 0 {
t.Errorf("zero completions in %d trials at T2/L5 Fighter — the spike cell should not be unwinnable", trials)
}
if res.Completions == trials {
t.Errorf("100%% completions in %d trials at T2/L5 Fighter — interrupt rolls / night checks not pressuring the run", trials)
}
// Phase 5-B player floor lifted the at-tier completion rate
// substantially; 100%% completion at the spike cell is now the
// expected "fairly breezy" outcome, not a harness-broken signal.
// (Cells that 0% out remain a harness-broken signal — checked
// above.)
_ = trials
if res.MedianDays == 0 {
t.Fatalf("median days == 0; day loop never advanced")
}
@@ -1269,6 +1272,138 @@ func TestExpeditionBalance_Phase5A_TierWideSensitivity(t *testing.T) {
}
}
// TestExpeditionBalance_Phase5B_GearBonusSweep walks the full matrix
// at gear magic-bonus delta ∈ {0, +1, +2} on top of the Phase 3-B
// best cell (e=23, d=1, burn=50, nick-floor=tier). Phase 5-A named
// player level as the dominant lever at T2/T3 but showed the
// within-bracket slope can't close the band — the live magic-bonus
// ladder (0/1/2/3/3) tops the player-power knob, so the question is
// what flat delta on top of the ladder lands T1-T5 in band.
//
// Bands (gogobee_expedition_difficulty.md):
// T1 80% (70-90%) T2 72% (62-82%) T3 65% (55-75%)
// T4 55% (45-65%) T5 45% (35-55%)
//
// 10 zones × 3 deltas × 200 trials = 6k trials; runs in ~1s.
// Diagnostic-only — picks the delta Phase 5-B ships in
// magicBonusForTier.
func TestExpeditionBalance_Phase5B_GearBonusSweep(t *testing.T) {
if testing.Short() {
t.Skip("phase 5-B gear sweep walks 10 zones × 3 deltas × 200 trials; -short skips it")
}
const trialsPerCell = 200
const baseSeed uint64 = 0xF50B1E
// Phase 3-B best cell, held constant.
const eliteThreshold = 23
const driftBase = 1
const supplyBurnPct = 50
// Two-axis grid. Gear delta is the to-hit/AC/damage lever (Phase
// 5-B's first read showed it dominates at T1/T2/T4); HP multiplier
// is the durability lever needed to close T3/T5 where gear alone
// stalled at ~5pp/delta. Smallest combination that lands all
// tiers in band gets shipped.
gearDeltas := []int{2, 3, 4}
hpMults := []float64{1.0, 1.25, 1.5}
type cellOut struct {
comp, death, starve int
}
runCell := func(zid ZoneID, tier ZoneTier, level, delta int, hpMult float64) cellOut {
profile := expeditionBalanceProfile{
ZoneID: zid,
Class: ClassFighter,
Level: level,
Supplies: makeSupplies(tier, SupplyPurchase{StandardPacks: 3}),
CampType: CampTypeStandard,
EliteInterruptThresholdOverride: eliteThreshold,
ThreatDriftBaseOverride: driftBase,
SupplyBurnRatePctOverride: supplyBurnPct,
GearMagicBonusOverride: delta,
PlayerHPMultOverride: hpMult,
}
out := cellOut{}
for trial := 0; trial < trialsPerCell; trial++ {
seed := baseSeed + uint64(trial) +
uint64(tier)*131 + zoneSeedSalt(zid) +
uint64(delta)*7_919 +
uint64(hpMult*1000)*23
res := runExpeditionBalanceTrial(profile, seed)
switch {
case res.Completed:
out.comp++
case res.Died:
out.death++
case res.StarvedOut:
out.starve++
}
}
return out
}
t.Logf("phase5-B gear×hp sweep — %d zones × %d gear × %d hp × %d trials, Fighter @ tier-centerline, baselines e=%d d=%d burn=%d",
len(zoneOrder), len(gearDeltas), len(hpMults), trialsPerCell,
eliteThreshold, driftBase, supplyBurnPct)
type comboKey struct {
gear int
hp float64
}
type tierAgg struct{ sum, count float64 }
perCombo := map[comboKey]map[ZoneTier]*tierAgg{}
for _, delta := range gearDeltas {
for _, hp := range hpMults {
key := comboKey{delta, hp}
perCombo[key] = map[ZoneTier]*tierAgg{}
t.Logf("═══ gear=+%d hp×%.2f ═══", delta, hp)
for _, zid := range zoneOrder {
zone, ok := getZone(zid)
if !ok {
continue
}
level := phase1TierCenterline[zone.Tier]
out := runCell(zid, zone.Tier, level, delta, hp)
compPct := float64(out.comp) / float64(trialsPerCell) * 100
t.Logf(" CELL g=+%d h=%.2f %-18s T%d L%-2d comp=%5.1f%% death=%5.1f%% starve=%5.1f%%",
delta, hp, zid, zone.Tier, level, compPct,
float64(out.death)/float64(trialsPerCell)*100,
float64(out.starve)/float64(trialsPerCell)*100)
ag, ok := perCombo[key][zone.Tier]
if !ok {
ag = &tierAgg{}
perCombo[key][zone.Tier] = ag
}
ag.sum += compPct
ag.count++
}
}
}
// Combo × tier headline. Bands per gogobee_expedition_difficulty.md:
// the "fairly breezy" target the user picked for Phase 5 means we
// can land at or above band-center across all tiers.
t.Logf("─── tier means by (gear, hp) — bands: T1 70-90, T2 62-82, T3 55-75, T4 45-65, T5 35-55 ───")
tiers := []ZoneTier{
ZoneTierBeginner, ZoneTierApprentice, ZoneTierJourneyman,
ZoneTierVeteran, ZoneTierLegendary,
}
for _, delta := range gearDeltas {
for _, hp := range hpMults {
key := comboKey{delta, hp}
parts := make([]string, 0, len(tiers))
for _, ti := range tiers {
ag := perCombo[key][ti]
if ag == nil || ag.count == 0 {
continue
}
parts = append(parts, fmt.Sprintf("T%d=%.1f%%", ti, ag.sum/ag.count))
}
t.Logf(" TIER-MEANS g=+%d h=%.2f %s", delta, hp, joinZones(parts))
}
}
}
// zoneSeedSalt produces a stable per-zone seed offset so each
// (outlier, sibling) draws from a distinct RNG stream without
// hand-numbering. fnv-like fold over the bytes; small footprint, no