Mekal Covic's Cellular Automata Simulator

Iteration Function




How it works and How to use

The simulator creates a grid of size 20x20 or 40x40, treating values outside this grid either as "0" or by wrapping around on itself (depending on the settings). Inside this grid, each position is given a numerical value, which is displayed as a colour based on the given display settings. Space can be used to pause the program, and it runs at 4 iterations per second.
After setting up the iteration function and display settings, you can place "1" values on a grid of "0"s, and then start the simulation. You can still modify the simulation while it is running, though it is better to pause it if you do such a thing.

The instruction set provided in the iteration function tells the simulation how to transform the grid per pixel (where pixel refers to a position on the grid). For each pixel, the values of the surrounding 8 pixels and the centre pixel are provided, and can be accessed by the variables NW, N, NE, E, W, SE, S, SW, (for the surrounding pixels) and C for the centre pixel. Each line either sets the value of a variable or returns the result.
All instructions are run in order, and all the variables given as input are guaranteed to be from the previous state. The instructions are not case sensitive.

Instructions

Make sure that your instruction set always returns some value. This can be done, for example, by specifying a default return value on the last line.

Technical Note: the instructions are run as heavily modified javascript, so you could technically do stuff not in the specification. However, this is not supported, so stick to the provided instruction set unless you know what you're doing and really need it.

Display Settings


Greyscale
Hue
Hue (with input min = black)




Simulation Settings


High Resolution

Edge Handling

Zero
Torus Surface