-- Competition entry of Kenneth Strouts -- To run, load the program in ghci and type showEntry (this call ensures a sensible scale factor is used.) import LSystem -- Colour declerations green1 = Colour 0.05 0.25 0.00 green2 = Colour 0.00 0.30 0.90 green3 = Colour 0.90 0.30 0.00 green4 = Colour 0.00 0.25 0.00 gr = Colour 0.0 0.0 0.4 s1 = Colour 0.9 0.9 0.0 s2 = Colour 0.7 0.3 0.0 s3 = Colour 0.2 0.0 0.0 -- Plant l-systems plant1 :: Int -> Command plant1 x = k x where k 0 = GrabPen green1 :#: Go 10 k (x+1) = k x :#: m :#: k x :#: Branch ( f x :#: p :#: k x ) f 0 = GrabPen green2 :#: Go 7 f (x+1) = f x :#: m :#: f x :#: Branch ( f x :#: p :#: f x ) p = Turn 10 m = Turn (-1) plant2 :: Int -> Command plant2 x = k x where k 0 = GrabPen green4 :#: Go 10 k (x+1) = l x :#: p :#: Branch ( k x :#: p :#: k x :#: p :#: k x ) :#: l x :#: m :#: Branch ( k x :#: m :#: k x :#: m :#: k x ) l 0 = GrabPen green2 :#: Go 10 l (x+1) = k x :#: k x :#: k x p = Turn (-10) m = Turn (10) -- Sun l-system sun :: Int -> Command sun x = k x where k 0 = GrabPen s1 :#: Go 3 :#: GrabPen s2 :#: Go 3 k (x+1) = k x :#: m :#: k x :#: Branch ( f x :#: p :#: k x ) f 0 = GrabPen s2 :#: Go 4 :#: GrabPen s3 :#: Go 3 f (x+1) = f x :#: m' :#: f x :#: Branch ( f x :#: p' :#: f x ) p = Turn 10 m = Turn (-10) p' = Turn 20 m' = Turn (-20) -- Ground turtle graphic ground :: Command ground = GrabPen gr :#: Go 2500 :#: Turn 270 :#: Go 5 :#: Turn 270 :#: Go 2500 :#: Turn 90 :#: Go 1 :#: Turn 90 :#: Go 2500 -- Picture picture :: Command picture = GrabPen Inkless :#: Turn 90 :#: Go 400 :#: Turn 270 :#: plant1 6 :#: GrabPen Inkless :#: Turn 190 :#: Go 850 :#: Turn 240 :#: GrabPen black :#: plant2 4 :#: Turn 120 :#: GrabPen Inkless :#: Go 620 :#: Turn 143 :#: ground :#: GrabPen Inkless :#: Turn 100 :#: Go 1250 :#: sun 7 -- Display command showEntry = display 0.24 picture