Interface for text based Cellular Automaton.
https://github.com/YujiSODE/txtCell
wiki: https://github.com/YujiSODE/txtCell/wiki
Copyright (c) 2017 Yuji SODE <yuji.sode@gmail.com>
This software is released under the MIT License.
See LICENSE or http://opensource.org/licenses/mit-license.php
txtCell.js
: interface for text based Cellular Automaton.imgMap.js
: interface to convert "map data" into canvas "image" or canvas "image" into "map data".txtCell_lifeGame.js
andtxtCell_growingLifeGame.js
: Web Worker interfaces for Cellular Automaton.
Map data:'xxx...x@xxx...x@...'
;x
is integer between 0 to 9.
Interface for text based Cellular Automaton.
function txtCell(wkScrpt[,dataName][,map1][,map2])
Parameters
wkScrpt
: a filename of a script for Web Worker.- [optional]
dataName
: name of a data set. timestamp is default value. - [optional]
map1
andmap2
: map data. random map with 0 or 1 (n x n data) is default value.
Returned function
function()
: function that returns Log object.
Log object has following values:map0
: initial data map.map1
: the current data map.map2
: additional data map.step
: the current step.dataName
: name of a data set. timestamp is default value.stat
: counted results expressed as an array. n-th element shows number of n. initial value is [0,0,0,0,0,0,0,0,0,0].
Method of returned function
function run(maxStep)
: it simulates onlymaxStep
steps. 1 is default value.function stat()
: method to count result data of 0 to 9:map1
in Log object. Returned value is an array; n-th element shows number of n.
Interface to convert "map data" into canvas "image" or canvas "image" into "map data".
function imgMap(canvasId)
Parameters
- canvasId: id of canvas tag; canvas tag is generated when there is not target tag.
Returned function
function()
: function that returns Log Object.
Log object has following values:canvasId
: id of target canvas tag.
-----------------------------------inputMap
: input data map for methodmap2Cvs(map)
.mapImage
: data URI for input data map with methodmap2Cvs(map)
.
-----------------------------------outputMap
: output data map with methodcvs2Map(abcd)
.abcd
: parameters to convert image into mapdata with methodcvs2Map(abcd)
.
v=f(RGBa-value)=aR+bG+cB+da.
Method of returned function
function reset()
: method to reset Log Object.function map2Cvs(map)
: method to convert map data into canvas image; map is map data.
"color chart" between blue(1) and red(9), and 0 is default output.
Figure 1. color chart.function cvs2Map(abcd)
: method to convert canvas image into map data.
abcd
is a text expressing values a, b, c, and d that satisfies v=f(RGBa-value)=aR+bG+cB+da;
e.g., "1011" means v=1R+0G+1B+1a. "1110" is default value.
Web Worker interfaces for Cellular Automaton.
-
"Conway's Game of Life":
txtCell_lifeGame.js
Rule of "Conway's Game of Life"
[surrounding sum:012345678]
[_current cell=0:000100000]
[_current cell=1:001100000]
-
"Growing life game":
txtCell_growingLifeGame.js
Growing life game is based on "Conway's Game of Life".
A living cell grows from 1 to 9 by step. An additional map can be used for limiting area;
a cell with value of 0 in additional map is not habitable in this life game.
Rule of "Growing life game"
[surrounding sum:012345678]
[_current cell=0:000100000]
[_current cell=1:002200000]
...
[_current cell=7:008800000]
[_current cell=8:009900000]
[_current cell=9:009900000]
A cell with value of 9 means that it has lasted for 9 or more steps.
A cell with value 0 in additional map will be 0 if additional is available.