Monday 25 February 2008

Project Update: Entropy Earth

Feature: L-Systems

L-Systems are a funny idea, I personally view them from a perspective of they're a language within a language which writes itself based upon the rules of a said language. Which is exactly what they are... But they're not that complicated at all really.

The process of generating something with an L-System requires that a grammar of some description is defined, and that the elements of that grammar have a result. It's Computer Sciene 101 stuff in alot of ways, and in a bunch of others it more parsing and language translation.

Okay, so I figured that it's probably best to allow whoever is writing said L-System to have absolute control over it so, the grammar is defineable. I'm currently using the following:

'X' ->"D[+X][-X]DX"
'D' -> "DD"

When we construct our string using our defined rewriting rule what we end up with is something like as follows:

X ->"D[+X][-X]DX"
D[+X][-X]DX - > DD[+D[+X][-X]DX][-D[+X][-X]DX]DDD[+X][-X]DX

This string obviously grows and grows at a dramatic rate.

This is a common grammar, we use the initiator X and then set a number of iterations, and as a result I feel a good starting point, which provides a basic 2D result.


While this is obviously a work in progress, it's always nice to have good results early on.

Okay anyways, once the L-System generates it's final resulting string, which may I add over the amount of iterations in the image is a very large string.

The characters of the string are parsed, which gives us our mini-language each character yeilds some manner of result, this is based upon Old Turtle drawing systems.

So I'm using:

{D} -> Draw over a distance.
{+} -> Positive Rotate on Z Axis.
{-} -> Negative Rotate on Z Axis.
{R} -> Right Rotate around Limb.
{L} -> Left Rotate around Limb.
{[} -> Push Data onto Stack.
{]} -> Pop Data off of the Stack.
{(} -> Number Input Begin.
{)} -> Number Input End.

While I'm not currently using all the commands that I have written, I am starting to open up a tremendious amount of power, notice that X isn't a command thus X is ignored when we come to draw out the result.

No comments: