pub trait Sim<N>where
N: Neighborhood,{
type Cell: 'static;
type Diff: 'static;
type Flow;
// Required methods
fn compute(&self, cells: N::Neighbors<'_, Self::Cell>) -> Self::Diff;
fn egress(
&self,
cell: &mut Self::Cell,
diffs: N::Neighbors<'_, Self::Diff>,
) -> N::Edges<Self::Flow>;
fn ingress(&self, cell: &mut Self::Cell, flows: N::Edges<Self::Flow>);
fn cell_padding(&self) -> Self::Cell;
fn diff_padding(&self) -> Self::Diff;
fn flow_padding(&self) -> Self::Flow;
}
Expand description
Defines a simulation for complicated things that have too much state to abandon on the next cycle.
This enforces a rule in that all new cells are only produced from old board state. This prevents the update order from breaking the simulation.
Required Associated Types§
Required Methods§
Sourcefn compute(&self, cells: N::Neighbors<'_, Self::Cell>) -> Self::Diff
fn compute(&self, cells: N::Neighbors<'_, Self::Cell>) -> Self::Diff
At this stage, everything is immutable, and the diff can be computed that describes what will change between simulation states.
Sourcefn egress(
&self,
cell: &mut Self::Cell,
diffs: N::Neighbors<'_, Self::Diff>,
) -> N::Edges<Self::Flow>
fn egress( &self, cell: &mut Self::Cell, diffs: N::Neighbors<'_, Self::Diff>, ) -> N::Edges<Self::Flow>
At this stage, changes are made to the cell based on the diff and then any owned state that needs to be moved to neighbors must be returned as part of the flow.
Sourcefn ingress(&self, cell: &mut Self::Cell, flows: N::Edges<Self::Flow>)
fn ingress(&self, cell: &mut Self::Cell, flows: N::Edges<Self::Flow>)
At this stage, the flow is received from all neighbors, allowing state to be added to this cell.
Sourcefn cell_padding(&self) -> Self::Cell
fn cell_padding(&self) -> Self::Cell
The cell used as padding.
Sourcefn diff_padding(&self) -> Self::Diff
fn diff_padding(&self) -> Self::Diff
The diff used as padding.
Sourcefn flow_padding(&self) -> Self::Flow
fn flow_padding(&self) -> Self::Flow
The flow used as padding.