Implementation

This program runs two simultaneous instances of this Game of Life. To show a side-by-side comparison, one of these instances is calculated using sequential programming and the other is calculated using parallel programming.

Each generation of a colony is calculated based on the position of the cells in the preceding generation. The decisions that determine what the next generation looks like are shown in Figure 11-1. Generation after generation, a colony grows, shrinks, and changes according to these very simple rules. Usually, it will eventually reach a state where every living cell stays alive, or where small figures oscillate between two or more repeating states. If we calculate the next four generations for the colony in Figure 11-2, we will see it progressing as shown in Figure 11-3.

Game of Life: Four sample steps

Figure 11-3. Game of Life: Four sample steps

The colony in this figure actually oscillates among four patterns, while at the same time moving diagonally across the grid. This pattern is known as the glider among Game of Life aficionados.

Get Intel Threading Building Blocks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.