Not exactly, you can pass in the strings for ‘draw forward’, ‘turn left’ and ‘turn right’ in the constructor. This, and the right brackets to ‘pushPosition’ en ‘popPosition’ are the only commands that this Turtle can take. It’s pretty limited but then again it was only included for checking if the L-system worked. It should be a pretty straightforward process to add more commands.
I looked for a nice algae L-system, found this one by Paul Bourke: http://paulbourke.net/fractals/lsys-algae-b/
Implementation:
system.addVariable("a");
system.addVariable("b");
system.addVariable("c");
system.addVariable("d");
system.addVariable("e");
system.addVariable("g");
system.addVariable("h");
system.addVariable("i");
system.addVariable("j");
system.addVariable("k");
system.addVariable("l");
system.addVariable("m");
system.addVariable("n");
system.addVariable("o");
system.addVariable("p");
system.addVariable("q");
system.addVariable("r");
system.addVariable("s");
system.addVariable("t");
system.addVariable("u");
system.addVariable("v");
system.addVariable("w");
system.addVariable("x");
system.addVariable("y");
system.printVariables();
system.addConstant("F");
system.printConstants();
system.setStart("aF");
system.printStart();
system.addRule(LRule("a", "FFFFFy[++++n][----t]fb"));
system.addRule(LRule("b", "+FFFFFy[++++n][----t]fc"));
system.addRule(LRule("c", "FFFFFy[++++n][----t]fd"));
system.addRule(LRule("d", "-FFFFFy[++++n][----t]fe"));
system.addRule(LRule("e", "FFFFFy[++++n][----t]fg"));
system.addRule(LRule("g", "FFFFFy[+++fa]fh"));
system.addRule(LRule("h", "FFFFFy[++++n][----t]fi"));
system.addRule(LRule("i", "+FFFFFy[++++n][----t]fj"));
system.addRule(LRule("j", "FFFFFy[++++n][----t]fk"));
system.addRule(LRule("k", "-FFFFFy[++++n][----t]fl"));
system.addRule(LRule("l", "FFFFFy[++++n][----t]fm"));
system.addRule(LRule("m", "FFFFFy[---fa]fa"));
system.addRule(LRule("n", "ofFFF"));
system.addRule(LRule("o", "fFFFp"));
system.addRule(LRule("p", "fFFF[-s]q"));
system.addRule(LRule("q", "fFFF[-s]r"));
system.addRule(LRule("r", "fFFF[-s]"));
system.addRule(LRule("s", "fFfF"));
system.addRule(LRule("t", "ufFFF"));
system.addRule(LRule("u", "fFFFv"));
system.addRule(LRule("v", "fFFF[+s]w"));
system.addRule(LRule("w", "fFFF[+s]x"));
system.addRule(LRule("x", "fFFF[+s]"));
system.addRule(LRule("y", "Fy"));
system.printRules();
res = system.getLevel(30);
cout << res << endl;
turtle = Turtle("F", "-", "+");
turtle.length = 1;
turtle.angle = 12;
I don’t know what ‘f’ is supposed to do, as it’s not included in one of the rules I guess it’s a turtle-command. Anyone know what it’s supposed to do?
Without adding the ‘f’ command, the algae look like the attached image.