Skip to main content

Knob

Trait Knob 

Source
pub trait Knob<S> {
    // Required methods
    fn name(&self) -> &str;
    fn range(&self) -> RangeInclusive<i32> ⓘ;
    fn apply(&self, stage: &S, step: i32) -> Option<S>;
    fn describe(&self, step: i32) -> String;

    // Provided method
    fn stride(&self) -> u32 { ... }
}
Expand description

One way the game lets the search change a stage definition S: a bounded integer step, 0 being the stage as authored.

Required Methods§

Source

fn name(&self) -> &str

Its name, which the change set uses.

Source

fn range(&self) -> RangeInclusive<i32> ⓘ

The steps it may take. It holds 0, the stage as authored.

Source

fn apply(&self, stage: &S, step: i32) -> Option<S>

stage with this knob moved step, or None when it can’t apply there (no free tile for one more piece). Knobs apply in the order given, each to the result of the one before; a knob at 0 isn’t applied.

Source

fn describe(&self, step: i32) -> String

The change of step in plain words, such as "the foe trips 10% less often".

Provided Methods§

Source

fn stride(&self) -> u32

The first step size the search tries: a coarse knob (every enemy’s level) starts larger. The search halves it down to 1.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§