Hyperbolic Cellular Automata Simulator

Period 10 spaceship on the {3;9} tiling, binary rule [B 3 S 2 7]. See it in the simulator.

This software is a simulator of cellular automata, acting on an regular tiling (grids) of the hyperbolic plane.

It supports arbitrary large configurations of cells, limited only by available memory.

The simulator is written in JavaScript (CoffeeScript actually) and works directly in the browser. It is an open software, sources are available on Github.

Features

Key features are:

The simulator also supports:

Tilings and neighbors

Only Moore neighborhood scheme is supported. In the {N;M} tiling (M regular N-gons are touching every vertex), total number of neighbors of a cell is \(N(M-2)\).

Cell neighbors in the {7;3}, {5;5}, {3;7} tilings.

Rules

For 2-state automata rules are specified in the slightly modified "BS" notation (used by Golly). The format is:
$$B\ n_1\ n_2\ ...\ S\ m_1\ m_2\ ...$$
where \(n_{1,2,...}\) are number of neighbors, required for cell to "born" (change from state 0 to state 1), and \(m_{1,2,...}\) are numbers of neighbors, required to "survive" (stay in state 1). Numbers must be separated by spaces because in hyperbolic tilings number of neighbors often exceeds 10.

To set rule, edit the "Rule" field on a side pane, then press enter or click button Set.

Custom rules

Custom rules are written in JavaScript. They support arbitrary number of states, and custom formulas for calculation of neighbors sum (default is summation).

To change to the custom rule mode, click button Generic... near the rule entry. Current rule would be converted to the custom rules code.

Custom rules format

Custom rules must be a valid JS code, evaluated in expression context to an object with the following required fields:

By default, sum of neighbors is calculated by summation of state values. This can be overridden by the following optional fields:

Editing and navigation

By default (when Pan button above view is active), left mouse button is used to pan view, middle button or left + shift are used to toggle state of a cell. This behavior is inverted by activating Edit button on the top of the view.

When panning view, dragging near view center translates view, and dragging near view edge rotates it.

Button Straighten view puts central cell exactly to the center of the view and rotates view to make the cell aligned vertically or horizontally. (Useful for making images and animations).

Memory

There is no undo (yet?). Instead, simple "memory" functionality with MS (set), MR (restore), MC (clear) buttons is implemented. It works exactly like in calculators.

Import and export

It is possible to export view state into a textual format. Either whole world or only visible area can be exported. Sample export result:

7$3$(A2(B|1))(A3(B|1))(b(A3(B|1)(b|1)))(a3(B|1))(B|1(a(B|1)))(a2(B|1))(A(B(a(B|1))))(a(B|1))
Here, 7 and 3 are tiling parameters, the rest is the description of cell states.

Cell position is described by a Von Dyck group \(D(N,M,2)\) with generators a, b. Generator "a" represents rotation around the N-gon center, generator "b" represents rotation around vertex. Coordinate of a cell is a chain of powers of "a" and "b".

In the export format, letters "a" and "b" designate generators, "A" and "B" are their inverse elements. Optional number after the letter is generator power. Number after vertical bar | is state of the cell. Braces are required; they allow to group multiple chains with common initial elements.

Save and load in Indexed Database

It is possible to store whole world state in the Indexed Database on the local machine. Saves are organized by grid and by rule; names are not required to be unique. They are stored locally and not uploaded anywhere.

By default, only saves matching current tiling and rule are shown. Use buttons to show all tilings and all rules.

Making animations

Uploading animations is only supported, when the page is run locally. To do it:

  1. Download sources
    $get clone https://github.com/dmishin/hyperbolic-ca-simulator.git
  2. Either build them:
    $make
    Or download the compiled version from the demo site:
    $wget http://dmishin.github.io/hyperbolic-ca-simulator/index.html
    $wget http://dmishin.github.io/hyperbolic-ca-simulator/application.js
  3. Use python 3 to start local server
    $python http_server_with_upload.py
  4. Open the local site: http://localhost:8000/index.html

Animator GUI allows to set start and end points of animation. Use memory buttons (MS) to save state before adjusting positions.

Derotate button tries to adjusts start and end position by equal amount so that they would be connected by a pure translation (without rotation). In euclidean geometry, it is meaningless but in hyperbolic geometry it is useful. It allows to make seamless animations of gliders (top animation is done using it).

Steps to make seamless animation of a spaceship

  1. Locate a spaceship (use Search and find far configurations)
  2. Adjust view to display it better, then use "Straighten view". (hotkey: Alt+S)
  3. Remember world state using MS (hotkey: M).
  4. Set animation start
  5. Simulate for several steps until spaceship returns into the original configuration (hotkey: N).
  6. Adjust view and use "Straighten view" to put spaceship exactly in the same position as in step #2.
  7. Set animation end
  8. Click Derotate to make path between start and end straight. (Should be possible for a real glider). You can ensure that positions are changed by clicking View button.
  9. Set other animation parameters (size, frames, generations, name), restore works state (MR, hotkey U), and run animation.
Frames of animation are uploaded to the "uploads" folder.

Sources and license

Sources are available on Github under the permissive ">MIT license.

The code uses following third party libraries:

Contacts

Don't hesitate to contact me on G+ or Reddit.