Trait gridsim::Sim[][src]

pub trait Sim<N> where
    N: Neighborhood
{ type Cell: 'static; type Diff: 'static; type Flow; fn compute(&self, cells: N::Neighbors) -> Self::Diff;
fn egress(&self, cell: &mut Self::Cell, diffs: N::Neighbors) -> N::Edges;
fn ingress(&self, cell: &mut Self::Cell, flows: N::Edges);
fn cell_padding(&self) -> Self::Cell;
fn diff_padding(&self) -> Self::Diff;
fn flow_padding(&self) -> Self::Flow; }

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.

Associated Types

type Cell: 'static[src]

The cells of the grid

type Diff: 'static[src]

Result of the neighbor-observing computation

type Flow[src]

The data which flows to each neighbor.

Loading content...

Required methods

fn compute(&self, cells: N::Neighbors) -> Self::Diff[src]

At this stage, everything is immutable, and the diff can be computed that describes what will change between simulation states.

fn egress(&self, cell: &mut Self::Cell, diffs: N::Neighbors) -> N::Edges[src]

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.

fn ingress(&self, cell: &mut Self::Cell, flows: N::Edges)[src]

At this stage, the flow is received from all neighbors, allowing state to be added to this cell.

fn cell_padding(&self) -> Self::Cell[src]

The cell used as padding.

fn diff_padding(&self) -> Self::Diff[src]

The diff used as padding.

fn flow_padding(&self) -> Self::Flow[src]

The flow used as padding.

Loading content...

Implementors

Loading content...