pub struct CaField<M>where
M: GridModel,{ /* private fields */ }Expand description
Double-buffered u8 cells stepped by M’s neighbourhood rule.
Implementations§
Source§impl<M> CaField<M>where
M: GridModel,
impl<M> CaField<M>where
M: GridModel,
Sourcepub fn grid_mut(&mut self) -> &mut Grid2D<u8>
pub fn grid_mut(&mut self) -> &mut Grid2D<u8>
Write access, for an action that rewrites the cells.
Sourcepub fn parallel_jobs(&self) -> usize
pub fn parallel_jobs(&self) -> usize
Number of rayon jobs one tick splits into.
Sourcepub fn with_seed(
extent: Extent,
params: &[ParamValue],
seed: Option<u64>,
) -> CaField<M>
pub fn with_seed( extent: Extent, params: &[ParamValue], seed: Option<u64>, ) -> CaField<M>
Builds a field seeded from seed, or from GRID_INIT_SEED when it is None.
Sourcepub fn from_cells(extent: Extent, cells: &[u8]) -> Option<CaField<M>>
pub fn from_cells(extent: Extent, cells: &[u8]) -> Option<CaField<M>>
Builds a field holding cells, seeded from GRID_INIT_SEED.
Returns None unless cells is exactly the length extent implies.
Trait Implementations§
Source§impl<M> Debug for CaField<M>where
M: GridModel,
Prints the model’s name and the grid’s size, not its cells.
impl<M> Debug for CaField<M>where
M: GridModel,
Prints the model’s name and the grid’s size, not its cells.
Source§impl<M> FieldLayer for CaField<M>where
M: GridModel,
impl<M> FieldLayer for CaField<M>where
M: GridModel,
Source§type DepositLanes = ()
type DepositLanes = ()
Per agent deposit lanes, filled by the agent passes, or
() for a field without deposit lanes.Source§fn param_descriptors() -> Vec<ParamDescriptor>
fn param_descriptors() -> Vec<ParamDescriptor>
Returns this layer’s own parameters, listed after the model’s parameters.
Source§fn from_params(params: &[ParamValue]) -> <M as GridModel>::Params
fn from_params(params: &[ParamValue]) -> <M as GridModel>::Params
Extracts the hot parameters for one tick. Read more
Source§fn new(extent: Extent, params: &[ParamValue]) -> CaField<M>
fn new(extent: Extent, params: &[ParamValue]) -> CaField<M>
Creates the layer over
extent, from this layer’s own slice of the parameters.Source§fn alloc_deposits(&self, _n: usize)
fn alloc_deposits(&self, _n: usize)
Allocates deposit lanes for
n agents. The engine reuses them every tick.Source§fn update(&mut self, _: &(), p: &<M as GridModel>::Params, tick: u64)
fn update(&mut self, _: &(), p: &<M as GridModel>::Params, tick: u64)
Advances the layer by one tick, with this tick’s deposits.
Source§fn grid_view(&self) -> Option<GridView<'_>>
fn grid_view(&self) -> Option<GridView<'_>>
Returns the cells to draw, or
None for a layer without a grid.Source§fn cell_count(&self) -> usize
fn cell_count(&self) -> usize
Number of cells.
Source§fn heap_bytes(&self) -> usize
fn heap_bytes(&self) -> usize
Heap memory held by the layer, in bytes.
Source§const HAS_GRID: bool = true
const HAS_GRID: bool = true
Whether the layer draws a grid. It must agree with
Self::grid_view.Source§fn prepare_view(&mut self)
fn prepare_view(&mut self)
Turns cells into palette indices. The engine calls it before each snapshot.
Auto Trait Implementations§
impl<M> Freeze for CaField<M>where
PhantomData<M>: Freeze,
impl<M> RefUnwindSafe for CaField<M>where
PhantomData<M>: RefUnwindSafe,
impl<M> Send for CaField<M>where
PhantomData<M>: Send,
impl<M> Sync for CaField<M>where
PhantomData<M>: Sync,
impl<M> Unpin for CaField<M>where
PhantomData<M>: Unpin,
impl<M> UnsafeUnpin for CaField<M>where
PhantomData<M>: UnsafeUnpin,
impl<M> UnwindSafe for CaField<M>where
PhantomData<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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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