x404.co.uk
http://www.x404.co.uk/forum/

Updated Game Of Life
http://www.x404.co.uk/forum/viewtopic.php?f=4&t=16460
Page 1 of 1

Author:  Fogmeister [ Mon May 21, 2012 2:07 pm ]
Post subject:  Updated Game Of Life

Just submitted an update to my Game of Life app.

CLICKY!

I've added a few nice features to it and massively massively increased the performance.

The new features are...
* You can now change the speed at which the simulation runs. The current version runs at 10 GPS (generationns per second). You can now change it to run anywhere from 5 seconds per generation to 60GPS.
* You can now toggle edge wrapping on and off.

The main changes are "under the hood" though. I wouldn't have been able to just ramp the speed up to 60GPS as the sim and the drawing just wouldn't handle it. I've had to optimise the GOL engine and the way it draws to get the best performance out of it.

Now it uses bit operations to speed up the way it calculates whether a cell should be alive or dead in the next generation and it also keeps track of which parts of the map are changing. It only checks cells that either changed themselves or have neighbours who changed in the last generation step.

So, if there is a single cell that keeps flashing on and off then the whole generation step only checks 9 cells.

Very pleased with it. Except I've had to pull it as I found a tiny bug but that will be fixed and resubmitted tonight :D So far I've had about 15 5 star reviews (from around the world) and I don't want to let a tiny, easy to fix bug ruin it.

Author:  Fogmeister [ Mon May 21, 2012 9:06 pm ]
Post subject:  Re: Updated Game Of Life

Right, uploaded an updated version.

I've actually added something that I was thinking of the other day also so that's good.

You can now show/hide the stats on the population. It just shows Generation number and Population count.

Author:  Fogmeister [ Tue May 22, 2012 9:20 pm ]
Post subject:  Re: Updated Game Of Life

OK, just updated the draw function to improve performance even further.

I'm not going to release it though.

If I keep submitting updates it'll never actually get approved.

Before I started tonight the draw function went through every single cell on the screen and checked if it was alive. If it was alive it then drew a rectangle onto the screen for that cell.

i.e. for y from 0 to 48
for x from 0 to 32
if cellIsAlive (runs on the model)
then draw rect at (x, y).

Now it sends an x, y coord into the model and gets back a width and whether that width is alive or dead.
If it is alive it adds a rectangle starting from x, y of the width and adds width to the x value.
If it is not alive it just adds width to the x value.
When x gets to the end of the line it goes to the next line.

::EDIT::

Gah! I gave in to temptation and resubmitted my latest version. It takes it from a max of around 35GPS (Generations Per Second) to a mix of around 56-57GPS.

Considering that the maximum FPS on an iPhone is 60FPS I'm quite pleased with that :D

Still room for improvement though.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/