Projects

ChipKIT: Conway's Game of Life on VGA, now with more colours

Last updated: Nov. 4, 2011, 8:46 p.m.

The classic Conway's Game of Life with different colour pixels indicating time since birth/death.

Life With More Colours: The classic Conway's Game of Life with different colour pixels indicating time since birth/death.

If you haven't already, check out my ChipKIT implementation of Conway's Game of Life because I'm not explaining all that again! In this version there are some subtle changes to it that make it more pretty to watch, although arguably more confusing to see what's going on.

Keeping Track of Age

When I was showing the Life implementation at an open day, someone at Bristol Hackspace suggested it might be interesting to see how the population was ageing and seeing where the areas of most rapid change were, and which areas had been stable for a long time. Considering the colour depth of the monitor (256 colours) I thought that an age between 0 and 7 for each dead or alive pixel would look reasonable and set about adapting the code. The only significant change to the display code is that it now uses a colour look up table to decide what 8 bit value to draw based on the byte read from the screen array. I've left the screen array with one byte per pixel, although this is inefficient as each pixel is represented by only 4 bits. The most significant of the four bits is a binary dead/alive flag, the least significant three represent how many turns the pixel has been in this state and are incremented in a saturating way each time the board is updated. This gives a set of 16 colours, the first 8 (0-7) are shades of red fading to orange which displays most recently dead to longest inactive. The next 8 (8-15) fade from green to blue representing just born to oldest alive.

In the game logic the update of the screen values based on the age of the pixel is handled in the case where the state (dead/alive) of the pixel hasn't changed. In the case it has changed then the pixel is set to dead/alive at zero age. Because the dead/alive flag bit has been moved to bit 3 of the byte, the neighbour count is now compared to a multiple of the symbolic alive value. This means that if three neighbours are alive the sum of the 3rd bits is 24 rather than just 3 but as the thresholds are multiplied by 8 then this will still work out right.

AttachmentLast UpdateSize
ChipKIT UNO32 sketchMay 21, 2014, 10:08 p.m.7.5 KB
Section:
Projects
Tags:
ChipKit,
VGA,
Open Hardware,
Game of Life

Comments

Posting comments is not currently possible. If you want to discuss this article you can reach me on twitter or via email.


Contact

Email: nathan@nathandumont.com

Twitter: @hairymnstr

Links