2 """ turtle-example-suite:
4 xtx_lindenmayer_indian.py
6 Each morning women in Tamil Nadu, in southern
7 India, place designs, created by using rice
8 flour and known as kolam on the thresholds of
11 These can be described by Lindenmayer systems,
12 which can easily be implemented with turtle
15 Two examples are shown here:
17 (2) anklets of Krishna
19 Taken from Marcia Ascher: Mathematics
20 Elsewhere, An Exploration of Ideas Across
24 ################################
25 # Mini Lindenmayer tool
26 ###############################
30 def replace( seq
, replacementRules
, n
):
34 newseq
= newseq
+ replacementRules
.get(element
,element
)
38 def draw( commands
, rules
):
50 ################################
51 # Example 1: Snake kolam
52 ################################
64 snake_rules
= {"-":r
, "+":l
, "f":f
, "b":"f+f+f--f--f+f+f"}
65 snake_replacementRules
= {"b": "b+f+b--f--b+f+b"}
66 snake_start
= "b--f--b--f"
68 drawing
= replace(snake_start
, snake_replacementRules
, 3)
77 draw(drawing
, snake_rules
)
79 from time
import sleep
82 ################################
83 # Example 2: Anklets of Krishna
84 ################################
102 krishna_rules
= {"a":A
, "b":B
, "f":F
}
103 krishna_replacementRules
= {"a" : "afbfa", "b" : "afbfbfbfa" }
104 krishna_start
= "fbfbfbfb"
111 drawing
= replace(krishna_start
, krishna_replacementRules
, 3)
112 draw(drawing
, krishna_rules
)
116 if __name__
=='__main__':