-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Minimal CMake
By :

Before we wrap up, let’s make one small addition to our application. We’d like to improve the performance of our update logic in our current implementation of Game of Life. One subtlety of implementing Game of Life is we can’t change the board we’re reading from at the same time. If we do, then the cells from the row we’re on will have changed from their earlier state by the time we get to the next row, which will mean the simulation won’t run correctly. In the implementation in ch2/part2
(a reminder to refer to https://github.com/PacktPublishing/Minimal-CMake to find this), we simply make a copy of the whole board, read from that in update_board
(see line 72 in ch2/part-2/main.c
) and write back to the original board. This is okay, but if most cells don’t change, it’s wasteful. A better approach is to record the cells that change, and then write back to the original board at the end. By doing this, we only...