This site requires JavaScript, please enable it in your browser!
Greenfoot back

Comments for Game of life

Return to Game of life

A new version of this scenario was uploaded on Thu Jul 19 22:26:49 UTC 2012
I'm trying to add the ability to draw in your own Cells, but I can't figure out hoe to use MouseInfo.
[code]/** * Check mouse input. */ private void checkMouse() { if(MouseInfo.getActor() = EmptyCell.class){ removeObject(EmptyCell); addObject(new Cell(), mx, my); } }[code/]
A new version of this scenario was uploaded on Fri Jul 20 01:30:47 UTC 2012
A new version of this scenario was uploaded on Fri Jul 20 01:32:31 UTC 2012 It now corrisponds with Conway"s rules or life I just need to find a way to get the cells into the game.
A new version of this scenario was uploaded on Mon Jul 30 00:28:02 UTC 2012 Game actually plays now, click to place cells, hold space to run.
DonaldDuckDonaldDuck

2012/7/30

You may want to add a failsafe (if !Greenfoot.isKeyDown("space") { running = false; }) because there is a glitch where if often thinks the spacebar is down when it's not.
@DonaldDuck Where in the code would I put that?
DonaldDuckDonaldDuck

2012/8/14

In the act method or wherever you check for the spacebar being pressed
I'm not sure the rules are being modeled correctly, as several famous configurations like the glider of the F-pentomino do not give the proper results.
danpostdanpost

2012/8/14

I think the problem is due to the code to change each cell is in the act method which will not work properly there. The way it needs to work is that all cells need to be calculated to determine the next state for all the cells before changing any of them. And then, changing all of them at once. In other words, the press of the spacebar should be in the sub-class of world, and each time it is found to be pressed iterate through all the cells to figure out there next states, and then iterate though all the cells, changing to the states figured.
@ Builderboy2005 The rules aren't working properly right now because the world starts full of "empty cells" and placing populated cells on top of them doesn't remove the empty cell class(right now, I'm still trying to figure that). Which means all the cells think they have one more empty cell around them then they actually do.
I just got super busy with school so I probably won't be working on this for a long time, if you like the game there are other completed ones on greenfoot as well many other places online.