Giter Club home page Giter Club logo

txtcell's Introduction

txtCell growingLifeGame_SS20170522_tri.png

Interface for text based Cellular Automaton.
https://github.com/YujiSODE/txtCell
wiki: https://github.com/YujiSODE/txtCell/wiki

Copyright (c) 2017 Yuji SODE <[email protected]>
This software is released under the MIT License.
See LICENSE or http://opensource.org/licenses/mit-license.php


Scripts

  1. txtCell.js: interface for text based Cellular Automaton.
  2. imgMap.js: interface to convert "map data" into canvas "image" or canvas "image" into "map data".
  3. txtCell_lifeGame.js and txtCell_growingLifeGame.js: Web Worker interfaces for Cellular Automaton.

Map data format

Map data:'[email protected]@...';x is integer between 0 to 9.

1.txtCell.js

Interface for text based Cellular Automaton.

Function

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 and map2: 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 only maxStep 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.

2.imgMap.js

Interface to convert "map data" into canvas "image" or canvas "image" into "map data".

Function

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 method map2Cvs(map).
    • mapImage: data URI for input data map with method map2Cvs(map).
      -----------------------------------
    • outputMap: output data map with method cvs2Map(abcd).
    • abcd: parameters to convert image into mapdata with method cvs2Map(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.
    color chart
    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.

3.txtCell_lifeGame.js and txtCell_growingLifeGame.js

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.

txtcell's People

Contributors

yujisode avatar

Stargazers

 avatar

Watchers

 avatar  avatar

txtcell's Issues

examples using "txtCell" and "imgMap.js"

"script20170517.js"

//an example using "txtCell" and "imgMap.js"  
(function(n){
    var slf=window,x,y,logX,logY,i=0,tF;
    tF=function(){
        var tId;
        x.run();
        logX=x();
        y.map2Cvs(logX.map1);
        i+=1;
        if(i<n){tId=slf.setTimeout(tF,1000);}
    };
    x=txtCell('txtCell_lifeGame.js','Life Game');
    y=imgMap('cellsResult');
    logX=x();
    y.map2Cvs(logX.map0);
    slf.setTimeout(tF,1000);
})(10);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.