conways_gol/gol.c
Marcelina Szostak b381ef759b
Initial Commit
2024-12-07 15:53:30 +01:00

50 lines
1.1 KiB
C

#include <stdbool.h>
#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:
}
}
}
}