a-star

pgr_astar and impossible edges (e.g., locked doors)

孤者浪人 提交于 2019-12-11 17:45:39
问题 I'm using postgresql / PostGIS with pgrouting and I need to compute the shortest path. In a previous version of pgrouting, I was using shortest_path_astar. In my routing graph I had impossible segments, such as locked doors. I used: SELECT id FROM shortest_path_astar('SELECT edge_id AS id, vertex_id1 AS source, vertex_id2 AS target, ' || '(CASE WHEN door = ''S'' THEN -1.0 ELSE (length) ) END)::float8 AS cost, ' || '(CASE WHEN door_rev = ''S'' THEN -1.0 ELSE (length) ) END )::float8 AS reverse

c++ boost library astar search tree implementation

一世执手 提交于 2019-12-11 15:05:55
问题 I am trying to implement an A* search tree into a project but I am not understanding how to create my Heuristic class. I have successfully implemented Dijkstra's and Prim's functions on my graph, But I am at a loss on how to create the Heuristic Class and call the astar function. Any help would be greatly appreciated, here is my full code up to this point: #include <iostream> #include <fstream> #include <map> #include <vector> #include <string> #include <sstream> #include "/Boost/boost_1_65_1

Astar parent, getpath

大兔子大兔子 提交于 2019-12-11 14:45:31
问题 there is my astar algorithm, But I don't know how to get parent and get a quick route from the Destination. Node script methods getPos() (Vector2) Parent (Node) Node n = ?.Parent; while(n != null) { path.add(n.getPos()); n = n.Parent; } 回答1: You have to set "current" as parent to the adjacent nodes. Then if the destination is found, you follow the path of the parent entries, this is the path EDIT: Also i can´t see a "cost" implementation ... 来源: https://stackoverflow.com/questions/46565789

A* Algorithm Java

社会主义新天地 提交于 2019-12-11 10:52:17
问题 I have spent entire weekend playing around with this. I am trying to store the nodes in PriorityQueue data structure. My astar function doesnt seem to be doing what it should. Anyone mind having a look? public void aStar(Node from, Node to) { PriorityQueue<Node> exploreList = new PriorityQueue<Node>(); ArrayList<Node> visited = new ArrayList<Node>(); ArrayList<Node> successors = new ArrayList<Node>(); Node current = from; System.out.println(current.getName()); while (current != to) {

Unity 2d A* pathfinding project: how to make ai object patrol to random points?

妖精的绣舞 提交于 2019-12-11 10:51:20
问题 As the title states this question refers to the Unity A* pathfinding project. I downloaded this package for my maze game so that the enemy's ai could navigate through the maze. So far I have followed a tutorial ( link will be provided below ) and everything is set up. However, I don't seem to know how to implement ray casting or another method to make the enemy patrol to a random point in a continuous loop. A* Tutorial Link Note: There is a problem with my current set up though, which I have

Java: Change an objects value without changing all references

Deadly 提交于 2019-12-11 09:23:06
问题 This is probably a noob question, but i just don't get it. I am trying to implement A* pathfinding in my game. I was following this tutorial and the code in the AstarPathfinder.java . But instead of instantiating the AStarPathfinder class and having an 2D Array for all Nodes i made a static method, to which i pass my 2D Array (the Level/World), start and end Node. Cause of this i always have to store the current and the next Node in a Node next and Node current . I then add them to the open

How to compute the running time of A-star algorithm

[亡魂溺海] 提交于 2019-12-11 06:37:35
问题 I am working with A* algorithm. I have a 2D grid, with some obstacles, and given the starting and final position, I find the shortest path between them. Here's my pseudocode while(queueNotEmpty){ removeFromPQ; if(removed == destination) found; insertAllNeighbours; } Remove and insert are the function on priority queue(Heap), and is O(log(n)) time. Considering the dimension of grid as N*N. How do I calculate the running time. i.e how many times will this loop execute? Is there any measure? 回答1

What are the procedures that should be taken when there is a line of sight between two points in Theta star algorithm?

牧云@^-^@ 提交于 2019-12-11 05:21:20
问题 I'm working on Theta star algorithm and I need to implement in Python. As you all know, theta star depends on line-of-sight in its work. When there is a line-of-sight between two points, what will be the procedure here after discovering the line-of-sight?. I know, if there is no line-of-sight, it will work as Astar algorithm, but what about the procedure after discovering there is a line-of-sight, what the algorithm will do here? 来源: https://stackoverflow.com/questions/57565748/what-are-the

How to structure an adjacency list for this A* program

白昼怎懂夜的黑 提交于 2019-12-11 03:17:35
问题 I'm trying to understand the A* path finding algorithm, and how to implement it in a python program. I found this website which does a pretty good job explaining how the algorithm itself works, as well as providing some example code. Here is where I get stuck: def make_graph(mapinfo): nodes = [[AStarGridNode(x, y) for y in range(mapinfo.height)] for x in range(mapinfo.width)] graph = {} for x, y in product(range(mapinfo.width), range(mapinfo.height)): node = nodes[x][y] graph[node] = [] for i

A* pathfinding not taking shortest path

允我心安 提交于 2019-12-10 22:20:49
问题 My A* pathfinding function always gets to its intended destination, but it almost always goes a bit out of the way. Here's an example: [I made a nice image to show my issue, but apparently it won't post until my reputation reaches 10; sorry, I'm new. :P] Essentially, it pulls left or up as much as possible without actually adding more tiles to the path. It sounds like an issue with calculating the gScore or possibly the part where a tile's parent can be reassigned based on neighboring tiles'