private static int CountWallsNear(ArrayView <bool> map, Point centerPos, int distance) { int count = 0; foreach (var pos in Radius.Square.PositionsInRadius(centerPos, distance)) { if (map.Contains(pos) && pos != centerPos && !map[pos]) { count += 1; } } return(count); }