12 void init_state(struct gol_board *state);
14 void init_state(struct gol_board *state) {
15 // Create the initial state. This is a glider gun (hopefully)
16 gol_vivify(state, 12, 0);
17 gol_vivify(state, 13, 0);
18 gol_vivify(state, 11, 1);
19 gol_vivify(state, 15, 1);
20 gol_vivify(state, 10, 2);
21 gol_vivify(state, 16, 2);
22 gol_vivify(state, 24, 2);
23 gol_vivify(state, 0, 3);
24 gol_vivify(state, 1, 3);
25 gol_vivify(state, 10, 3);
26 gol_vivify(state, 14, 3);
27 gol_vivify(state, 16, 3);
28 gol_vivify(state, 17, 3);
29 gol_vivify(state, 22, 3);
30 gol_vivify(state, 24, 3);
31 gol_vivify(state, 0, 4);
32 gol_vivify(state, 1, 4);
33 gol_vivify(state, 10, 4);
34 gol_vivify(state, 16, 4);
35 gol_vivify(state, 20, 4);
36 gol_vivify(state, 21, 4);
37 gol_vivify(state, 11, 5);
38 gol_vivify(state, 15, 5);
39 gol_vivify(state, 20, 5);
40 gol_vivify(state, 21, 5);
41 gol_vivify(state, 34, 5);
42 gol_vivify(state, 35, 5);
43 gol_vivify(state, 12, 6);
44 gol_vivify(state, 13, 6);
45 gol_vivify(state, 20, 6);
46 gol_vivify(state, 21, 6);
47 gol_vivify(state, 34, 6);
48 gol_vivify(state, 35, 6);
49 gol_vivify(state, 22, 7);
50 gol_vivify(state, 24, 7);
51 gol_vivify(state, 24, 7);
54 int main(int argc, char* args[])
56 struct gol_board state = {
57 .live_cells = malloc(10 * sizeof(typeof(*state.live_cells))),
65 if (!state.live_cells) {
71 for (unsigned int i = 0; i < 1000; ++i) {
72 printf("Generation %d\n", i);
73 for (unsigned int j = 0; j < state.n; j += 2) {
74 printf("(%d, %d)\n", state.live_cells[j],
75 state.live_cells[j + 1]);
82 SDL_Window* window = NULL;
83 SDL_Surface* screen = NULL;
85 if (SDL_Init(SDL_INIT_EVERYTHING) < 0) {
89 //screen = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE);
91 window = SDL_CreateWindow("SDL Tutorial",
92 SDL_WINDOWPOS_UNDEFINED,
93 SDL_WINDOWPOS_UNDEFINED,
101 screen = SDL_GetWindowSurface(window);
106 SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0xFF, 0xFF, 0xFF));
107 SDL_UpdateWindowSurface(window);
111 SDL_DestroyWindow(window);