Game of Life in Java


git clone git://

Since I recently got back into Java recently, I threw together this little Game of Life implementation in Java. It looks a lot like my maze generator/solver on the inside, reflecting the way I think about these things. Gavin wrote a competing version of the game in Processing which we were partially discussing the other night, so I made my own.

The individual cells are actually objects themselves, so you could inherit the abstract Cell class and drop in your own rules. I bet you could even write a Cell that does the iterated prisoner's dilemma cellular automata. The Cell objects are wired together into a sort of mesh network. Instead of growing it wraps around on the sides.

It takes up to four arguments right now, with three types of cells, basic, implementing the basic Conway's Game of Life, growth, which is a cell that matures over time, and random which mixes both types together (seen in the screenshot). The arguments work as follows,

java -jar GoL.jar [<cell type> [<width> <height> [<cell pixel width>]]]

I may look into extending this to do some things beyond simple cellular automata.

Have a comment on this article? Start a discussion in my public inbox by sending an email to ~skeeto/ [mailing list etiquette] , or see existing discussions.

This post has archived comments.

null program

Chris Wellons (PGP)
~skeeto/ (view)