[][src]Trait conway::grids::CharGrid

pub trait CharGrid {
    fn write_at_position(
        &mut self,
        col: usize,
        row: usize,
        ch: char,
        visibility: Option<usize>
    );
fn is_valid(ch: char) -> bool;
fn width(&self) -> usize;
fn height(&self) -> usize;
fn get_run(
        &self,
        col: usize,
        row: usize,
        visibility: Option<usize>
    ) -> (usize, char); fn to_pattern(&self, visibility: Option<usize>) -> Pattern { ... } }

Required methods

fn write_at_position(
    &mut self,
    col: usize,
    row: usize,
    ch: char,
    visibility: Option<usize>
)

Write a char ch to (col, row).

Panics

Panics if:

  • col or row are out of range
  • char is invalid for this type. Use is_valid to check first.
  • visibility is invalid. That is, it equals Some(player_id), but there is no such player_id.

fn is_valid(ch: char) -> bool

Is ch a valid character?

fn width(&self) -> usize

Width in cells

fn height(&self) -> usize

Height in cells

fn get_run(
    &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.

Loading content...

Provided methods

fn to_pattern(&self, visibility: Option<usize>) -> Pattern

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().

Loading content...

Implementors

impl CharGrid for BitGrid[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]

_visibility is ignored, since BitGrids have no concept of a player.

fn get_run(
    &self,
    col: usize,
    row: usize,
    _visibility: Option<usize>
) -> (usize, char)
[src]

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 argument is unused and should be None.

Returns

(run_length, ch)

Panics

This function will panic if col or row are out of bounds.

fn to_pattern(&self, visibility: Option<usize>) -> Pattern[src]

impl CharGrid for GenState[src]

fn width(&self) -> usize[src]

Width in cells

fn height(&self) -> usize[src]

Height in cells

fn get_run(
    &self,
    col: usize,
    row: usize,
    visibility: Option<usize>
) -> (usize, char)
[src]

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]

impl CharGrid for Universe[src]

fn width(&self) -> usize[src]

Return width in cells.

fn height(&self) -> usize[src]

Return height in cells.

fn to_pattern(&self, visibility: Option<usize>) -> Pattern[src]

Loading content...