Initial Commit

This commit is contained in:
Marcelina Szostak 2024-12-07 15:53:30 +01:00
commit b381ef759b
No known key found for this signature in database
GPG Key ID: BE51722E80D2B63F
2 changed files with 50 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
a.out

49
gol.c Normal file
View File

@ -0,0 +1,49 @@
#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:
}
}
}
}