Evolving Plants

This is one of my earliest interactive projects, or at least, the original version was. It was first written in Java, and then updated in 2022 to C++ in Qt.
See below for a more detailed explanation.
This project is open source and can be found on GitHub

Run it yourself

To run this program yourself on Windows, download and unzip the file and double-click on "EvolvingPlants.exe" inside the folder.
EvolvingPlants_v4-1 (zip)

How it works

The Gist

"Plants" are modelled as lines (stems) and ovals (leaves), the leaves absorb light energy and cast shadows. Over time plants evolve to compete for this light energy by being taller than competitors, or a different colour, or by having more leaves. The trade-off is that being taller and more complex requires more energy to exist, and a high dense canopy that blocks out all light prevents baby plants from surviving long enough to grow to full size.

Light

The image to the right shows a number of small multi-coloured plants on a white background. The coloured rectangles beneath each leaf are shadows. The colour of the light represents the energy available at that point. R,G,& B channels each contain their own energy and a leaf may evolve in colour to extract energy from one or more of these channels. A leaf "blocks" all of the energy it absorbs.
If a leaf has the colour 50, 50, 50, it will try to absorb that much light from each colour channel, gaining up to 150 energy. A plant cannot utilise more that 200 units of energy, the excess is actually deducted from the energy the leaf generates by "photosynthesising", this is realistic, plant leaves in strong direct sunlight can overheat and even "burn" like human skin does in strong sunlight.

Early on

Here we can see two groups of plants, this simulation is actually the same as in the previous image, some 4000 ticks later, and we can see that these plants appear to all be descended from just two of the original plants based on their colour.

Competition

Now that these plants are growing in the same range, they have begun to compete for light, both with members of their own species, but now also with the other species too, initially we see a simple increase in height.

Colour Niches

As there is a cap on how much energy a leaf can extract from the light when photosynthesising, we see different species evolving to take advantage of the light not absorbed by the upper canopy. Here we see three different colours of plant, with the shadows becoming progressively darker as each species extracts a different subset of the available light. From this point on the upper canopy colour may drift over time via genetic drift and smaller species will adapt their colours via natural selection to stay different from the taller plants.

Branching

The selected plant is drawn with a white outline, here it is possible to make out that it is no longer a single stem with a leaf at the top, but it now has a second branch out to the right. The reddish plants also appear to have a branch, albeit smaller. The plants' structure will continue to get more complex as the simulation continues.