, . : , "" , , , - . , , .
Main . Main count, - :
, , , . , count, , N. , 1. i, 1 n, :
(i<0)? N-l: (i==N)? 0: i;
Main (), torus. i. , :
return (i<0)? N-l: (i==N)? 0: i;
, . countAliveNeighbors. , count , alive . Main. , // :
/ public void countAliveNeighbors() { for(int i=0; i<N; i++)
for(int j=0; j<N; j++) {
count[i][j] = alive[i][j]? -1:0;//-1, for(int k=-l; k<2; k++) // for(int m=-l; m<2; m++)// count[i][j] += alivettorus(i+k)][torus(j+m)]? 1:0; } }
changestates . , , "":
// public void changestates() {
boolean changed = false; // , // countAliveNeighbors(); // for(int i=0; i<N; i++) //
for(int j=0; j<N; j++)// , ,
// if (!alive[i][j] && count[i][j] == 3) alive[i][j]= changed = true; //, 2 3 ,
|
|
else if (alive[i][j]&&(count[i][j]==2 || count[i][j]==3)); // else { if(alive[i][j]) changed=true; // - alive[i][j]=false; } // ,
if (!changed) Engine.finish(); }
, . , changestates, . .
Main (), 1.0 changestates:
changeStates();
(. 8.2).
LifeGame3.
, - - .
. - "" , . : www.math.cora/students/wonders/life/life.htnil.
- . -
(OK), ( - ).
:
for(int i = 0; i<N; i++) for(int j = 0; j<N; j++) alive [i][j] = false; alive[22][23] = true; alive[22][24] = true;
, ( false). true , . (. . 8.3), , , . . ( , ) .
LifeGame4.
8.2. " " (Harvest)
. , , , : , . , . , , . (, ). ko- . , , , .
|
|
Harvest. (. 8.4) . , (, ), ( ), , .
, . (cart) (combain) (Truck) . (Bin) (Field) . ,
, . , .