Week 9: GPU Game of Life


For my ninth weekly project, I’ve created…life!

Although it was originally computed by hand, Conway’s Game of Life has been implemented as software so many times over the past 44 years by so many people that I’m not sure doing my own version even counts as a creative project, but somehow throughout my decades of computer programming I’ve never built one, so I’m doing it anyway.

This particular version is implemented almost entirely on the GPU–the CPU provides the initial state and can turn more cells on to keep the game going, but otherwise all computation is done in a compute shader. (Compute shaders are kind of brilliant for this, as the Game of Life is practically the definition of an embarassingly parallel problem.)

I render live cells in red, and have dead cells fade gradually in green instead of disappearing. This makes it easier to see structures forming and vanishing. The initial condition is just created by randomly drawing pixels all over the buffer, and you can add more at any time by holding down the Enter key.

One thing I found particularly interesting is how many gliders tend to emerge from these completely random starting conditions! With the green trails behind them, they’re very visible. You also get a lot of small, stable structures as well as simple oscillators. (Phase-2 oscillators are almost impossible to see in this simulation, unfortunately, because it moves so fast it makes them look stable.)

Click here to download the program (update: added some DLLs it was missing). It’s a Win32 executable and requires a D3D11-compatible video card (anything even remotely recent should work). There’s some on-screen help-text that explains some other controls you can use.

Week 8: Attempted Cinemagraph

I absolutely adore cinemagraphs–still images with subtle, looping animation. There’s something mesmerizingly timeless about the best ones. For this week’s project, I tried to create my own (large file, may take some time to load–sorry):

It’s just some buildings on 9th St NW as seen out of my window, with the reflection of a car going by. My main takeaway from doing this is to wonder how the heck cinemagraph creators keep their file sizes reasonable! This thing is huge, despite the motion being fairly subtle (everything but the big tree and the car going by is completely still).

On the plus side, I think I hid the point where it loops pretty well (I can’t see it, and I know it’s there)–the end of the original video quickly crossfades back into the beginning.

So, all in all, a modestly successful experiment with some as-yet unsolved problems. Next time I’ll see about reducing the size–by lowering the framerate, using a shorter loop, and/or a smaller animated part of the image.