Conways game of life
in
Programming Questions
•
11 months ago
- int[][] feld=new int[10][10];
int[][] z=new int[10][10];
int xs=0;
int ys=0;
// --------------------------------------------------------
// Setup
void setup() {
size(320,320);
xs=width/8;
ys=height/8;
smooth(); frameRate(1);
for (int x=1;x < 9; x++) {
for (int y=1;y < 9; y++) {
if (int(random(0,9))==1) feld[x][y]=1;
}
}
fill(0,0,0);
}
// --------------------------------------------------------
// Hauptfunktion
void draw() {
background(255,255,255);
int l=0;
for (int x=1;x < 9; x++) {
for (int y=1;y < 9; y++) {
l=-feld[x][y];
for (int xx=-1; xx < 2; xx++) {
for (int yy=-1; yy < 2; yy++) {
l+=feld[x+xx][y+yy];
}
}
if (l > 1) { z[x][y]=1; }
if (l < 7) { z[x][y]=-1 ; }
//if (l==9) { z[x][y]=0; }
//else {z[x][y]=-1;}
}
}
for (int x=1;x < 9; x++) {
for (int y=1;y < 9; y++) {
feld[x][y]=z[x][y];
if (feld[x][y]==1) {
rect((x-1)*xs,(y-1)*ys,xs-1,ys-1);
}
}
}
}
as a beginner my game of life should follow 1 rule, but i am not able to figure it out :c
i want that it starts with 2 blocks and if the chessboard is full everybody dies 8 (
i hope you can help me
sorry for my bad english....
markus
i want that it starts with 2 blocks and if the chessboard is full everybody dies 8 (
i hope you can help me
sorry for my bad english....
markus
1