Struct conway::Universe
[−]
[src]
pub struct Universe { /* fields omitted */ }
Represents a wrapping universe in Conway's game of life.
Methods
impl Universe
[src]
fn get_cell_state(
&mut self,
col: usize,
row: usize,
player_id: Option<usize>
) -> CellState
[src]
&mut self,
col: usize,
row: usize,
player_id: Option<usize>
) -> CellState
fn set_unchecked(&mut self, col: usize, row: usize, new_state: CellState)
[src]
fn set(
&mut self,
col: usize,
row: usize,
new_state: CellState,
player_id: usize
)
[src]
&mut self,
col: usize,
row: usize,
new_state: CellState,
player_id: usize
)
fn toggle_unchecked(
&mut self,
col: usize,
row: usize,
opt_player_id: Option<usize>
) -> CellState
[src]
&mut self,
col: usize,
row: usize,
opt_player_id: Option<usize>
) -> CellState
fn toggle(
&mut self,
col: usize,
row: usize,
player_id: usize
) -> Result<CellState, ()>
[src]
&mut self,
col: usize,
row: usize,
player_id: usize
) -> Result<CellState, ()>
fn new(
width: usize,
height: usize,
is_server: bool,
history: usize,
num_players: usize,
player_writable: Vec<Region>,
fog_radius: usize
) -> Result<Universe, &'static str>
[src]
width: usize,
height: usize,
is_server: bool,
history: usize,
num_players: usize,
player_writable: Vec<Region>,
fog_radius: usize
) -> Result<Universe, &'static str>
Instantiate a new blank universe with the given width and height, in cells. The universe is at generation 1.
fn width(&self) -> usize
[src]
Return width in cells.
fn height(&self) -> usize
[src]
Return height in cells.
fn latest_gen(&self) -> usize
[src]
Get the latest generation number (1-based).
fn next(&mut self) -> usize
[src]
Compute the next generation. Returns the new latest generation number.
fn each_non_dead(
&self,
region: Region,
visibility: Option<usize>,
callback: &mut FnMut(usize, usize, CellState)
)
[src]
&self,
region: Region,
visibility: Option<usize>,
callback: &mut FnMut(usize, usize, CellState)
)
Iterate over every non-dead cell in the universe for the current generation. region
is
the rectangular area used for restricting results. visibility
is an optional player_id;
if specified, causes cells not visible to the player to be passed as CellState::Fog to the
callback.
Callback receives (x, y, cell_state).
fn each_non_dead_full(
&self,
visibility: Option<usize>,
callback: &mut FnMut(usize, usize, CellState)
)
[src]
&self,
visibility: Option<usize>,
callback: &mut FnMut(usize, usize, CellState)
)
Iterate over every non-dead cell in the universe for the current generation.
visibility
is an optional player_id, allowing filtering based on fog.
Callback receives (x, y, cell_state).
fn region(&self) -> Region
[src]
Get a Region of the same size as the universe