// Conway's Game of Life program // Author: xamidev // Licensed under the Unlicense. See the repo below. // https://github.com/xamidev/blankos #include "conway.h" #include "../libc/stdio.h" #include "../kernel/system.h" #include "../libc/crypto.h" #include #include "../drivers/serial.h" #include "../libc/string.h" void print_grid(const unsigned char grid[X][Y]) { for (int i=0; i= 0 && ni < X && nj >= 0) { if (grid[ni][nj] == LIVE) live_neighbors++; } } } return live_neighbors; } void grid_new_generation(unsigned char grid[X][Y], unsigned char temp[X][Y]) { for (int i=0; i SOUP_PROB ? LIVE : DEAD; } } } void program_conway(int argc, char* argv[]) { clear(); unsigned char grid[X][Y] = {0}; unsigned char temp[X][Y] = {0}; if (argc == 1) { soup(grid); } else if (argc == 2 && strcmp(argv[1], "-g") == 0) { grid[1][2] = LIVE; grid[2][3] = LIVE; grid[3][1] = LIVE; grid[3][2] = LIVE; grid[3][3] = LIVE; } else if (argc == 2 && strcmp(argv[1], "-l") == 0) { grid[10][3] = LIVE; grid[10][4] = LIVE; grid[10][5] = LIVE; grid[10][6] = LIVE; grid[11][2] = LIVE; grid[11][6] = LIVE; grid[12][6] = LIVE; grid[13][2] = LIVE; grid[13][5] = LIVE; } print_grid(grid); puts("generation 0"); for (int i=1; i