Struct foundry::Grid[][src]

pub struct Grid { /* fields omitted */ }

This struct contains the grid of a life cellular automaton.

This grid is stored as a Vec<bool>. When it is toroidal, its size is constant. When it is not, it is resized when computing the next generation according to the size of the contained pattern.

The origin of the pattern is also stored in Grid: the coordinates of its north west corner is stored as a (usize, usize).

It also contains the cellular automaton's rules stored as two Vec<u8>s. These are the survival and birth conditions into survival and birth respectivly.

Methods

impl Grid
[src]

Returns the coordinates of the cell at the upper left corner of the current Grid.

Returns the size of the current Grid's pattern.

impl Grid
[src]

Returns a new Grid encoded within a file located at path.

Errors

If there is an IO error or the file isn't a valid life file, an error of the type FileParsingErrorKind will be returned.

Writes the Grid into a file located at path.

Errors

If there is an IO error, an error of the type io::Error will be returned.

impl Grid
[src]

Randomizes the current Grid by setting a random state to each cell.

Computes the next generation of the current Grid and updates it.

impl Grid
[src]

Returns a new Grid:

  • containing the file format frmt
  • toroidal if trdl is true, resizable otherwise
  • containing the rules given by srvl and brth
  • whose grid's size is determined by width and height

Returns a new Grid and initializes its cells randomly.

Returns the file format used.

Sets a new file format for this Grid.

Returns true if the grid is toroidal. Otherwise the grid is resizable.

Returns the survival conditions of the cellular automaton.

Redefines the survival conditions of the cellular automaton.

Returns the birth conditions of the cellular automaton.

Redefines the birth conditions of the cellular automaton.

Returns the width of the grid.

Returns the height of the grid.

Returns the state of the cell at the coordinates (x, y).

If the coordinates are out of bounds and the grid is toroidal, then it returns the state of the cell at the coordinates modulo the size of the grid. Otherwise, if the coordinates are out of bounds but the grid is not toroidal, it returns 0u8.

Modifies the state of the cell at the coordinates (x, y) with state. Returns Err(GridErrorKind::OutOfBoundCoords) if the coordinates are out of bounds.

Trait Implementations

impl Clone for Grid
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Debug for Grid
[src]

Formats the value using the given formatter. Read more

impl Display for Grid
[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl Send for Grid

impl Sync for Grid