Conway’s game of life

Today I randomly decided to try and replicate the game of life using SDL2 and C++.

Surprisingly I got pretty far in one go and didn’t scrap the idea after 10 minutes but in the end I realized that my version doesn’t behave like the actual game of life, since it doesn’t exactly follow the rules.

Anyway, the game basically consists of a square field which is devided up into cells. These cells can either be alive or dead.

The state of cells can change by the following rules:

  • If a dead cell is surrounded by exactly three living cells it’ll become alive in the next generation.
  • If a living cell has only one living neighbor it’ll die in the next generation
  • If a living cell has two or three living neighbors it’ll stay alive
  • If a living cell is surrounded by four or more living cells it’ll die

Surrounding means all eight cells around it, directly connected or diagonally. Seems simple enough right? Well I still managed to fudge it up, since mine doesn’t quite stick to these rules, but it still produces some cool results.

Selfhtml

So, yeah don’t expect too much it’s only about 300 lines of bad structured c++. And as always here’s the sourcecode and binaries. (Also includes a linux build)

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s