]> code.delx.au - gnu-emacs/blob - test/manual/etags/cp-src/conway.hpp
Merge from origin/emacs-25
[gnu-emacs] / test / manual / etags / cp-src / conway.hpp
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 };