Lab 12: Instructor's Notes


As a fun way to explore two-dimensional vectors, this exercise builds a class that facilitates playing John Conway's cellular automata "game of Life." The game involves processing a grid of cells, which we represent as a two-dimensional vector of vector of integers.

To facilitate this exercise, we provide several files:

The LifeGame class constructor initializes itself with a configuration stored in an input file. To facilitate exploring the game, we also provide several different configuration files, including test.life, stable.life, quick.life, cross1.life, cross2.life, glider.life, gliders.life, and blank.life.

As usual, if you wish to avoid network contention, save local copies of these files ahead of time and direct your students to access those local copies.

Note: At the time this is being written (May 1998), the CodeWarrior 3.0 compiler does not handle nested vectors properly, but generates an error like:

  Error   : declaration syntax error
  (instantiating: 'std::iterator_traits> *>')
  iterator line 63   typedef typename Iterator::difference_type difference_type;
when operations that use iterators (like push_back()) are used with vectors of vectors.

Metrowerks has provided a work-around, which is to insert the lines:

   __MSL_FIX_ITERATORS__(vector<int>);
   __MSL_FIX_ITERATORS__(vector< vector<int> >);
just above the declaration of your vector-using class. We have placed these lines in the appropriate place in LifeGame.h, but we have commented them out. If you encounter the above error, uncomment these lines in LifeGame.h and the error should be eliminated.

Metrowerks has promised a patch to fix the problem by June 1998, so if your compiler generates the error, contact Metrowerks for the patch and install it on your system.


Back to This Lab's Home Page

Forward to the Prelab Questions


Copyright 1998 by Joel C. Adams. All rights reserved.