Oasis After Dark
Concept
This project explores cellular automata through the creation of a small, interactive ecosystem that I call the Oasis After Dark. Instead of using traditional binary cellular automata, I wanted to experiment with a system where each cell represents a material with behavior. The sketch simulates four elements: sand, water, plant life, and fire, each governed by simple local rules.
The core idea behind the project is emergence. How complex, organic-looking patterns arise from simple interactions between neighboring cells. Sand falls and forms dunes, water flows and spreads, plants grow near water sources, and fire consumes organic matter. Individually, these behaviors are simple, but together they create a dynamic and evolving landscape.
Instead of generating art automatically I let the user be the artist and generate the oasis that they want.
Process
I began by building the grid structure and implementing the simplest material: sand. Each cell stores its type and updates based on local rules, which is the foundation of the cellular automaton.
The key behavior for sand is gravity: it falls downward if possible and slides diagonally if blocked. This was my first implementation of a local rule system.

if (canMoveInto(x, y + 1, [EMPTY])) {
moveCell(x, y, x, y + 1, cell);
return;
}
let dir = random() < 0.5 ? -1 : 1;
if (canMoveInto(x + dir, y + 1, [EMPTY])) {
moveCell(x, y, x + dir, y + 1, cell);
return;
}
Next, I added water, which introduced more complex movement. Unlike sand, water not only falls but also spreads sideways when blocked. This required adding multiple movement checks and randomness.

Water made the system feel more dynamic and introduced the first real interaction between materials. For example, sand can displace water, creating more complex patterns.
After movement-based elements, I introduced plants, which behave differently by growing instead of moving. Plants expand only when near water, creating a dependency between elements. But they also added another interaction. Fire can burn plants, and if the plants are connected and the fire touches one part, the fire will spread and burn down the whole “forest”.

And finally the sky looked a bit empty without anything on it so I decided to add some stars to make the sky fuller and the sketch look more alive.

function generateStars() {
stars = [];
for (let i = 0; i < 150; i++) {
stars.push({
x: random(width),
y: random(height),
size: random(1, 2.5),
alpha: random(80, 180)
});
}
}
Code Highlight
One part of the code I am particularly proud of is the use of shuffled neighbor evaluation for plant growth and fire spreading:
function shuffledNeighbors(x, y) {
let arr = [
{ x: x - 1, y: y - 1 },
{ x: x, y: y - 1 },
{ x: x + 1, y: y - 1 },
{ x: x - 1, y: y },
{ x: x + 1, y: y },
{ x: x - 1, y: y + 1 },
{ x: x, y: y + 1 },
{ x: x + 1, y: y + 1 },
];
for (let i = arr.length - 1; i > 0; i--) {
let j = floor(random(i + 1));
[arr[i], arr[j]] = [arr[j], arr[i]];
}
return arr;
}
This function ensures that neighboring cells are processed in a random order rather than a fixed sequence. Without this, growth and spread would appear directional and artificial. By randomizing neighbor order I believe the project looks more natural. Plants grow in unpredictable directions, and fire spreads in a more natural, chaotic way.
Future Improvements
Overall I am really happy with how the project turned out. I think it is really similar to those sandbox games that let you create your own world. Choosing to let the users be the artist and create their own playground rather than creating generated art was I think the right direction for this project as it adds more interactivity and brings the user closer to the project than just tweaking some settings. As for the future improvements I would like to explore more materials and different interactions between them. Maybe adding smoke that emerges from “forest fires” and maybe letting some sand turn into glass when in too much contact with fire. Finally, this was a fun project to work, I learned a lot about cellular automata and its use and can’t wait to use it in my future projects!