]> git.friedersdorff.com Git - max/gol.git/blob - array.h
42c5415b24337d219e9da0d9d9c9fb40b8402b58
[max/gol.git] / array.h
1 #ifndef GOL_ARRAY_H
2 #define GOL_ARRAY_H
3
4 #include <stdint.h>
5
6
7 /* 
8  * Represents a state of the Game of Life.  The coordinates of all live cells
9  * is stored in an array: [x1, y1, x2, y2, x3, y3,...].  N is the number of
10  * live cells, size is the size of the array. 
11  */
12
13 struct gol_board {
14         int_least32_t *live_cells;
15         uint_least32_t n;
16         uint_least32_t size;
17 };
18
19 /*
20  * Check that a cell located at (x,y) in the game board is live.
21  */
22 int gol_is_live(struct gol_board *state, int_least32_t x, int_least32_t y);
23
24 /*
25  * Append the coordinates of the live cell to the array.
26  */
27 int gol_vivify(struct gol_board *state, int_least32_t x, int_least32_t y);
28
29 #endif