[−][src]Crate ca_rules
Parsing rule strings of life-like and other cellular automata.
Currently the following rules are supported:
- Totalistic Life-like,
e.g.,
B3/S23
. - Isotropic non-totalistic Life-like,
e.g.,
B2ci3ai4c8/S02ae3eijkq4iz5ar6i7e
. - Totalistic Hexagonal,
e.g.,
B2/S34H
. - Isotropic non-totalistic Hexagonal,
e.g.,
B2o3-o4m/S12m3o4m5H
. - von Neumann neighborhood,
e.g.,
B2/S013V
. - The corresponding Generations rules
of the above rules, e.g.,
3457/357/5
.
For non-Generations rules, both B/S notation
(B3/S23
) and S/B notation
(23/3
) are supported.
For Generations rules, three different notations are supported:
- B/S notation (
B357/S3457/C5
) - The notation used by Golly (
3457/357/5
) - The notation used by Catagolue (
g5b357s3457
)
Please refer to Life Wiki for detailed definitions and notations of these rule strings.
Example:
use ca_rules::ParseLife; // Define a struct for your rule: #[derive(Debug, Eq, PartialEq)] struct Rule { b: Vec<u8>, s: Vec<u8>, } // Implement a parser trait for your rule: // The choice of the trait depends on the type of rules you want to parse. impl ParseLife for Rule { // Implement a function to construct the rule from b and s data: fn from_bs(b: Vec<u8>, s: Vec<u8>) -> Self { Rule { b, s } } } // Then you can parse a rule string: let life = Rule::parse_rule("B3/S23").unwrap(); assert_eq!( life, Rule { b: vec![3], s: vec![2, 3], } )
Enums
ParseRuleError | Errors that can be returned when parsing rule strings. |
Traits
ParseHex | A trait for parsing totalistic hexagonal rules. |
ParseHexGen | A trait for parsing totalistic hexagonal Generations rules. |
ParseLife | A trait for parsing totalistic life-like rules. |
ParseLifeGen | A trait for parsing totalistic life-like Generations rules. |
ParseNeumann | A trait for parsing totalistic rules with von Neumann neighborhood. |
ParseNeumannGen | A trait for parsing totalistic Generations rules with von Neumann neighborhood. |
ParseNtHex | A trait for parsing non-totalistic hexagonal rules. |
ParseNtHexGen | A trait for parsing non-totalistic hexagonal Generations rules. |
ParseNtLife | A trait for parsing non-totalistic life-like rules. |
ParseNtLifeGen | A trait for parsing non-totalistic life-like Generations rules. |
ParseNtNeumann | A trait for parsing non-totalistic rules with von Neumann neighborhood. |
ParseNtNeumannGen | A trait for parsing non-totalistic Generations rules with von Neumann neighborhood. |