pub fn autobalance<S: Clone, R: Sides>(
stage: &S,
knobs: &[&dyn Knob<S>],
entrants: &[&dyn Entrant<S, R>],
checks: &[Check],
settings: &BalanceSettings,
) -> Result<Balanced<S>, PlaytestError<R>>Expand description
Changes stage with knobs until every rate check of checks puts
every one of entrants inside its band, as settings says. The
entrants and the checks are never changed: only the stage is.
All deterministic:
- Before: the stage as authored plays at
settings.tries. In every band already, it stops (Stop::AlreadyInBands). - Pattern search at
settings.quicktries, from every knob at 0, each knob’s stride itsKnob::stride: in knob order,+stridethen-stride(clamped to the range, skipping a step that doesn’t move or that a knob can’t apply). The first step that lowers thedistanceis taken and the knob order starts again. When none does, every stride above 1 is halved; when every stride is 1, it stops (Stop::Stuck). - Confirm: a setting in every band at
quickplays attries. In every band there too, it is pruned; if not, the pattern search carries on attriesfrom there. - Prune: each changed knob in order is tried at 0, then nearer 0
one step at a time, keeping each change that stays in every band
at
tries(Stop::InBands). What is left is the smallest change set this search found, not one proved the smallest. - Budget: every run of the playtest runner is one evaluation, and
a setting is never run twice at one try count. When the
evaluationsrun out, it stops (Stop::Budget) with the best setting seen, kept back one evaluation to play it attries.
A setting that ends no nearer its bands at tries than the stage as
authored is dropped: the result is then the stage as authored.
A check naming an entrant not in the run fails before any try is played; a refused command stops the search.
It is autobalance_by, each setting played by playtest::run,
never told to stop.