root/test/manual/etags/cp-src/conway.hpp

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. alive
  2. read
  3. set
  4. clear
  5. compute_next_state
  6. step

     1 /* ======================================================================= */
     2 /*                                 CONWAY.H                                */
     3 /* ======================================================================= */
     4 
     5 class site: public location
     6     {
     7     char x, y, alive, next_alive;
     8     int total_surrounding(void);
     9 public:
    10     site(int xi, int yi): x(xi), y(yi), alive(0) { }
    11     ~site();
    12     char read() { return alive; }
    13     void set(void) { alive = 1; }
    14     void clear(void) { alive = 0; }
    15     void compute_next_state(void)
    16         {
    17         int n = total_surrounding();
    18         next_alive = alive;
    19         if (n < 2 || n > 3) next_alive = 0;
    20         else if (n > 2) next_alive = 1;
    21         }
    22     void step(void) { alive = next_alive; }
    23     };

/* [<][>][^][v][top][bottom][index][help] */