countClosedNeighbors method

int countClosedNeighbors(
  1. int x,
  2. int y
)

The number of cardinal neighbors of the tile at column x row y that are closed (not open)

Implementation

int countClosedNeighbors(int x, int y) {
  int count = 0;
  for (var n in neighbors(x, y)) {
    if (!n.isOpen) count++;
  }
  return count;
}