Foundations
To those who are not familiar with cellular automata, here’s a guide to introduce you to Vivarium. For now just know that a vivarium is an abstraction we created to describe cellular automata in a way that is easy and fun to learn for those who wouldn’t know exactly where to start.
Vivarium
Section titled “Vivarium”In the digital world, think of a vivarium like a 2d image in motion. The movement happens in steps, each step is a consequence of the previous one. This motion is the result of a simulation driven by a set of rules that are unique to each vivarium. These rules are simple, but can create complex behaviors when combined together, making the image evolve over time. We’ll talk about rules in a bit. Now let’s define our building blocks.
Elements
Section titled “Elements”An element is an abstract way to represent anything we want to put in our vivarium. Dogs, cats, aliens, trees, sand, electricity, hot air balloons… are all valid elements. It’s up to you what an element represents. All is needed is:
- a name — like “alien” — to know what it is (how to distinguish it logically from other elements)
- a color — like “green” — to know how to draw it on the screen (how to distinguish it visually from other elements)
Neighborhood
Section titled “Neighborhood”Elements exists in a world we call the grid. Every element occupies a cell of the grid, and shares its surroundings with other elements. More than often, an element is influenced by its neighbors and evolve into another element when the configuration of its neighbors meets certain criteria. We call neighborhood the area of influence of a given element. Anything happening outside the neighborhood can be ignored, while anything that happens inside the neighborhood might have an impact on the element.
By default, the neighborhood of a cell is made of the 8 adjacent (diagonal included) cells surrounding it. In Vivarium, technically speaking, the central cell does not belong to its neighborhood.
Evolution
Section titled “Evolution”To show you how a vivarium works, let’s start with a very small image.
This is a 5 pixels by 5 pixels image. If you’re not familiar with pixels and how images are represented on a screen, think of this as a grid of little squares. A color is assigned to each square. Often we’re going to call these squares “cells”. In this image we have blue cells all around a central green cell. This is our initial image.
We are going to update the image in two steps. First we’re going to fill in the grid with numbers. In each cell we’re going to write down the number of green cells that are found in the neighborhood of the current cell.
The second step is to color the cells that have a 1 in them. This is because the rule we’re going to apply says that blue cells become green if the number of green neighbors is exactly 1.
Note how this is made in two steps. It’s important to compute first all the numbers we’ll write in, and then update the grid with new colors. I’ll show you why: