1 / 23

L Systems

This lecture explores L-Systems, a simple computational system with rules that can lead to emergent behavior. L-Systems are used in computer-generated imaging, evolutionary algorithms, and understanding biological forms.

konen
Download Presentation

L Systems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. L Systems This is lecture 9 (week 9) of Biologically Inspired Computing Various credits for these slides, which have in part been adapted from slides by: Ajit Narayanan,

  2. L-Systems • This is another example of a continuing theme, in which: • the underlying computational system is `simple’ • things happen according to simple rules • the end result has interesting, useful, and/or surprising properties • i.e. … there is emergent behaviour • and, it seems to explain, or help to explain, certain things that we might otherwise think are `magical’, or think that they must have arisen from extremely complex design processes. • L = Lindenmayer, the inventor of the systems we look at today.

  3. L-Systems • are useful for: • Computer-generated imaging (as you’ll soon realise) • Evolutionary Algorithms, as encodings for certain complex structures • Understanding what led to many of the biological forms, especially plants, that we see around us.

  4. L System = (small) set of grammar rules • An L system is a set of grammar rules, • Plus a start symbol (or an initial group of symbols) • Plus a semantics – a way of interpreting the grammar strings E.g. here is a grammar: rule 1: A  BBC rule 2: B  abA Here is a start string: AAA Here’s what happens when we apply rules a few times: AAA  BBCBBCBBC  abACabACabAC  abBBCCabBBCCabBBCC  ababAabACCababAabACCababAabACC Etc …

  5. So what? AAA  BBCBBCBBC  abACabACabAC  abBBCCabBBCCabBBCC  ababAabACCababAabACCababAabACC It becomes interesting when we add the semantics. In this case, Let: a = forward 10 b = left rand(10,40) A = right rand(10,40), forward 5 C = disc diameter rand (2,5), forward 10 Then ababAabACCababAabACCababAabACC = Interesting … but could it be more interesting? What if the semantics involved interpreting the grammar strings as music?

  6. More interesting examples • Grammar symbols: {F,+,–} • Rules: FF+F--F+F • Start symbol (or, axiom): F • Note that when a rule is applied in an L system, it is applied simultaneously to all possible positions. • In this case, after just 2 applications of the rule we get: F+F--F+F+F+F--F+F -- F+F--F+F+F+F--F+F

  7. Now let: • “F” – Draw forward one unit • “f” – Move forward one unit (without making a mark) • “+” – Rotate turtle left • “–” – Rotate turtle right • Units and angles are global constants • Commands change turtle state (position, orientation)

  8. von Koch Snowflake Curve -- +,- = 60o F+F--F+F F+F--F+F F F+F--F+F F+F--F+F+ +F+F--F+F

  9. Branching • The F,+,- and similar systems (i.e. turtle graphics with one turtle) cannot easily model branching structures (such as trees). • Could do it via retracing steps, but there’s a better way. • Turtle state stack • “[” – pushes state onto stack • “]” – pops state from stack • Use “[” to start a branch and “]” when finished to return to its base • So include “[” and “]” in the grammar rule(s). F+F+F----f++F----f+… vs. F[+F[+F][-F]][-F[+F][-F]]

  10. Rules for Types of Branching TT[+B][-B]T TT[---B]+T TT[+B][-B] • Monopodial • Trunk extends undeviated to top • Branches extend perpendicularly • Sympodial • Trunk deviates to top • Branches extend perpendicularly • Binary • Trunk terminates at first branching point • Branches deviate uniformly

  11. FF[+F]F[-F]F Example of this L system: Axiom = F. 1 application; 2 applications; 4 applications

  12. Stochastic L-Systems • Conditional firing of rules F  <something>: probability1 F  <something2>: probability2 etc … • Example: Random Bushes F  F[+F]F[-F]F : 0.33 F  F[+F]F : 0.33 F  F[-F]F : 0.34 • If not stochastic,then deterministic

  13. Parameterized 3-D Turtle Graphics & / \ ^ U • “+(q )” – yaw left • “-(q )” – yaw right • “^(q )” – pitch up • “&(q )” – pitch down • “\(q )” – roll left • “/(q )” – roll right • “F(x)” – draw x units • “f(x)” – move x units L H - +

  14. Ternary Tree, using only: F  F[&F][&/F][&\F]

  15. “!(w)” changes width of lines (cylinders) from that point onward “@O” draws a sphere Useful at branch joints Many more possible, and used, to do with: Colour Texture Environment (see later) Other Turtle Commands

  16. Parameterized Productions • Non-terminals can be parameterized • Rules can be conditional NT(param) : cond result • Example: Fibonacci A(n) : n > 1  A(n-1)A(n-2) A(n) : n = 1  X A(n) : n = 0  e (empty) A(4) = A(3)A(2) = A(2)A(1)A(1)A(0) = A(1)A(0)XX = XXX

  17. Query symbol “?” • “?P(x,y,z)” – position ; “?H(x,y,z)” – heading • Variables (x,y,z) replaced by actual values at current turtle position • Example: Ellipse A  [+B][-B]F?P(x,y)A B  F?P(x,y)@oB ?P(x,y) : 4x2 + (y-10)2 > 100  [+(2y)F][-(2y)F]% • “%” cuts all symbols to end of branch

  18. Open L-Systems • Environmental query “?E(x1,x2,…)” • Queries the environment • Query at current turtle state • Example: Light sensitivity • “?E(r)” how much light does a cluster of leaves of radius r at the current turtle position get? • Result provides a parameter for (typically) distances of growth in that branch.

  19. Evolving Virtual Creatures (Sims, 1994)Paper: available at my site: recommended reading • A classic, exceptional, but rarely copied or bettered experiment with evolutionary algorithms. • Genotype: Similar (in fact equivalent) to an L system, in that the main part was a compact way to represent something that grows into a form. • … chromosomes were directed graphs that specified body segments, limb segments, etc…, their connections to each other, and parameters such as size, shape, constraints on angles, and joint types. • Each individual had a neural network brain, with parameters also encoded in the chromosome. • Sims simulated environments for the creatures, which had realistic physics.

  20. Evolving Virtual Creatures (Sims, 1994)Paper: available at my site

  21. Initial population, of course, is random, and full of very odd looking creatures that thrash about without getting anywhere fast.

  22. Simple fitness functions for different tasks swimming Fitness = distance travelled by centre of gravity Fitness = distance travelled by centre of gravity walking jumping Fitness = max height reached by lowest part of the creature

  23. The Sims film

More Related