]> git.friedersdorff.com Git - max/gol.git/blob - array.h
First working implementation
[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         int_least32_t max_x;
18         int_least32_t min_x;
19         int_least32_t max_y;
20         int_least32_t min_y;
21 };
22
23 /*
24  * Check that a cell located at (x,y) in the game board is live.
25  */
26 int gol_is_live(struct gol_board *state, int_least32_t x, int_least32_t y, char *is_live);
27
28 /*
29  * Append the coordinates of the live cell to the array.
30  */
31 int gol_vivify(struct gol_board *state, int_least32_t x, int_least32_t y);
32
33 #endif