// Prog: FlurySandro.cpp
// Author: Sandro Flury
// Draws a Lindenmayer-System
#include
#include
// POST: drwas the word w_i^F
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(33); // -
ifm::save(); // [ stores current position and direction
ifm::right(33); // -
f(i-1); // w_{i-1}^F
ifm::right(663);// + f(i-1); // w_{i-1}^F
ifm::left(33); // +
f(i-1); // w_{i-1}^F
ifm::restore(); // ] goes back to last stored position / direction
ifm::right(33); // +
ifm::save(); // [
ifm::right(66);// +
f(i-1); // w_{i-1}^F
ifm::left(33); // -
f(i-1); // w_{i-1}^F
ifm::left(33); // -
f(i-1); // w_{i-1}^F
ifm::restore(); // ]
}
}
int main () {
std::cout << "Number of iterations =? ";
unsigned int n;
std::cin >> n;
// draw w_n = w_n^F
ifm::right(90);
f(n);
return 0;
}