Procedural Tree Generator

Top Arrow
It 🇮🇹

Project Overview

Key Concepts

  • Recursion
  • Procedural generation
  • Randomized algorithms
  • Python Turtle graphics
  • Performance measurement

Motivation

This project was created while I was learning recursion and procedural generation techniques in Python.

The initial idea came from a simple question: If I teach a computer how to draw a tree and each generated tree is unique, who should be considered the artist, the programmer or the machine?

To explore this idea, I developed a recursive algorithm that generates organic-looking trees through randomized branching angles, variable branch lengths, and probabilistic growth rules.

Implementation

The recursive process is controlled by progressively reducing branch length. Once branches become sufficiently short, the algorithm switches to leaf generation, guaranteeing termination.

The implementation prioritizes visual complexity over execution speed and was developed primarily as an exercise in recursion and procedural generation.

Results and Observations

As you can see from the examples below, some trees appear more natural than others, regardless of the time required to generate them. During testing, I observed little correlation between execution time and the visual quality of the generated tree.

Possible Future Improvements

Because of the apparent lack of correlation between execution time and visual quality, a possible future improvement would be to introduce a time limit of 200 seconds, preventing excessively long generation times.

Generated tree example 1 Generated tree example 2 Generated tree example 3 Generated tree example 4 Generated tree example 5 Generated tree example 6 Generated tree example 7 Generated tree example 8 Generated tree example 9 Generated tree example 10 Generated tree example 11 Generated tree example 12 Generated tree example 13 Generated tree example 14