Skip to content

shaunbennett/lindenmayer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lindenmayer

A basic implementation of Lindenmayer systems in Golang.

This was used to generate L-System trees in my raytracer project lucis. See main.go for the lua code generation based off the L-System.

Usage

// Create a new L-System with axiom "S"
system := lsystem.New("S")

// Add basic production rules
system.AddProduction('S', "QX")
system.AddProduction('X', "B[LX[RX]B][RX[LX]B]X")

// Add two production rules with weight 10
// Weights are used as a probability of selecting that rule
// Since both weights are equal, there is a 50% chance for each rule
system.AddWeightedProduction('B', "BB", 10)
system.AddWeightedProduction('B', "B", 10)

// Iterate the system 8 times and print the result
fmt.Println(system.Iterate(8))

About

Lindenmayer Systems (L-Systems) in Go

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages