Struct rlifesrc_lib::World
source · pub struct World<R: Rule, A: Algorithm<R>> { /* private fields */ }
Expand description
The world.
Implementations§
source§impl<R: Rule, A: Algorithm<R>> World<R, A>
impl<R: Rule, A: Algorithm<R>> World<R, A>
sourcepub fn search(&mut self, max_step: Option<u64>) -> Status
pub fn search(&mut self, max_step: Option<u64>) -> Status
The search function.
Returns Status::Found
if a result is found,
Status::None
if such pattern does not exist,
Status::Searching
if the number of steps exceeds max_step
and no results are found.
source§impl<R: Rule> World<R, LifeSrc>
impl<R: Rule> World<R, LifeSrc>
sourcepub fn new_with_rule<A: Algorithm<R>>(config: &Config, rule: R) -> World<R, A>
pub fn new_with_rule<A: Algorithm<R>>(config: &Config, rule: R) -> World<R, A>
Creates a new world from the configuration and the rule.
sourcepub fn new_lifesrc(config: &Config, rule: R) -> Self
pub fn new_lifesrc(config: &Config, rule: R) -> Self
Creates a new world from the configuration and the rule,
using the LifeSrc
algorithm.
source§impl<R: Rule<IsGen = False>> World<R, Backjump<R>>
impl<R: Rule<IsGen = False>> World<R, Backjump<R>>
sourcepub fn new_backjump(config: &Config, rule: R) -> Self
pub fn new_backjump(config: &Config, rule: R) -> Self
Creates a new world from the configuration and the rule,
using the Backjump
algorithm.
source§impl<R: Rule, A: Algorithm<R>> World<R, A>
impl<R: Rule, A: Algorithm<R>> World<R, A>
sourcepub fn get_cell_state(&self, coord: Coord) -> Option<State>
pub fn get_cell_state(&self, coord: Coord) -> Option<State>
Gets the state of a cell. Returns Err(())
if there is no such cell.
sourcepub const fn is_gen_rule(&self) -> bool
pub const fn is_gen_rule(&self) -> bool
Whether the rule is a Generations rule.
sourcepub fn is_b0_rule(&self) -> bool
pub fn is_b0_rule(&self) -> bool
Whether the rule contains B0
.
In other words, whether a cell would become ALIVE
in the next
generation, if all its neighbors in this generation are dead.
sourcepub fn cell_count_gen(&self, t: i32) -> u32
pub fn cell_count_gen(&self, t: i32) -> u32
Number of known living cells in some generation.
For Generations rules, dying cells are not counted.
sourcepub fn cell_count(&self) -> u32
pub fn cell_count(&self) -> u32
Minimum number of known living cells in all generation.
For Generations rules, dying cells are not counted.
sourcepub fn set_max_cell_count(&mut self, max_cell_count: Option<u32>)
pub fn set_max_cell_count(&mut self, max_cell_count: Option<u32>)
Set the max cell counts.
Currently this is the only parameter that you can change during the search.
sourcepub fn rle_gen(&self, t: i32) -> String
pub fn rle_gen(&self, t: i32) -> String
Displays the whole world in some generation, in a mix of Plaintext and RLE format.
- Dead cells are represented by
.
; - Living cells are represented by
o
for rules with 2 states,A
for rules with more states; - Dying cells are represented by uppercase letters starting from
B
; - Unknown cells are represented by
?
; - Each line is ended with
$
; - The whole pattern is ended with
!
.
sourcepub fn plaintext_gen(&self, t: i32) -> String
pub fn plaintext_gen(&self, t: i32) -> String
Displays the whole world in some generation in Plaintext format.
Do not use this for Generations rules.
- Dead cells are represented by
.
; - Living and Dying cells are represented by
o
; - Unknown cells are represented by
?
.