Game of Life (revisited)

In an earlier Game of Life post, I had my Arduino Uno simulate ‘Life’ on a modest 64×32 cell grid. After receiving the ESP8266 WiFi Color Display Kit from Squix (see previous post), I discovered Bodmer’s TFT_eSPI library, highly optimized for its 320×240 ili9341 display in combination with esp8266 based boards. It even comes with a Game of Life example sketch!

Bodmer’s example would clearly run out of memory for 1-pixel cell grids, because it stores every single 1-bit cell state in its own 8-bit integer! So I modified the sketch, now storing eight consecutive cell states in one byte, like I had already been forced to do in my¬†earlier Game of Life sketch.

The small price for this storage expansion (by a factor of 8!) is speed, but the library is so fast that the result is still beyond my expectation. The video shows that a 320×240 grid can easily handle patterns as large as the famous Line puffer. (After I made the video, I discovered that the pattern moves noticeably faster if the esp8266 ‘s clock speed is set to 160MHz, and even faster on an ESP32.)

I wrote a small application that converts RLE* files to grid initialization commands. These can be used in the initGrid() function of the sketch. More pattern files will be added.

*Run Length Encoded files for many GoL patterns are freely available on Internet.