[−][src]Struct conway::universe::GenState
Methods
impl GenState
[src]
pub fn set_unchecked(&mut self, col: usize, row: usize, new_state: CellState)
[src]
Sets the state of a cell, with minimal checking. It doesn't support setting
CellState::Fog
.
Panics
Panics if an attempt is made to set an unknown cell.
pub fn copy_from_bit_grid(
&mut self,
src: &BitGrid,
dst_region: Region,
opt_player_id: Option<usize>
)
[src]
&mut self,
src: &BitGrid,
dst_region: Region,
opt_player_id: Option<usize>
)
Copies from src
BitGrid to this GenState as the player specified by opt_player_id
,
unless opt_player_id
is None
. This is an "or" operation, so any existing alive cells
are retained, though they may change ownership. Walls, however, are preserved. Fog is
cleared on a cell-by-cell basis, rather than using fog radius.
IMPORTANT: dst_region should not extend beyond GenState, nor beyond player's writable region. Caller may ensure this using Region::intersection.
The top-left cell (that is, the cell at (0,0)
) in src
gets written to (dst_region.top(), dst_region.left())
in dst
.
pub fn diff(&self, new: &GenState, visibility: Option<usize>) -> GenStateDiff
[src]
Creates a "diff" RLE pattern (contained within GenStateDiff) showing the changes present in
new
, using self
as a base (that is, self
is assumed to be "old"). If visibility
is
not None
, only the changes visible to specified player will be recorded.
The gen0
field of the result will be equal to self.gen_or_none.unwrap()
and the gen1
field will be equal to new.gen_or_none.unwrap()
.
When visibility
is Some(player_id)
, then for all possible gs0
and gs1
where
player_id
is valid and dimensions match, the following should be true:
let gsdiff = gs0.diff(&gs1, visibility); gsdiff.pattern.to_grid(&mut new_gs, visibility).unwrap(); assert_eq!(new_gs, gs1);
Panics:
- This will panic if either
self.gen_or_none
ornew.gen_or_none
isNone
. - This will panic if the lengths of the
player_states
vectors do not match. - This will panic if the dimensions of the grids do not match.
pub fn clear(&mut self)
[src]
Zeroes out all bit grids. Note: this means fog is cleared for all players.
pub fn copy(&self, dest: &mut GenState)
[src]
Trait Implementations
impl CharGrid for GenState
[src]
fn width(&self) -> usize
[src]
Width in cells
fn height(&self) -> usize
[src]
Height in cells
fn write_at_position(
&mut self,
col: usize,
row: usize,
ch: char,
visibility: Option<usize>
)
[src]
&mut self,
col: usize,
row: usize,
ch: char,
visibility: Option<usize>
)
fn is_valid(ch: char) -> bool
[src]
fn get_run(
&self,
col: usize,
row: usize,
visibility: Option<usize>
) -> (usize, char)
[src]
&self,
col: usize,
row: usize,
visibility: Option<usize>
) -> (usize, char)
Given a starting cell at (col, row)
, get the character at that cell, and the number of
contiguous identical cells considering only this cell and the cells to the right of it.
This is intended for exporting to RLE.
The visibility
parameter, if not None
, is used to generate a run as observed by a
particular player.
Returns
(run_length, ch)
Panics
This function will panic if col
, row
, or visibility
(Some(player_id)
) are out of bounds.
fn to_pattern(&self, visibility: Option<usize>) -> Pattern
[src]
Returns a Pattern that describes this CharGrid
as viewed by specified player if visibility.is_some()
, or a fog-less view if visibility.is_none()
. Read more
impl PartialEq<GenState> for GenState
[src]
impl Clone for GenState
[src]
fn clone(&self) -> GenState
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for GenState
[src]
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,