SHARE
TWEET

L-systems 0.0.1

jeffwincek Dec 15th, 2011 26 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. axiomA='A'
  2. rulesA = {}
  3. rulesA['A'] = 'AB'
  4. rulesA['B'] = 'A'
  5.  
  6. axiomB='B'
  7. rulesB = {}
  8. rulesB['B'] = 'BA'
  9. rulesB['A'] = 'B'
  10.  
  11. axiomF='F--F--F'
  12. rulesF = {}
  13. rulesF['F'] = 'F+F--F+F'
  14.  
  15.  
  16. def compose(axiom, rules):
  17.         output = ""
  18.         for i in axiom:
  19.                 output = output + rules.get(i,i)
  20.         return output
  21.        
  22. def iterate(axiom,rules, times):
  23.         if times == 0:
  24.                 print axiom
  25.         else:
  26.                  iterate(compose(axiom, rules), rules, times -1)
  27.                
  28. iterate(axiomB,rulesB,6)
  29. iterate(axiomA,rulesA,6)
  30. iterate(axiomF,rulesF,6)
  31.  
  32. #special thanks to http://www.4dsolutions.net/ocn/lsystems.html
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top