Skip to content

A generic L system generation class. Example uses: Generating mazes, creating organic looking decorations.

Notifications You must be signed in to change notification settings

byronhallett/L-system-unity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

L-System class for unity

Usage:

LSystem l = new LSystem();
// Add a symbol for every constant and variable.
// Each symbol must be bound to a function to give it formal functionality
// Each function is a c# Action, which is a delegate with no params and no return
l.AddSymbol('A', GoForward);
l.AddSymbol('B', GoForward);
l.AddSymbol('+', Turn);
l.AddSymbol('-', Turn);
// Add rewrite rules to use in evolution
// key, probablity, rewrite string
l.AddRule('A', 0.5f, "B - A - B");
l.AddRule('A', 0.5f, "B - B - B");
l.AddRule('B', 1.0f, "A + B + A");
// Choose a starting system state (can be string)
l.SetSystem("A");
// Evolve the system by n generations
// This will change the systms internal state
l.EvolveSystem(3);
// Print string if desired, while designing pattern
// print(l.GetSystemString());
// Call the functions bound to each symbol in the current system state
l.EvaluateSystem();

About

A generic L system generation class. Example uses: Generating mazes, creating organic looking decorations.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages