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; } } } }
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); }
public SimplePriorityQueue() { _queue = new FastPriorityQueue <SimpleNode>(InitialQueueSize); }
public SimplePriorityQueue() { _queue = new FastPriorityQueue <SimpleNode>(INITIAL_QUEUE_SIZE); }
public PriorityQueue() { queue = new FastPriorityQueue <Node>(INITIAL_QUEUE_SIZE); }