-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexamples.py
More file actions
31 lines (22 loc) · 750 Bytes
/
examples.py
File metadata and controls
31 lines (22 loc) · 750 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from grammar import LSystemGrammar
def algae_growth_example():
alphabet=['A', 'B']
constants=[]
rules={'A':'AB', 'B':'A'}
grammar=LSystemGrammar(alphabet, constants, rules)
axiom='A'
steps=7
string=grammar.generate(axiom, steps)
print('ALGAE GROWTH EXAMPLE\n\tAxiom: '+str(axiom)+'\n\tIterations: '+str(steps)+'\n\tOutput: '+string+'\n')
def fractal_tree_example():
alphabet=['0', '1']
constants=['[', ']']
rules={'1':'11', '0':'1[0]0'}
grammar=LSystemGrammar(alphabet, constants, rules)
axiom='0'
steps=3
string=grammar.generate(axiom, steps)
print('FRACTAL TREE EXAMPLE\n\tAxiom: '+str(axiom)+'\n\tIterations: '+str(steps)+'\n\tOutput: '+string+'\n')
if __name__=="__main__":
algae_growth_example()
fractal_tree_example()