Struct 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> Freeze for World<R, A>
where R: Freeze, A: Freeze,

§

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 R: Unpin, A: Unpin, <A as Algorithm<R>>::Reason: Unpin,

§

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

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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 T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

fn vzip(self) -> V