Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

The Game of Life - Please HELP!  RSS feed

 
jason candelora
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is my code...I was hoping I could get another pair of eyes to scan it and see what I might be doing wrong...All of my organisms die after the first cycle!

Any help would be appreciated!!!
Jason Candelora
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jason,
As I understand the rules here:
The number of live neighbors is always based on the cells before the rule was applied. In other words, we must first find all of the cells that change before changing any of them.

This means that you must have at least 2 boards in use. One that is the current state for checking and one that is being changed. After the change you can then make the changed one the current one.
In your case, it looks like you are only using one board which would explain why your oganisms are dying fast.
Regards,
Manfred.
 
jason candelora
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, I appreciate the help!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!