Trait Sim

Source
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§

Source

type Cell: 'static

The cells of the grid

Source

type Diff: 'static

Result of the neighbor-observing computation

Source

type Flow

The data which flows to each neighbor.

Required Methods§

Source

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.

Source

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.

Source

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.

Source

fn cell_padding(&self) -> Self::Cell

The cell used as padding.

Source

fn diff_padding(&self) -> Self::Diff

The diff used as padding.

Source

fn flow_padding(&self) -> Self::Flow

The flow used as padding.

Implementors§