pub trait AutomatonImpl {
// Required methods
fn new(states: u8, size: usize, rule: Rule) -> Self;
fn skipped_iter(
&mut self,
steps: u32,
skip: u32,
scale: u16,
) -> Box<dyn Iterator<Item = Vec<u8>> + '_>;
fn size(&self) -> usize;
fn states(&self) -> u8;
fn init_from_pattern(&mut self, pattern_fname: &str);
fn update(&mut self);
fn random_init(&mut self);
fn grid(&self) -> Vec<u8> ⓘ;
// Provided method
fn iter(&mut self, steps: u32) -> Box<dyn Iterator<Item = Vec<u8>> + '_> { ... }
}Expand description
An automaton must implement this trait.
Required Methods§
Sourcefn new(states: u8, size: usize, rule: Rule) -> Self
fn new(states: u8, size: usize, rule: Rule) -> Self
Make a new cellular automaton with a given grid size, number of states per cells and rule.
use rust_ca::rule::Rule;
use rust_ca::automaton::Automaton;
use rust_ca::automaton::AutomatonImpl;
let automaton = Automaton::new(3, 128, Rule::random(1, 2));Sourcefn skipped_iter(
&mut self,
steps: u32,
skip: u32,
scale: u16,
) -> Box<dyn Iterator<Item = Vec<u8>> + '_>
fn skipped_iter( &mut self, steps: u32, skip: u32, scale: u16, ) -> Box<dyn Iterator<Item = Vec<u8>> + '_>
Returns an boxed iterator of CA steps, skipping every skip step and
scaling the grid by a factor scale.
Sourcefn init_from_pattern(&mut self, pattern_fname: &str)
fn init_from_pattern(&mut self, pattern_fname: &str)
Initialize all the cells of the grid from a pattern file.
Sourcefn random_init(&mut self)
fn random_init(&mut self)
Randomly set all the cells of the cellular automaton grid
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.