a-star

A* Algorithm: closed list contains too many elements / too large

心不动则不痛 提交于 2019-12-18 16:58:53
问题 I'm currently implementing the A* algorithm in JavaScript. However, I've ran into a problem: My closedList seems way too large. Here is a screenshot of the output: What could cause this problem? Is my heuristic calculation wrong? Node.prototype.getHeuristic = function(pos0, pos1) { // Manhatten Distance var horizontalDistance = Math.abs(pos1.x - pos0.x); var verticalDistance = Math.abs(pos1.y - pos0.y); return horizontalDistance + verticalDistance; } Or did I understand/implement something

Unable to implement A Star in java

元气小坏坏 提交于 2019-12-18 16:57:57
问题 I've been trying all day to get this algorithm up and running, but I cant for the life of me. I've read many tutorials on the net, and source code in AS3, javascript, and C++; but I cannot adapt what I am seeing to my own code. I have created an AStar class that has a nested class named Node. The map is a 2D array named MAP. The biggest problem that I am having is pulling the F value in the pathfind function. I have implemented the F = G + H, my problem is the actual AStar algorithm. Can

Python - Speed up an A Star Pathfinding Algorithm

China☆狼群 提交于 2019-12-18 10:01:43
问题 I've coded my first slightly-complex algorithm, an implementation of the A Star Pathfinding algorithm. I followed some Python.org advice on implementing graphs so a dictionary contains all the nodes each node is linked too. Now, since this is all for a game, each node is really just a tile in a grid of nodes, hence how I'm working out the heuristic and my occasional reference to them. Thanks to timeit I know that I can run this function successfully a little over one hundred times a second.

A* heuristic, overestimation/underestimation?

前提是你 提交于 2019-12-17 10:33:16
问题 I am confused about the terms overestimation/underestimation. I perfectly get how A* algorithm works, but i am unsure of the effects of having a heuristic that overestimate or underestimate. Is overestimation when you take the square of the direct birdview-line? And why would it make the algorithm incorrect? The same heuristic is used for all nodes. Is underestimation when you take the squareroot of the direct birdview-line? And why is the algorithm still correct? I can't find an article

Keeping track of tiles in a* search

放肆的年华 提交于 2019-12-13 18:18:05
问题 I am having a hard time keeping track of the tiles generated by getAdjacentTiles(..) . I have identified the performance issue of my A* implementation below is that I do not keep track of the tiles that have seen before, every call to getAdjacentTiles returns new tiles ( Node 's) and not any of the tiles in openSet or closedSet . I decided to use a list of Node objects as all of the tiles created so far, and pass that to getAdjacentTiles to determine if a tile it produces has already been

A* Path finding algorithm running extremely slow [duplicate]

久未见 提交于 2019-12-13 02:43:46
问题 This question already has an answer here : Implement A star (A*) path algorithm in large map, low performance (1 answer) Closed 3 years ago . I am currently working on my first game for android, and my first time creating an a* path finding algorithm. It is a 2d game. I have created one enemy containing this algorithm (ie. It is being ran once every frame) and it slows down performance from 60fps to 1-2 fps. Obviously something is horribly wrong, I have tried looking online for solutions but

Can A* search be simplified in an unweighted graph?

强颜欢笑 提交于 2019-12-13 01:26:16
问题 Here's an algorithm that is almost A* search. Essentially it's BFS with a priority queue that uses A* priority. frontier <- empty priority queue frontier.insert(start) with priority g(start)+h(start) while frontier isn't empty vertex <- dequeue frontier for each undiscovered neighbor of vertex neighbor.discovered = true neighbor.parent = vertex frontier.insert(neighbor) with priority g(neighbor)+h(neighbor) if neighbor == goal, stop This algorithm is missing the parts of A* that handle this

A* to recognize it's impossible to get to the goal

主宰稳场 提交于 2019-12-12 19:57:03
问题 I implemented A* for the 8 puzzle problem pretty much word for word to the pseudo code in the wiki article but even though I have closed I still get infinite runtime on boards that should fail. It seems that the rate of opening new nodes is larger than closing them, since for each node about 1-4 new nodes are added to the open but only one node is moved from open to closed . So what can be done to recognize that a given starting board has no path to the goal without waiting forever? This is

A-star algorithm

妖精的绣舞 提交于 2019-12-12 08:37:45
问题 I'm having issues with my A-star implemention. It does find path from my point A to B but not if the terrain is more 'complex', then my Find() function seems to not be ending. For instance, it does work on the 20 x 20 array here but if you add a square ('#') in the bottom to the most-right obstacle/wall then it fails. I hope someone can point out any mistakes I'm doing. Here's my code: #include <iostream> #include <string> #include <cmath> #include <vector> #include <utility> #include

A* Pathfinding in a hexagonal grid

試著忘記壹切 提交于 2019-12-12 08:21:36
问题 Can anyone point me to a simple example that implements A* path-finding algorithm on a hexagonal grid (in JS). I have made it working on a square grid, however all my attempts to make it work on a hexagonal grid have failed. This is how my grid looks like: I'm using the same technique to both draw the grid and generate coordinates as seen in this topic. Here's the grid coords data along with the start, end coords: [0, 0] , [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [1, 3], [2, 0], [2, 1], [2, 2]