Skip to content

Commit

Permalink
Update txtCell.js
Browse files Browse the repository at this point in the history
  • Loading branch information
YujiSODE authored May 19, 2017
1 parent eaf48fa commit c8aa151
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion txtCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 20,11 @@
* - 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: _Log.map1. Returned value is an array; n-th element shows number of n.
* === List of scripts for Web Worker ===
* - "Conway's Game of Life": 'txtCell_lifeGame.js'
* - "Growing life game": 'txtCell_growingLifeGame.js'
Expand All @@ -30,7 33,7 @@
function txtCell(wkScrpt,dataName,map1,map2){
var slf=window,W,r9=slf.Math.random().toFixed(9).replace(/\./g,''),
bd=slf.document.getElementsByTagName('body')[0],
I=0,_Map,_Log={map0:undefined,map1:undefined,map2:undefined,step:0,dataName:undefined},
I=0,_Map,_Log={map0:undefined,map1:undefined,map2:undefined,step:0,dataName:undefined,stat:[0,0,0,0,0,0,0,0,0,0]},
Div,Name,pStep,I=0,J=0,P,pRnd=0,step=0,dStep=0,max=0,tId,F,
f,dMap,wkMsg;
//element generator
Expand Down Expand Up @@ -106,6 109,18 @@ function txtCell(wkScrpt,dataName,map1,map2){
max=maxStep;
wkMsg([P.innerHTML.replace(/<br>/g,'@'),map2]);
};
//method to count result data of 0 to 9: _Log.map1
//returned value is an array; n-th element shows number of n
F.stat=function(){
if(!!_Log.map1){
var S=[0,0,0,0,0,0,0,0,0,0],L=_Log.map1.replace(/@/,''),n=L.length,i=0;
while(i<n){
S[L[i]] =1,i =1;
}
_Log.stat=S;
return S;
}
};
return F;
}
//=== examples ===
Expand Down

0 comments on commit c8aa151

Please sign in to comment.