private void HelperBruteForce(int[,] Map_data_passable, CheckPassable isPassable, ActionOnVisit action, bool isStack)
    {
        int       count = 0;
        int       newX  = 0;
        int       newY  = 0;
        GraphNode neighbour;

        PriorityListWrapper <GraphNode> openSet   = new PriorityListWrapper <GraphNode>(isStack);
        HashSet <GraphNode>             closedSet = new HashSet <GraphNode>();

        GraphNode originNode = new GraphNode(x, y);

        openSet.Push(originNode);

        while (openSet.Count > 0)
        {
            GraphNode n = openSet.Pop();
            closedSet.Add(n);
            action(Map_data_passable, n);

            count++;
            if (count > 10000)
            {
                Debug.LogError("Infinite Loop");
                break;
            }

            newX           = n.x + 1;
            newY           = n.y;
            neighbour      = new GraphNode(newX, newY);
            neighbour.Prev = n;
            ValidNeighbour(Map_data_passable, isPassable, neighbour, openSet, closedSet);

            newX           = n.x - 1;
            newY           = n.y;
            neighbour      = new GraphNode(newX, newY);
            neighbour.Prev = n;
            ValidNeighbour(Map_data_passable, isPassable, neighbour, openSet, closedSet);

            newX           = n.x;
            newY           = n.y + 1;
            neighbour      = new GraphNode(newX, newY);
            neighbour.Prev = n;
            ValidNeighbour(Map_data_passable, isPassable, neighbour, openSet, closedSet);

            newX           = n.x;
            newY           = n.y - 1;
            neighbour      = new GraphNode(newX, newY);
            neighbour.Prev = n;
            ValidNeighbour(Map_data_passable, isPassable, neighbour, openSet, closedSet);
        }
        CountedTiles = count;
    }
 private void ValidNeighbour(int[,] Map_data_passable,
                             CheckPassable isPassable,
                             GraphNode neighbour,
                             PriorityListWrapper <GraphNode> openSet,
                             HashSet <GraphNode> closedSet)
 {
     if (!MapTools.IsOutOfBounds(neighbour.x, neighbour.y) &&
         isPassable(Map_data_passable[neighbour.x, neighbour.y]) &&
         !closedSet.Contains(neighbour) &&
         !openSet.Contains(neighbour))
     {
         openSet.Push(neighbour);
     }
 }