Skip to main content

SimulationRunner

Struct SimulationRunner 

Source
pub struct SimulationRunner<G: PrintableGame> { /* private fields */ }
Expand description

Drives a Simulator behind a fixed dashboard.

The game’s own viewport sits on the left, a stats panel and (when a human is up) an action-select menu stack on the right, and a scrolling log strip runs along the bottom.

Implements App for every Backend, so the same runner drives a real terminal (retroglyph-crossterm) or an in-memory retroglyph_core::backend::Headless test session unchanged; run is the convenience entry point for the former. Escape ends the loop early regardless of whose turn it is; once the match reaches a terminal state the dashboard keeps rendering the final position (rather than exiting the instant it happens, which would hide it) and waits for Enter or Escape to close.

Implementations§

Source§

impl<G: PrintableGame> SimulationRunner<G>

Source

pub fn new(simulator: Simulator<G>, ai_tick: Duration) -> Self

Wraps simulator, polling an AI-controlled active seat for a move once every ai_tick of wall-clock time (via Frame::delta) rather than on every single frame, so AI turns are visible instead of flashing past.

Fixes the dashboard’s viewing seat for the whole match at Simulator::primary_human (or a neutral spectator if there is no human seat), computed once here rather than every frame.

Source

pub fn is_terminal(&self) -> bool

Returns whether the wrapped match has reached a terminal state.

True while the dashboard is showing its “match over” prompt and waiting for Enter/Escape, per SimulationRunner’s own docs.

Source

pub fn into_simulator(self) -> Simulator<G>

Unwraps the runner, returning the Simulator at its current state (e.g. after the loop exits, to inspect the final position or log).

Trait Implementations§

Source§

impl<G, B> App<B> for SimulationRunner<G>
where G: PrintableGame, G::Action: Debug, B: Backend,

Source§

fn update(&mut self, term: &mut Terminal<B>, frame: &Frame) -> Flow

Advance and render one frame. Read more

Auto Trait Implementations§

§

impl<G> !RefUnwindSafe for SimulationRunner<G>

§

impl<G> !Send for SimulationRunner<G>

§

impl<G> !Sync for SimulationRunner<G>

§

impl<G> !UnwindSafe for SimulationRunner<G>

§

impl<G> Freeze for SimulationRunner<G>
where Simulator<G>: Freeze,

§

impl<G> Unpin for SimulationRunner<G>
where Simulator<G>: Unpin,

§

impl<G> UnsafeUnpin for SimulationRunner<G>

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.