pub struct GridModelState<M: GridModel> { /* private fields */ }Expand description
Engine wrapper that implements SimState for any GridModel.
Implementations§
Source§impl<M: GridModel> GridModelState<M>
impl<M: GridModel> GridModelState<M>
Sourcepub fn from_params(params: &[ParamValue]) -> Self
pub fn from_params(params: &[ParamValue]) -> Self
Builds a state from the full parameter list, with its RNG starting from GRID_INIT_SEED.
Sourcepub fn from_params_seeded(params: &[ParamValue], seed: Option<u64>) -> Self
pub fn from_params_seeded(params: &[ParamValue], seed: Option<u64>) -> Self
Builds a state whose RNG starts from seed, or GRID_INIT_SEED when it is None.
Sourcepub fn from_cells(params: &[ParamValue], cells: &[u8]) -> Option<Self>
pub fn from_cells(params: &[ParamValue], cells: &[u8]) -> Option<Self>
Builds a state whose grid holds cells, with the default seeds.
Returns None unless cells is exactly the length params implies.
Trait Implementations§
Source§impl<M: GridModel> Debug for GridModelState<M>
impl<M: GridModel> Debug for GridModelState<M>
Source§impl<M: GridModel> SimState for GridModelState<M>
impl<M: GridModel> SimState for GridModelState<M>
Source§fn grid_view(&self) -> Option<GridView<'_>>
fn grid_view(&self) -> Option<GridView<'_>>
Returns the grid layer to draw, if the state has one. Read more
Source§fn stats(&self) -> Vec<StatEntry>
fn stats(&self) -> Vec<StatEntry>
Returns the current statistics, one entry per declared series.
Source§fn act(&mut self, index: usize) -> bool
fn act(&mut self, index: usize) -> bool
Runs the model’s action at
index, between ticks, and returns whether it ran. Read moreSource§fn population(&self) -> u64
fn population(&self) -> u64
Size of the population: its cells, its agents or its live nodes.
Source§fn heap_bytes(&self) -> usize
fn heap_bytes(&self) -> usize
Approximate size in bytes of the memory this state owns, on the host for a CPU state and on the device
for a GPU state.
Source§fn parallel_jobs(&self) -> Option<usize>
fn parallel_jobs(&self) -> Option<usize>
Number of jobs that one step splits into.
None if a backend has no such split.Source§fn point_view(&self) -> Option<PointView<'_>>
fn point_view(&self) -> Option<PointView<'_>>
Returns the agents to draw, if the state has any.
Source§fn edge_view(&self) -> Option<EdgeView<'_>>
fn edge_view(&self) -> Option<EdgeView<'_>>
Returns the edges to draw between the positions from
SimState::point_view.Source§fn prepare_view(&mut self)
fn prepare_view(&mut self)
Prepares the views before a snapshot is built. Read more
Source§fn set_layout(&mut self, _on: bool, _budget_ms: f32) -> bool
fn set_layout(&mut self, _on: bool, _budget_ms: f32) -> bool
Turns the layout on or off, with a time budget per publish in milliseconds. Read more
Source§fn relax_layout(&mut self)
fn relax_layout(&mut self)
Runs the layout for one time budget, if it is on. Read more
Auto Trait Implementations§
impl<M> Freeze for GridModelState<M>
impl<M> RefUnwindSafe for GridModelState<M>where
CaField<M>: RefUnwindSafe,
impl<M> Send for GridModelState<M>
impl<M> Sync for GridModelState<M>
impl<M> Unpin for GridModelState<M>
impl<M> UnsafeUnpin for GridModelState<M>where
CaField<M>: UnsafeUnpin,
impl<M> UnwindSafe for GridModelState<M>where
CaField<M>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more