Trait gridsim::Sim [−][src]
pub trait Sim<'a> { type Cell; type Diff; type Move; type Neighbors; type MoveNeighbors; fn step(
_: &Self::Cell,
_: Self::Neighbors
) -> (Self::Diff, Self::MoveNeighbors); fn update(_: &mut Self::Cell, _: Self::Diff, _: Self::MoveNeighbors); }
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
The type of cells on the grid
type Diff
Represents all information necessary to modify a cell in the previous grid to produce the version in the next
type Move
Data that moves between cells
type Neighbors
Neighborhood of cells.
type MoveNeighbors
Nighborhood of moving data
Required Methods
fn step(_: &Self::Cell, _: Self::Neighbors) -> (Self::Diff, Self::MoveNeighbors)
Performs one step of the simulation, creating diffs and movements that go out to neighbors.
fn update(_: &mut Self::Cell, _: Self::Diff, _: Self::MoveNeighbors)
Updates a cell with a diff and movements into this cell. Note that these movements are the ones produced in each neighboring cell.