# Game of Life , Adam & Eve

Show 40 post(s) from this thread on one page
Page 2 of 2 First 12
• 09-23-2011, 11:27 PM
rapito
Re: Game of Life , Adam & Eve
Back a few post I "binary" explained how it should be if it is 3 in a row...
Using the paint method first it just paints the one at the top and int he bottom of the one in the center meaning this:
000
111
000

does this

020
000
020

2 = Next Cell to live
It should paint the Dead ones though....
• 09-23-2011, 11:34 PM
Norm
Re: Game of Life , Adam & Eve
I have checked it yet but my first idea is that a cell needs 4 states. When counting the neighbors only the alive or dying(currently alive but will be dead) are counted, not the dead or coming alive (currently dead but will be alive).
• 09-23-2011, 11:44 PM
rapito
Re: Game of Life , Adam & Eve
Why should i count the next one to be alive?
I managed to fix the array issue and with the painting debugging my result is how it should be (Just if i click each cell to change its color depending on its next state):

000 -> 020
111 -> 323
000 -> 020

3 = Next Gen Dead Cell
2 = Next Gen Alive Cell

Which four states would these be and what would I use them for?
• 09-24-2011, 03:25 AM
Norm
Re: Game of Life , Adam & Eve
I didn't see that you did that by using two arrays. I only used one to keep the cells' state in.

You have too many statics variables. Here are some changes you could make:
Code:

```        public  CellEntity cells[][] = new CellEntity[X_CELLARRAY][Y_CELLARRAY];                 for (int px=0; px<cells.length ; px++)                         for(int py=0; py<cells[px].length; py++)                 CellEntity[][] newGen = cells.clone();    // Save current map                 for (int px=0; px < cells.length ; px++)                   for(int py=0; py < cells[px].length; py++)                                            cells[px][py].survive(cells, newGen);      // Mark cells in newGen using cells as source         public void survive(CellEntity[][] cells, CellEntity[][] newGen)        {                 int vivas = fam(cells);         public int fam(CellEntity[][] cells) {                                 int fam=0;                 if(x > 0 && x < cells.length-1         && y > 0 && y < cells[0].length-1  ){```
• 09-24-2011, 03:26 AM
rapito
Re: Game of Life , Adam & Eve
I got it working...
This is the zip file containing it:
Attachment 1812
I Will edit my first post and post the solution.

For some reason my CellEntity class was behaving as static.
I fixed my issue by creating a 2 dimensional int array with values calculated with the next gen values instead of having the method kill the cloned array of the Cell Entities, then just make the cels suicide or come ti live dependin on the array values!

Thanks for your help Norm! :D
I Really Appreciate it!
I hope i get an A :P ^_^
• 09-24-2011, 03:28 AM
Norm
Re: Game of Life , Adam & Eve
Quote:

my CellEntity class was behaving as static.
See the end of my last post
• 09-24-2011, 03:34 AM
rapito
Re: Game of Life , Adam & Eve
I tried that too several times, and exatly that same way, got the same results XD
Show 40 post(s) from this thread on one page
Page 2 of 2 First 12