a-star

Implement A star (A*) path algorithm in large map, low performance

天大地大妈咪最大 提交于 2020-01-11 10:09:31
问题 I'm using this A star (A*) Pathfinder.java to calculate & generate my route in an Android map app. https://github.com/xSmallDeadGuyx/SimpleAStar/blob/master/Pathfinder.java The size of the map is large, dimensions around 8000x8000, when I use the A star Pathfinder.java to calculate the route from one to another point in the map. The A star Pathfinder calculate 1 by 1 and used in the large map (8000x8000), the performance/calculation speed is quite low/slow (not efficient). I have tried to

Manhattan distance in A*

拈花ヽ惹草 提交于 2020-01-11 02:21:07
问题 I am implementing a NxN puzzle solver using A* search algorithm and using Manhattan distance as a heuristic and I've run into a curious bug (?) which I can't wrap my head around. Consider these puzzles (0 element being blank space): (initial) 1 0 2 7 5 4 8 6 3 (goal) 1 2 3 4 5 6 7 8 0 The minumum number of moves to reach solution from initial state is 11. However, my solver, reaches goal in 17 moves. And therein lies the problem - my puzzle solver mostly solves the solvable puzzles in a

Pathfinding in 2D Arrays

半城伤御伤魂 提交于 2020-01-04 06:08:11
问题 Let's say I have this 2D Array map { 0,0,0,0,7,1,1,1,1,1,1,1,1 }, { 0,7,7,7,7,1,1,1,24,1,1,1,1 }, { 0,7,24,24,24,24,24,24,24,1,1,3,1 }, { 0,7,23,23,23,23,23,23,24,1,1,3,1 }, { 0,7,24,23,23,23,23,23,23,1,1,1,1 }, { 0,7,24,23,23,23,23,23,23,1,1,1,1 }, { 0,7,23,23,23,23,23,23,24,1,3,1,1 }, { 0,7,24,24,24,24,24,24,24,1,3,1,1 }, { 0,0,0,0,1,1,1,1,1,1,1,1,1 }, and I have HashSet full of Integers that define blocked tiles. What would be a good way so that when I click on one part of the map from

Pathfinding in 2D Arrays

[亡魂溺海] 提交于 2020-01-04 06:08:05
问题 Let's say I have this 2D Array map { 0,0,0,0,7,1,1,1,1,1,1,1,1 }, { 0,7,7,7,7,1,1,1,24,1,1,1,1 }, { 0,7,24,24,24,24,24,24,24,1,1,3,1 }, { 0,7,23,23,23,23,23,23,24,1,1,3,1 }, { 0,7,24,23,23,23,23,23,23,1,1,1,1 }, { 0,7,24,23,23,23,23,23,23,1,1,1,1 }, { 0,7,23,23,23,23,23,23,24,1,3,1,1 }, { 0,7,24,24,24,24,24,24,24,1,3,1,1 }, { 0,0,0,0,1,1,1,1,1,1,1,1,1 }, and I have HashSet full of Integers that define blocked tiles. What would be a good way so that when I click on one part of the map from

C++ A-star implementation — determining whether a node is already in the priority queue of open items

我的未来我决定 提交于 2020-01-02 14:05:52
问题 One step in the A* pathfinding algorithm requires searching the list of open nodes for the node you're currently interacting with, and adding that node to the list if it isn't already there, or updating its value and parent, if it's present but with a higher weight than the current version of the node. These behaviors aren't supported in the STL priority_queue structure. How should I implement that step? Updates since this question is getting a lot of views: std::priority_queue may look like

C++ A-star implementation — determining whether a node is already in the priority queue of open items

﹥>﹥吖頭↗ 提交于 2020-01-02 14:05:22
问题 One step in the A* pathfinding algorithm requires searching the list of open nodes for the node you're currently interacting with, and adding that node to the list if it isn't already there, or updating its value and parent, if it's present but with a higher weight than the current version of the node. These behaviors aren't supported in the STL priority_queue structure. How should I implement that step? Updates since this question is getting a lot of views: std::priority_queue may look like

Understanding A* heuristics for single goal maze

旧城冷巷雨未停 提交于 2020-01-02 04:04:42
问题 I have a maze like the following: |||||||||||||||||||||||||||||||||||| | P| | ||||||||||||||||||||||| |||||||| | | || | | ||||||| || | | || | | | | |||| ||||||||| || ||||| | || | | | | || || | | || | | | | | |||| ||| |||||| | | | | | | | || |||||||| | | || | | |||||||| || || ||||| | || | || ||||||||| || | | |||||| ||||||| || |||||| | |||||| | |||| || | | | |||||| ||||| | || || ||||| | |||||| | ||||| || | | |||||| ||||||||||| || || | |||||||||| |||||| | |+ |||||||||||||||| | ||||||||||||||||||

questions regarding the use of A* with the 15-square puzzle

孤街醉人 提交于 2020-01-01 02:01:12
问题 I'm trying to build an A* solver for a 15-square puzzle. The goal is to re-arrange the tiles so that they appear in their natural positions. You can only slide one tile at a time. Each possible state of the puzzle is a node in the search graph. For the h(x) function, I am using an aggregate sum, across all tiles, of the tile's dislocation from the goal state. In the above image, the 5 is at location 0,0, and it belongs at location 1,0, therefore it contributes 1 to the h(x) function. The next

A* Algorithm for very large graphs, any thoughts on caching shortcuts?

北战南征 提交于 2019-12-31 08:14:06
问题 I'm writing a courier/logistics simulation on OpenStreetMap maps and have realised that the basic A* algorithm as pictured below is not going to be fast enough for large maps (like Greater London). The green nodes correspond to ones that were put in the open set/priority queue and due to the huge number (the whole map is something like 1-2 million), it takes 5 seconds or so to find the route pictured. Unfortunately 100ms per route is about my absolute limit. Currently, the nodes are stored in

What are some good methods to finding a heuristic for the A* algorithm?

好久不见. 提交于 2019-12-30 06:49:16
问题 You have a map of square tiles where you can move in any of the 8 directions. Given that you have function called cost(tile1, tile2) which tells you the cost of moving from one adjacent tile to another, how do you find a heuristic function h(y, goal) that is both admissible and consistent? Can a method for finding the heuristic be generalized given this setting, or would it be vary differently depending on the cost function? 回答1: Amit's tutorial is one of the best I've seen on A* (Amit's page