#include "ofApp.h"

// Variable length array declaration not allowed at file scope
// So add "const" to declare the variable is fixed

const int gridSize = 480;
const int cellSize = 1;

bool grid[gridSize][gridSize];
bool nextGrid[gridSize][gridSize];


int countNeighbors(int x, int y) {
    int count = 0;
    for (int i = -1; i <= 1; i++) {
        for (int j = -1; j <= 1; j++) {
            
            int ni = x + i;
            int nj = y + j;
            
            // x, y , and expect the cell itself
            if (ni >= 0 && ni < gridSize &&
                nj >= 0 && nj < gridSize &&
                !(i == 0 && j == 0)) {
                // if grid == true aka (1), count++
                if (grid[ni][nj]) {
                    count++;
                }
            }
        }
    }
    return count;
}


ofImage image;