int countNeighbours(boolean[][] map, int i, int j) {
		int count = 0;

		// 1 2 3
		// 4 X 5
		// 6 7 8

		for (int x = -1; x < 2; x++) {
			for (int y = -1; y < 2; y++) {
				int nx = i + x;
				int ny = j + y;
				if (x == 0 && y == 0)
					continue;
				if (ny < 0 || ny >= height) {
					count++;
				} else if (nx < 0 || nx >= width) {
					// do nothing
				} else {
					if (map[nx][ny])
						count++;
				}

			}
		}

		return count;
	}