private List<GridSquare> getGoodNeighbors(GridSquare current,bool[] visited,bool onlyUnexplored) { List<GridSquare> neighbors = new List<GridSquare>(); GridSquare[] squares = {current.Top,current.Left,current.Bottom,current.Right}; foreach (GridSquare s in squares) { if (s == null) continue; if (visited[s.getHash ()]) continue; if (s.isBlocked ()) continue; if (onlyUnexplored && current.isJunction()) { if (current.Junction.hasExplored (s)) continue; } if (evaluateSquare (s,current,visited)) neighbors.Add (s); } return neighbors; }