int MainWindow::NeighborCount(int row, int column){ int total = 0; if (_isFinite) { if (row - 1 >= 0) { if (gameBoard[row - 1][column]) { total++; } if (column - 1 >= 0) { if (gameBoard[row - 1][column - 1]) { total++; } } if (column + 1 < settings.defaultGridSize) { if (gameBoard[row - 1][column + 1]) { total++; } } } if (row + 1 < settings.defaultGridSize) { if (gameBoard[row + 1][column]) { total++; } if (column + 1 < settings.defaultGridSize) { if (gameBoard[row + 1][column + 1]) { total++; } } if (column - 1 >= 0) { if (gameBoard[row + 1][column - 1]) { total++; } } } if (column + 1 < settings.defaultGridSize) { if (gameBoard[row][column + 1]) { total++; } } if (column - 1 >= 0) { if (gameBoard[row][column - 1]) { total++; } } }