//Informatik - Serie 11 - Skript- Aufgabe 127
//Programm: GollmartTristan.cpp
//Autor: Tristan Gollmart
//Draw a brainshaped construct with the Lindenmeyer system (recommended for n=6+)
#include
#include
// POST: the word w_i^F is drawn
void f (const unsigned int i) {
if (i == 0)
ifm::forward(); // F
else {
f(i-1); // w_{i-1}^F
f(i-1); // w_{i-1}^F
ifm::left(5); // -
ifm::save(); // [ stores current position and direction
ifm::left(5); // -
f(i-1); // w_{i-1}^F
ifm::right(20); // +
f(i-1); // w_{i-1}^F
ifm::right(20); // +
f(i-1); // w_{i-1}^F
ifm::restore(); // ] goes back to last stored position / direction
}
}
void g (const unsigned int i) {
if (i == 0)
ifm::forward(); // F
else {
g(i-1); // w_{i-1}^F
ifm::right(15); // -
g(i-1); // w_{i-1}^F
ifm::left(15); // ++
g(i-1); // w_{i-1}^F
ifm::right(15); // -
g(i-1); // w_{i-1}^F
f(i);
}
}
int main () {
std::cout << "Number of iterations =? ";
unsigned int n;
std::cin >> n;
// draw w_n = w_n^F
ifm::left(130); // loook up
f(n); // w_n^F
g(n);
return 0;
}