L Systems - PowerPoint PPT Presentation

About This Presentation
Title:

L Systems

Description:

L Systems – PowerPoint PPT presentation

Number of Views:84
Avg rating:3.0/5.0
Slides: 24
Provided by: macs3
Category:
Tags: systems | ternary

less

Transcript and Presenter's Notes

Title: L Systems


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 youll 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
Heres what happens when we apply rules a few
times
AAA ? BBCBBCBBC ? abACabACabAC ?
abBBCCabBBCCabBBCC ? ababAabACCababAabACCababAabA
CC Etc
5
So what?
AAA ? BBCBBCBBC ? abACabACabAC ?
abBBCCabBBCCabBBCC ? ababAabACCababAabACCababAabA
CC
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?FF--FF
  • 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

FF--FF FF--FF -- FF--FF FF--FF
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
FF--FF
FF--FF
FF--FF
FF--FF
FF--FF
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 theres 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).

FFF----fF----f
vs.
FFF-F-FF-F
10
Rules for Types of Branching
T?TB-BT T?T---BT T?TB-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
Example of this L system
F?FFF-FF
Axiom F. 1 application 2 applications 4
applications
12
Stochastic L-Systems
  • Conditional firing of rules
  • F ? ltsomethinggt probability1
  • F ? ltsomething2gt probability2
  • etc
  • Example Random Bushes
  • F ? FFF-FF 0.33
  • F ? FFF 0.33
  • F ? F-FF 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 ? FF/F\F
15
Other Turtle Commands
  • !(w) changes width of lines (cylinders) from
    that point onward
  • _at_O draws a sphere
  • Useful at branch joints
  • Many more possible, and used, to do with
  • Colour
  • Texture
  • Environment (see later)

16
Parameterized Productions
  • Non-terminals can be parameterized
  • Rules can be conditional
  • NT(param) cond ? result
  • Example Fibonacci
  • A(n) n gt 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-BF?P(x,y)A
  • B ? F?P(x,y)_at_oB
  • ?P(x,y) 4x2 (y-10)2 gt 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
Write a Comment
User Comments (0)
About PowerShow.com