commit b381ef759b8aa2ebde06febebaaa13f1a1659e0f Author: Marcelina Szostak Date: Sat Dec 7 15:53:30 2024 +0100 Initial Commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cba7efc --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +a.out diff --git a/gol.c b/gol.c new file mode 100644 index 0000000..9a75a11 --- /dev/null +++ b/gol.c @@ -0,0 +1,49 @@ +#include + +#define SIZE 512 + + + +int main() +{ + bool grid[SIZE][SIZE]; + + for(int i = 0; i < SIZE;){ + for(int j = 0; i < SIZE;){ + grid[i][j] = false; + } + } + + for(int i = 0; i < SIZE;){ + for(int j = 0; i < SIZE;){ + int neighbours = 0; + + int nx_prawo = i + 1 > SIZE ? 0 + (i + 1 - SIZE) : i + 1; + int ny_prawo = j; + + int nx_lewo = i - 1 < 0 ? SIZE - (i - 1 + SIZE) : i - 1; + int ny_lewo = j; + + int nx_gora = i; + int ny_gora = j + 1 > SIZE ? 0 + (j + 1 - SIZE) : j + 1; + + int nx_dol = i; + int ny_dol = j - 1 < 0 ? SIZE - (j - 1 + SIZE) : j - 1; + + neighbours = grid[nx_prawo][ny_prawo] == true ? neighbours + 1 : neighbours; + neighbours = grid[nx_lewo][ny_lewo] == true ? neighbours + 1 : neighbours; + neighbours = grid[nx_gora][ny_gora] == true ? neighbours + 1 : neighbours; + neighbours = grid[nx_dol][ny_dol] == true ? neighbours + 1 : neighbours; + + int state = 0; + + state = neighbours < 2 ? 1 : neighbours == 2 || neighbours == 3 ? 2 : neighbours > 3 ? 3 : neighbours == 3 ? 4 : 0; + + switch (state) + { + case 1: + } + } + } + +}