Results 21 to 27 of 27
Thread: Game of Life , Adam & Eve
- 09-23-2011, 11:27 PM #21
Member
- Join Date
- Sep 2011
- Posts
- 13
- Rep Power
- 0
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 #22
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 #23
Member
- Join Date
- Sep 2011
- Posts
- 13
- Rep Power
- 0
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?Last edited by rapito; 09-24-2011 at 01:46 AM.
- 09-24-2011, 03:25 AM #24
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:
Java 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 ){Last edited by Norm; 09-24-2011 at 03:27 AM.
- 09-24-2011, 03:26 AM #25
Member
- Join Date
- Sep 2011
- Posts
- 13
- Rep Power
- 0
Re: Game of Life , Adam & Eve
I got it working...
This is the zip file containing it:
TDO.zip
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 #26
Re: Game of Life , Adam & Eve
See the end of my last postmy CellEntity class was behaving as static.
- 09-24-2011, 03:34 AM #27
Member
- Join Date
- Sep 2011
- Posts
- 13
- Rep Power
- 0
Similar Threads
-
game of life, using 2d array
By aramiky818 in forum New To JavaReplies: 1Last Post: 09-09-2011, 05:47 AM -
Game of Life GUI Error
By Lavace in forum New To JavaReplies: 3Last Post: 01-03-2011, 01:57 PM -
Game of life methods help
By bigskers76 in forum New To JavaReplies: 26Last Post: 12-12-2009, 03:11 PM -
game of life
By bigskers76 in forum New To JavaReplies: 10Last Post: 12-09-2009, 05:21 AM -
A more efficient Game of Life
By unreal4evr in forum New To JavaReplies: 3Last Post: 03-27-2009, 03:08 AM


4Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks