I've completed a first pass at getting my L-systems working.
1. Getting the artificial plant from Wikipedia to generate:
https://en.wikipedia.org/wiki/L-system#Example_7:_Fractal_plant
Project fragment successful. Code sample not kept.
2: Refactor, work into plug-n-play system. Example fragment:
LSystem fractalPlantSystem = new LSystem("X");
fractalPlantSystem.appendRule(new LRule('X', "F-[[X]+X]+F[+FX]-X"));
fractalPlantSystem.appendRule(new LRule('F', "FF"));
fractalPlantSystem.appendRule(new LIdentityRule(' ', ""));
fractalPlantSystem.iterate(8);
lines = new PlantInterpreter().parse(fractalPlantSystem).getContents();
LSystem(String Initialarg):
Represents a container for the string to be operated on, as well as a container for the rules.
LRule(char locate, String replace)
Represents an arbitrary rule. The standard LRule accepts a symbol to locate, and whatever sequence replaces it.
LIdentityRule(char locate, String replace) extends LRule
Identity rule. LSystems containing the identity rule will call it if no other rule is invoked.
LSystem.iterate(int times)
Performs the system operation on the contained string X times..
LInterpreter()
Represents an arbitrary interpreter for an L system.
PlantInterpreter() implements LInterpreter
Generates a list of lines when parse is called on a compatible L system. Monogame can then draw the lines with relative ease.
1. Getting the artificial plant from Wikipedia to generate:
https://en.wikipedia.org/wiki/L-system#Example_7:_Fractal_plant
Project fragment successful. Code sample not kept.
2: Refactor, work into plug-n-play system. Example fragment:
LSystem fractalPlantSystem = new LSystem("X");
fractalPlantSystem.appendRule(new LRule('X', "F-[[X]+X]+F[+FX]-X"));
fractalPlantSystem.appendRule(new LRule('F', "FF"));
fractalPlantSystem.appendRule(new LIdentityRule(' ', ""));
fractalPlantSystem.iterate(8);
lines = new PlantInterpreter().parse(fractalPlantSystem).getContents();
LSystem(String Initialarg):
Represents a container for the string to be operated on, as well as a container for the rules.
LRule(char locate, String replace)
Represents an arbitrary rule. The standard LRule accepts a symbol to locate, and whatever sequence replaces it.
LIdentityRule(char locate, String replace) extends LRule
Identity rule. LSystems containing the identity rule will call it if no other rule is invoked.
LSystem.iterate(int times)
Performs the system operation on the contained string X times..
LInterpreter()
Represents an arbitrary interpreter for an L system.
PlantInterpreter() implements LInterpreter
Generates a list of lines when parse is called on a compatible L system. Monogame can then draw the lines with relative ease.
3: Added stochastic rule:
example:
new LStochasticRule('X', new string[] { "X[++FX[++FX]][--FX[--FX]]X", "F+[[X]+X]+F[+FX]+X" })
//TODO: this automatically creates a stochastic rule with a 50% of two outcomes. This is unacceptable, in the long term, requiring a rework.
example:
new LStochasticRule('X', new string[] { "X[++FX[++FX]][--FX[--FX]]X", "F+[[X]+X]+F[+FX]+X" })
//TODO: this automatically creates a stochastic rule with a 50% of two outcomes. This is unacceptable, in the long term, requiring a rework.
4: Integration with display medium (minecraft, atm), and accidental landmass generation:
---A partial implementation is complete, but, at the moment, is not clean enough to show.--
--IMO, the shapes I'm currently generating (similar to the one above) would make a rather nice island chain. For this reason, I'm moving the terrain-generation part of my project up.--
---A partial implementation is complete, but, at the moment, is not clean enough to show.--
--IMO, the shapes I'm currently generating (similar to the one above) would make a rather nice island chain. For this reason, I'm moving the terrain-generation part of my project up.--