Conway's Game of Life! 1.2

After I saw Conway’s game of life on Dara Ó Briain’s maths club, I knew then and there that that would be good for my first solo program. After a bit of help with my malfunctioning code from some VERY kind people…
here: http://www.java-gaming.org/topics/an-array-index-out-of-bounds-exception-i-know-what-that-means-but-why/30036/msg/278077/view.html#msg278077

I made…

THE GAME OF LIFE:
Conway’s game of life is a game that consists of an orthographic grid of cells that can be “alive” or “dead”; it is built on 4 simple rules:
/*
*Live cells with fewer than two live neighbours die.
*Live cells with two or three neighbours live on.
*Live cells with more than three neighbours die.
*Dead cells with two or three live neighbours become live.
*/

it can be quite fun to build contraptions (or societies if you like…) of your own, but one problem with this version is that the window is relatively tiny and there is no option to move the viewing pane. (I could change that but it would take a lot of effort on my part XD)

DOWNLOADS:

1.2 (i.e. adds optional game speeds and cell set up instead of initializing the cells from code)
here: http://www.mediafire.com/download/4ro1aja74tgkics/game_of_life_1_2.zip

CONTROLS:

  • use the mouse and left click to turn on/ turn off a cell.
  • change the game speed (BEFORE activating) using shift/control
  • use enter to activate and watch your simulation.

TESTING:

forgot about a picture XD, got it now!

The rules for Life can actually be expressed more simply:

A live cell with two neighbors stays live.
A live or dead cell with three neighbors is live.
All other cells are dead.

This turns into a one-liner (where a cell is a boolean):
[icode]cell = neighbors == 3 || cell && (neighbors == 2);[/icode]

I know, I found that out when coding, but the rules on the wiki, i.e the rules that would be explained to a player, are in the main post ^

hmm that’s probably simpler to explain to a player too though… XD

A cell is live in the next generation if there are exactly three cells either in its open Moore neighbourhood or in its closed Moore neighbourhood.

Well sure, if you go with CA jargon, you could just say “B3/S23”