Пример #1
0
    public ActionAStar(ActionGraph graph, GoapActionNode start, Dictionary <string, object> goal)
    {
        var frontier = new Priority_Queue.FastPriorityQueue <GoapActionNode>(10000);

        frontier.Enqueue(start, 0);
        cameFrom[start]  = start;
        costSoFar[start] = 0;
        while (frontier.Count > 0)
        {
            var current = frontier.Dequeue();
            if (MeetsGoal(current, goal))
            {
                finalPoint = current;
                break;
            }
            foreach (var next in graph.Neighbors(current))
            {
                float newCost = costSoFar[current] + graph.Cost(current, next);
                if (!costSoFar.ContainsKey(next) || newCost < costSoFar[next])
                {
                    costSoFar[next] = newCost;
                    float priority = newCost + Heuristic(next, goal);
                    frontier.Enqueue(next, priority);
                    cameFrom[next] = current;
                }
            }
        }
    }
Пример #2
0
    public Dictionary <Coordinates, Coordinates> SearchUnfilled(Graph graph, Coordinates start, Coordinates end)
    {
        var frontier = new Priority_Queue.FastPriorityQueue <Coordinates>(10000);

        frontier.Enqueue(start, 0);
        cameFrom[start]  = start;
        costSoFar[start] = 0;
        while (frontier.Count > 0)
        {
            var current = frontier.Dequeue();
            if (current == end)
            {
                this.end = current;
                break;
            }
            foreach (var next in graph.Neighbors(current))
            {
                float newCost = costSoFar[current] + graph.Cost(next);
                if (!costSoFar.ContainsKey(next) || newCost < costSoFar[next])
                {
                    costSoFar[next] = newCost;
                    float priority = newCost + Heuristic(next, end);
                    frontier.Enqueue(next, priority);
                    cameFrom[next] = current;
                }
            }
        }
        return(cameFrom);
    }
Пример #3
0
 public SimplePriorityQueue()
 {
     _queue = new FastPriorityQueue <SimpleNode>(InitialQueueSize);
 }
Пример #4
0
 public SimplePriorityQueue()
 {
     _queue = new FastPriorityQueue <SimpleNode>(INITIAL_QUEUE_SIZE);
 }
Пример #5
0
 public PriorityQueue()
 {
     queue = new FastPriorityQueue <Node>(INITIAL_QUEUE_SIZE);
 }