Skip to main content

Tunable

Struct Tunable 

Source
#[non_exhaustive]
pub struct Tunable<S> { pub stage: S, pub knobs: Vec<Box<dyn Knob<S>>>, pub play: StagePlay<S>, pub write: StageWrite<S>, }
Expand description

The stage an AutobalancePlan may change, of the game’s stage definition type S: the command never sees S, only what the search found (TunableStage). Build it with Tunable::new (ADR-0039).

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§stage: S

The stage as authored.

§knobs: Vec<Box<dyn Knob<S>>>

What the search may change, in the order it tries them.

§play: StagePlay<S>

One try on a stage: the stage (as authored, or changed by the knobs), the entrant at that index of the plan’s entrants, the seed, the turn it stops at. Tries run on several threads at once, in any order; most simply play_try.

§write: StageWrite<S>

Writes a changed stage back to the game’s files (--apply): the files written, as the game shows them.

Implementations§

Source§

impl<S> Tunable<S>

Source

pub fn new( stage: S, knobs: Vec<Box<dyn Knob<S>>>, play: StagePlay<S>, write: StageWrite<S>, ) -> Self

The stage stage, changed by knobs, a try on it played by play and a changed one written by write.

Trait Implementations§

Source§

impl<S: Clone + Sync> TunableStage for Tunable<S>

Source§

fn search( &self, settings: &BalanceSettings, evaluate: &mut Evaluate<'_>, should_stop: &mut dyn FnMut() -> bool, apply: bool, ) -> Result<Searched, String>

The search over the stage (shuyi_core::autobalance_by) as settings say, each setting played by evaluate, asking should_stop before each run; with apply, the stage found is written if it changed.

Auto Trait Implementations§

§

impl<S> !RefUnwindSafe for Tunable<S>

§

impl<S> !Send for Tunable<S>

§

impl<S> !Sync for Tunable<S>

§

impl<S> !UnwindSafe for Tunable<S>

§

impl<S> Freeze for Tunable<S>
where S: Freeze,

§

impl<S> Unpin for Tunable<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for Tunable<S>
where S: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.