CA rules parsers
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
. - Non-isotropic Life-like,
e.g.,
MAPARYXfhZofugWaH7oaIDogBZofuhogOiAaIDogIAAgAAWaH7oaIDogGiA6ICAAIAAaIDogIAAgACAAIAAAAAAAA
. - Totalistic Hexagonal,
e.g.,
B2/S34H
. - Isotropic non-totalistic Hexagonal,
e.g.,
B2o3-o4m/S12m3o4m5H
. - Non-isotropic Hexagonal,
e.g.,
MAPFgFoF2gXgH5oF4B+gH4A6AH
. - von Neumann neighborhood,
e.g.,
B2/S013V
. - Non-isotropic von Neumann,
e.g.,
MAPHmlphg
. - The corresponding Generations rules
of the above rules, e.g.,
3457/357/5
.
For non-Generations rules, four different notations are supported:
- B/S notation (
B3/S23
) - S/B notation (
23/3
) - MAP strings
for non-isotropic rules
(
MAPARYXfhZofugWaH7oaIDogBZofuhogOiAaIDogIAAgAAWaH7oaIDogGiA6ICAAIAAaIDogIAAgACAAIAAAAAAAA
)
For Generations rules, four different notations are supported:
- B/S notation (
B357/S3457/C5
) - The notation used by Golly (
3457/357/5
) - The notation used by Catagolue (
g5b357s3457
) - MAP strings
for non-isotropic rules
(
MAPARYBFxZpF38WaRd/aZZ//hZpF39pln/+aZZ//pZp/ukWaRd/aZZ//mmWf/6Waf7paZZ//pZp/umWaf7paZbplg/5
)
Please refer to Life Wiki for detailed definitions and notations of these rule strings.
Usage
use ParseLife;
// Define a struct for your rule:
// Implement a parser trait for your rule:
// The choice of the trait depends on the type of rules you want to parse.
// Then you can parse a rule string:
let life = parse_rule.unwrap;
assert_eq!
For details, please refer to the doc.