Automaton

We call our implementation automaton and, when run, it presents a pair of blank grids side by side. The lefthand grid displays cell colony generations with the calculations being done with sequential logic. The righthand grid displays cell colony generations with the calculations being done with parallel logic using Threading Building Blocks. Above each grid is the current generation number. Running on a single-processor core will work, but the results will vary based on the threads that get priority. Some will see the parallel side appear to be faster, even on a single-core processor, because it will have more resources competing fairly for the single-processor core than the sequential version (see the section “Fair Scheduling,” in Chapter 9). Other machines show the opposite behavior because the sequential thread ends up with a priority. Neither result says anything about the efficiency of the parallel version. However, if you run this code on a quad-core (or better) processor, you will see a commensurate increase in speed for the parallel side due to true parallelism.

The Game of Life was originally assumed to take place on an infinite space. In this implementation, both of the grids wrap. The top edge is treated as though it is connected to the bottom edge, and the left edge is treated as though it is connected to the right edge. Therefore, a glider pattern moving off one edge will come into the grid from the opposite edge.

To seed both grids with the same starting cell pattern, you pull down the Game menu and select Seed. A random cell pattern is generated and placed into both grids. To begin the processing, pull down the Game menu again and select Run. Soon you will see a display similar to that shown in Figure 11-4.

Automaton in action

Figure 11-4. Automaton in action

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.18.220.243