<s> class LSystem ( object ) : <EOL> def __init__ ( self ) : <EOL> self . steps = <NUM_LIT:0> <EOL> self . axiom = "<STR_LIT:F>" <EOL> self . rule = "<STR_LIT>" <EOL> self . startLength = <NUM_LIT> <EOL> self . theta = radians ( <NUM_LIT> ) <EOL> reset ( ) <EOL> def reset ( self ) : <EOL> self . production = axiom <EOL> self . drawLength = startLength <EOL> self . generations = <NUM_LIT:0> <EOL> def getAge ( self ) : <EOL> return generations <EOL> def render ( self ) : <EOL> translate ( width / <NUM_LIT:2> , height / <NUM_LIT:2> ) <EOL> steps += <NUM_LIT:5> <EOL> if steps > len ( production ) ( ) : <EOL> steps = len ( production ) ( ) <EOL> for i in range ( steps ) : <EOL> step = production . charAt ( i ) <EOL> if step == '<STR_LIT:F>' : <EOL> rect ( <NUM_LIT:0> , <NUM_LIT:0> , - drawLength , - drawLength ) <EOL> noFill ( ) <EOL> translate ( <NUM_LIT:0> , - drawLength ) <EOL> elif step == '<STR_LIT:+>' : <EOL> rotate ( theta ) <EOL> elif step == '<STR_LIT:->' : <EOL> rotate ( - theta ) <EOL> elif step == '<STR_LIT:[>' : <EOL> pushMatrix ( ) <EOL> elif step == '<STR_LIT:]>' : <EOL> popMatrix ( ) <EOL> def simulate ( self , gen ) : <EOL> while self . getAge ( ) < gen : <EOL> self . production = self . iterate ( self . production , self . rule ) <EOL> def iterate ( self , prod_ , rule_ ) : <EOL> self . drawLength = self . drawLength * <NUM_LIT> <EOL> self . generations += <NUM_LIT:1> <EOL> newProduction = prod_ <EOL> newProduction = newProduction . replace ( "<STR_LIT:F>" , rule_ ) <EOL> return newProduction </s>
