Your browser does not support the HTML5 canvas tag.
(Change something in the code and hit "Restart" to experiment)
Config:


What is this

This is a cellular automata simulation that uses a 2D matrix of cells to generate interesting effects. Each cell executes simple rules that control its state and behavior ( color, replication, state (on/off), etc ). The "program" that the cells execute can be defined in the area to the right, via a metalanguage similar to the genetic code of real cells. The source code is here.

How a cell works

A cell is a square with a given dimension on the canvas. It can react to its environment according to a "genetic code", defined in the area on the right side.

One can configure cells to execute a certain program defining particular cell types and genes that instruct them what to do.

The simulation starts by default with a single cell in the center of the board and evolves from there according to the program on the right. You can specify a different starting setup by instructing the program what cells to activate, via the setup.cells parameter. For example, to initialize a cell at position x: 20 and y: 40, and another one at position x: 30, and y -20, you can add this to the configuration: { ... "setup":{ "cells":[ { "pos": [20,40], "type":"add a type defined by you" }, { "pos": [30,-20] } ] } ... } As you can see, besides the position, you can specify a custom type of the cell, defined via the types parameter of the configuration.

The default replication direction of the original cell is straight up, but it can be modified via the SRM operation.

Neighbors

Each cell is aware of its direct neighbors.
For each cell, the neighboring cells will be identified like this:

0 1 2
7 x 3
6 5 4

A cell can "act" upon its direct neighbors by replicating its genetic code to them if they are empty or they have a lower priority. See the example code.

Cell's properties and operations

To program cells to do something, one needs to define genes in the genes section of the configuration. Each gene has an activation function ( a certain set of conditions that need to be fulfilled), and a set of operations that are executed if its activation function returns true. See the example to understand how this works. The text between /* ... */ is ignored.

The most important operations are:

Most important properties:

Read below to see all possible properties and operations.

How cells can be programmed via the metalanguage

Cell properties and helper functions

Cell operations

All operations need to end with the ; character.