Here is a fun example written with a combination of C++ to use
parallel_for from Threading Building Blocks and managed C++ code for the user interface code. This example implements the Game of Life invented by British mathematician, John Horton Conway. It was widely popularized when Martin Gardner described it in his “Mathematical Games” column in Scientific American in October 1970. It was popular from the start, but it also opened up a new field of mathematical research known as cellular automata and spurred work in the field of simulation games.
The Game of Life is played on a two-dimensional orthogonal grid of square cells, each of which is in one of two possible states: live or dead. Every cell interacts with its eight neighbors, which are the cells that touch the cell (horizontally, vertically, or diagonally). At every step in life, each cell lives, dies, stays empty, or is born because of a simple decision based on the surrounding population (number of neighbors).
Life persists in any cell where it is also present in two or three of the eight neighboring cells, and otherwise disappears (due to loneliness or overcrowding). Life is born in any empty cell for which there is life in exactly three of the eight neighboring cells. The decision-making is illustrated in Figure 11-1. A small grid containing five living cells is shown in Figure 11-2. As you can see, The Game of Life is beautifully parallel.
Figure 11-1. How to decide whether a cell lives, dies, is born, ...