pub fn autobalance_by<S: Clone, E>(
stage: &S,
knobs: &[&dyn Knob<S>],
settings: &BalanceSettings,
evaluate: impl FnMut(&S, &Tries) -> Result<PlaytestReport, E>,
should_stop: impl FnMut() -> bool,
) -> Result<Balanced<S>, E>Expand description
autobalance’s search, each setting played by evaluate: the
report of the stage it is given, played as the Tries it is given
say, its checks judged (a caller with threads plays the seeds on them
and playtest::judges them once). Its first error stops the search.
Before each run of the search, should_stop is asked whether to stop
(a caller’s clock: the core reads none). Once it says so, the search
stops (Stop::Stopped) with the best setting seen, kept back one
evaluation as for Stop::Budget: the stage as authored and the
setting it ends on are always played at settings.tries, so a search
told to stop at once makes the one run of the stage as authored.
Given the same reports from evaluate and the same answers from
should_stop, it makes the same runs in the same order and finds the
same changes.