Warmist's page

Logo

My ramblings

View My GitHub Profile

9 December 2018

Terrarium

Terrarium in action

A small ecosystem in a window

I’ve lately been inspired by Loren schmidt and her new project. Although her project is way more involved and complicated and more game-like it inspired me to try something in similar vein.

So here’s a small ecosystem and how it works.

Simple/physical parts

Stuff

Sand

A brownish substance that piles up. It’s calculated as follows:

Walls

A dark teal totally inert substance. Mostly for light cover

Water

A blue/light blue material. Currently does nothing important. Calculation:

Dead plant matter

Dark reddish material. Simulated same as sand.

Light

Everything in here is either light blocking (e.g. sand, walls) or not (water, empty air, seeds). It’s shown as light background and it lights up first layer of sand.

Plants

Plants Plants have 3 stages: seed, growing and fruiting.

Seed

It’s an orange/yellowy falling pixel. While falling it moves a bit to left/right just so it would not fall into same dark spots. To go into growing stage it needs to fall onto sand and be lit by light. If it sits too long in darkness it decomposes into dead plant matter.

Growing

The green material. The seed extends it’s shoot upwards. It has a bias towards the light. Each pixel placed consumes some energy of the plant and even existing consumes some more. On the other hand sunlit pixels of the plant generate energy. If energy gets below zero plant turns into dead plant matter. The cost of adding pixels is increased (quadratically) for each new pixel. This makes plants stop growing after some time. That is when the plant goes into fruiting.

Fruiting

The orange blob stuck to the plant. Plant uses it’s energy to grow it bigger. As it reaches it’s size limit it burst into dead plant matter and some seeds. This makes new plants as the seeds sometimes get into good place and sprout new plants.

Worms

Worm

Worms start a single cell and grow by eating dead plant matter. This reduces the piles of it which would drown out the terrarium very quickly. It also mimics the part of decomposers in natural world. Some behavior traits:

This makes them very good for plants as they come up to the surface, destroy dead plant matter and then die and turn into sand in sunlight. This is then makes plant seeds sprout.

Issues

However this still needs work to be fully closed system:

Conclusion

It’s a very interesting toy to experiment and see some emergent behavior. My approach is more object oriented (i.e. plants and worms are objects) but you could go more Cellular automaton path and get different cell interactions that way (e.g. make artificial cells with cell membrane being one type insides different kind cells). And any way you go it’s a very dynamic and ‘alive’ toy.

Code for this is here.

tags: