Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- def applyRules(ch):
- newstr = ""
- if ch == 'F':
- newstr = 'F-F++F-F' # Rule 1
- else:
- newstr = ch # no rules apply so keep the character
- return newstr
- def processString(oldStr):
- newstr = ""
- for ch in oldStr:
- newstr = newstr + applyRules(ch)
- return newstr
- def createLSystem(numIters,axiom):
- startString = axiom
- endString = ""
- for i in range(numIters):
- endString = processString(startString)
- startString = endString
- return endString
- print(createLSystem(4,"F"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement