algae.ls
Take a look at the systems/algae.ls
file. For convenience it is reproduced
here
config:
step = 100
angle = 45
rules:
axiom = A
A => AB
B => A
Does this look familiar?
Rules
Take a closer look at the rules
section. It defines an axiom just as in the
preceding chapter.
Furthermore it defines two rules. The first rule A => AB
tells us to replace
every symbol A
with its production AB
. The last rule B => A
tells us to
replace each symbol B
with the production A
.
This is exactly like the rules in the preceding chapter.
cargo run
Go into the code
directory and run the following command
cargo run -- -f system/algae.ls -n 0
It should respond with A
. Below the sequence of words generated by the
L-system from the preceding chapter is reproduced.
- A
- AB
- ABA
- ABAAB
Change the -n
parameter in the call to cargo run and check if it corresponds
with the above sequence.
Exercices
- Check other values for the number of iterations.
- check out
cargo run -- --help
.