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>

source

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>

source

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.

source

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>>

source

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>

source

pub fn get_cell_state(&self, coord: Coord) -> Option<State>

Gets the state of a cell. Returns Err(()) if there is no such cell.

source

pub const fn config(&self) -> &Config

World configuration.

source

pub const fn is_gen_rule(&self) -> bool

Whether the rule is a Generations rule.

source

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.

source

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.

source

pub fn cell_count(&self) -> u32

Minimum number of known living cells in all generation.

For Generations rules, dying cells are not counted.

source

pub const fn conflicts(&self) -> u64

Number of conflicts during the search.

source

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.

source

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 !.
source

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 ?.
source§

impl<R: Rule, A: Algorithm<R>> World<R, A>

source

pub fn ser(&self) -> WorldSer

Available on crate feature serde only.

Saves the world as a WorldSer.

source

pub fn deser(&mut self, ser: &WorldSer) -> Result<(), Error>

Available on crate feature serde only.

Restores the world from the WorldSer.

Trait Implementations§

source§

impl From<World<Life, Backjump<Life>>> for PolyWorld

Convert into LifeBackjump variant.

source§

fn from(v: World<Life, Backjump<Life>>) -> Self

Converts to this type from the input type.
source§

impl From<World<Life, LifeSrc>> for PolyWorld

Convert into Life variant.

source§

fn from(v: World<Life, LifeSrc>) -> Self

Converts to this type from the input type.
source§

impl From<World<LifeGen, LifeSrc>> for PolyWorld

Convert into LifeGen variant.

source§

fn from(v: World<LifeGen, LifeSrc>) -> Self

Converts to this type from the input type.
source§

impl From<World<NtLife, Backjump<NtLife>>> for PolyWorld

Convert into NtLifeBackjump variant.

source§

fn from(v: World<NtLife, Backjump<NtLife>>) -> Self

Converts to this type from the input type.
source§

impl From<World<NtLife, LifeSrc>> for PolyWorld

Convert into NtLife variant.

source§

fn from(v: World<NtLife, LifeSrc>) -> Self

Converts to this type from the input type.
source§

impl From<World<NtLifeGen, LifeSrc>> for PolyWorld

Convert into NtLifeGen variant.

source§

fn from(v: World<NtLifeGen, LifeSrc>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<R, A> !RefUnwindSafe for World<R, A>

§

impl<R, A> !Send for World<R, A>

§

impl<R, A> !Sync for World<R, A>

§

impl<R, A> Unpin for World<R, A>where A: Unpin, R: Unpin, <A as Algorithm<R>>::Reason: Unpin,

§

impl<R, A> !UnwindSafe for World<R, A>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V