-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupdaterules.js
55 lines (54 loc) · 2.19 KB
/
updaterules.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
var updaterule = [function(ii,jj,np){
var change = false;
if (np(ii,jj) === 0){
change = np(ii-1,jj-2) & np(ii-1,jj-1) & np(ii-1,jj) & np(ii-1,jj+1) & np(ii-1,jj+2);
change = change | np(ii+1,jj-2) & np(ii+1,jj-1) & np(ii+1,jj) & np(ii+1,jj+1) & np(ii+1,jj+2);
change = change | np(ii-1,jj-1) & np(ii-1,jj-1) & np(ii,jj-1) & np(ii+1,jj-1) & np(ii-1,jj-1);
change = change | np(ii-2,jj+1) & np(ii-1,jj+1) & np(ii,jj+1) & np(ii+1,jj+1) & np(ii+2,jj+1);
}
return change;
},
function(ii,jj,np){
var change = false;
if (np(ii,jj) === 0){
change = (np(ii-1,jj) + np(ii+1,jj) + np(ii,jj-1) + np(ii,jj+1)) >= 2;
//change = np(ii,jj-1) & np(ii+1,jj);
//change = change | np(ii+1,jj) & np(ii,jj+1);
//change = change | np(ii,jj+1) & np(ii-1,jj);
//change = change | np(ii-1,jj) & np(ii,jj-1);
}
return change;
},
function(ii,jj,np){
var change = false;
if(np(ii,jj)===0){
change = (np(ii,jj-1) + np(ii+1,jj) + np(ii-1,jj+1)) >=2;
//change = change | (np(ii,jj+1) + np(ii-1,jj) + np(ii+1,jj-1)) >= 2;
//change = change | (np(ii-1,jj) + np(ii,jj-1) + np(ii+1,jj+1)) >= 2;
//change = change | (np(ii-1,jj+1) + np(ii+1,jj)) + np(ii,jj-1) >= 2;
}
return change;
},
function(ii,jj,np){
var change = false;
if(np(ii,jj)===0){
change = (np(ii-1,jj) + np(ii,jj-1) + np(ii,jj+1)) >= 2;
}
return change;
},
function(ii,jj,np){
var change = false;
if(np(ii,jj)===0){
change = (np(ii-3,jj) + np(ii-2,jj) + np(ii-1,jj)) == 3;
//change = change | (np(ii,jj-1) + np(ii,jj-2) + np(ii+1,jj-1) + np(ii+1,jj-2)) == 4;
//change = change | (np(ii,jj-1) + np(ii,jj-2) + np(ii-1,jj-1) + np(ii-1,jj-2)) == 4;
change = change | (np(ii,jj+1) + np(ii,jj+2) + np(ii+1,jj+1) + np(ii+1,jj+2)) == 4;
change = change | (np(ii,jj+1) + np(ii,jj+2) + np(ii-1,jj+1) + np(ii-1,jj+2)) == 4;
//change = change | (np(ii-1,jj) + np(ii-2,jj) + np(ii-1,jj+1) + np(ii-2,jj+1)) == 4;
//change = change | (np(ii-1,jj) + np(ii-2,jj) + np(ii-1,jj-1) + np(ii-2,jj-1)) == 4;
//change = change | (np(ii+1,jj) + np(ii+2,jj) + np(ii+1,jj+1) + np(ii+2,jj+1)) == 4;
//change = change | (np(ii+1,jj) + np(ii+2,jj) + np(ii+1,jj-1) + np(ii+2,jj-1)) == 4;
}
return change;
}
];