Wave-pattern Automata

Cellular automata producing wave-like patterns.

by Nikita Sadkov

HTML

<p id="info">hello</p>
<canvas id="canvas" width="400" height="400" style="border:1px solid #000000;"></canvas>

JavaScript

var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
var cv_w = canvas.width;
var cv_h = canvas.height;

var info = document.getElementById('info');

var FPS = 120 //frames per seconds
var cols = 200;
var rows = 200;
var cell_w = cv_w/cols
var cell_h = cv_h/rows

var world0 = []
var world1 = []


for (y = -1; y < rows+1; y++) {
  world0[y] = [];
  world1[y] = [];
  for (x = -1; x < cols+1; x++) {
    world0[y][x] = 0;
    world1[y][x] = 0;
  }
}
world = world0

var initial = "\
  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9|\
0                                        |\
1                                        |\
2                                        |\
3                               * *      |\
4                               * *      |\
5                                        |\
6                                        |\
7                                        |\
8                                        |\
9                 * * *                  |\
0                 *   *                  |\
1                 * * *                  |\
2                                        |\
3                                        |\
4                                        |\
5                                        |\
6                                 * *    |\
7                                 *   *  |\
8                                   * *  |\
9                                        ";
/* var initial = "\
  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9|\
0                                        |\
1                                        |\
2                                        |\
3         * *                            |\
4         * *                            |\
5                                        |\
6                                        |\
7                                        |\
8                     *                  |\
9                   *   *                |\
0                     *                  |\
1           ...