This document describes Terasology trees, a proof-of-concept tree growth simulator I wrote for possible inclusion in the open source sandbox game Terasology.

Due to limited time, I wrote the simulation in Python, the language I know best and can work fastest in. Then, to get to drawing trees quickly, I grabbed hold of the matplotlib Python graphics library and just threw the plant into a 3D scatterplot to see it. To make this work in Terasology the code will have to be translated to Java and integrated. It is not a huge amount of code, and I don't think this is an insurmountable task for the enthusiastic :) but I can't say.

To play with the simulation in Python, you need to set up python with numpy and matplotlib on top of it, then check out the code from the GitHub repository. The simulation is very simple: it just spits out PNG files with tree pictures on them, as well as a description file with details on growth. You can change the parameters and create new "species" simply by manipulating the file.

A look at some species

I threw together seven "species" as a start, just to show the different growth habits you can create. The videos show animations of the growth of each species. (Note: If these videos don't work, I find reloading the page helps. In Firefox at least.)

A "default" tree with no particular special parameters.

A tree with a large bulb-like trunk, like a Baobab, which could be full of water.

A "hobble" tree with branches that reach down to the ground.

A "lift" tree like a sequoia that reaches high into the air and has a hollow trunk. (Because of height limitations in the simulation the space isn't tall enough...)

A "spiraling" trunk tree with wildly varying vine-like branches.

Something like a Christmas tree (but needing more work...)

A tree with a deep tap root reaching far into the ground. (Can't show much depth here.)

I am not perfectly happy with the way these look, but I also know from prior experience that all such simulation parameter sets improve with continued tweaking, which I have not done much of, having used up all the time I had building the model itself. So if you think these look ugly, I agree! But I also think they could look MUCH better with the same model.

Things you can do

Here are the things the player should be be able to do to/with the trees if this code was (translated and) integrated into Terasology.

Light and shade

Individual tree stems respond to light falling on them, so the player can manipulate conditions of light and shade above tree parts to change the shape of the tree. I generated a sunlight map like this to test it.

sun coverage

Non-woody stems seek out greater sunlight, so they should grow out from under barriers placed above them, or grow towards artificial light sources (considered to contain light by the species parameters).

Here you can see some trees "reaching for" the light. The cluster in the middle are all competing for the higher light in that patch.


Water and minerals

Trees respond to amounts of water and minerals in the soil. In this proof-of-concept simulation I have created these simply as randomly generated "patches" in the soil, like this:

water water distribution

minerals minerals distribution

On integration trees would seek out preferred types of blocks in the soil of Terasology. Each tree species would include a specification of which kinds of blocks it can draw water or minerals from. For example, a species might find some water in dirt, less in gravel, less in stone, and very little in sand; but another species might be more efficient at extracting water from a wider range of blocks. So the player could manipulate underground resources in order to grow tree species they want to use (perhaps one whose parts they want). Players could also detect the presence of underground resources by noticing what trees are growing where (a gold tree grows only over gold deposits, etc).

Here is a tree "reaching" for bodies of water and minerals in the soil.

reaching for water and minerals

This image shows ten trees all competing for light, water and minerals in the same space.


These images show tree parts with color maps showing:

Biomass - with a "heat" map, from blue at the lowest to red at the highest. The leaves have little biomass because they give it all to the internodes, and the internodes have a lot because they pass it around. Some of the root internodes "store" biomass because when it gets to them, nobody wants it back (unless the plant does poorly later).

New biomass from photosynthesis (photosynthate) - strongest in the darkest green leaf clusters.

takeup of water
Here you see the water content in each part. Some at the bottom have tapped into water patches and are dark blue. Some little pulses of light blue are making their way around the plant to the leaves, possibly from water patches previously exhausted.

takeup of minerals
Similarly the mineral content is highest at the root tips, but if you look carefully you can see it working its way up the main root and to the trunk of the tree, where it spreads out into the bottoms of the branches.

Tree species can also differ in how "hardy" they are, and how they respond to stresses like little water, poor soils and low light. This is to make it possible to make a variety of difficulty in growing different species. For example, on a "quest" one could have to grow a tree of a species that has stiff requirements and needs constant watching over, but yields magical items.

Selective pruning.

One of the most important parts of trees (real and imagined) are the meristems, or buds. In the simulation these produce all the other tree parts. If these are visible in the simulation as blocks (I picture them as small items, like buttons), the player can shape a tree by pruning buds here and there to influence the development of other buds. Thus snipping the buds at the ends of stems will encourage the growth of other branches, perhaps to create more useful wood or to create a house-like structure built of branches. In this image you can see an apical bud in bright green among the dark green leaves attached to the stem in brown.

apical bud

Also, tree parts can die if they become starved for energy. In some cases dead tree parts of a specific type might be worth having - dead wood, for example, might burn longer and faster in a furnace or steam engine than living wood. Or a wilted flower block might produce a better dye, or a dead (rotten) fruit might produce a poison. Thus by starving all or parts of plants of the things they need (water, minerals, light) the player might produce a desirable resource. For example, right now I have it that if an internode (bit of stem) dies, everything that depends on it also dies (which makes sense). So players might "hack off" branches, then wait a day or two for them to die, then harvest the dead wood.

Flowering and fruiting.

Trees can grow (if specified in their species parameters) both flowers and fruits, in specified "shapes" (clusters of blocks). These could be useful blocks players could use. But timing would be important, as well as sunlight, water and minerals. Thus there might be a tree whose fruits yield diamonds, but they only flower for one day and only after a rainstorm. Or something.

So there it is. The Python code is HEAVILY commented and hopefully describes the whole model well enough that someone else could pick it up and run with it. Hopefully. I can answer questions on the Terasology forum. I HOPE that by including enough responsive detail in the basic system I have made it possible to do lots of cool things if the system was integrated with Terasology.

aka Cynthia Kurtz
cfkurtz at kurtz-fernhout dot com
(to avoid being cast aside as spam, include my first name in the body of the email)