~/lab/lsystem — zsh
cd ..thomas@parkin ~/lab $ ./lsystem# grammars that grow plants and space-filling curves
man lsystem

Lindenmayer systems (1968) are string-rewriting grammars. Start from an axiom and replace every symbol by its rule, in parallel, over and over: F → FF doubles every line each generation. The resulting string is then read as instructions for a turtle: F draws forward, +/-turn by the angle, [ saves the turtle's position on a stack and ] jumps back to it. That stack is what makes branches.

The string grows exponentially. The plant at 7 iterations is over 100,000 symbols. Small angle changes make very different shapes, so try nudging the slider. "Jitter" randomly perturbs each turn, which makes plants look less like clip art. Colour shows branch depth for plants and drawing order for curves.