Questions tagged [a-star]

A* is a graph shortest-path algorithm that uses a heuristic function to speed up the search

A* is a single source shortest path algorithm that use a heuristic function in order to speed up its search. The algorithm is similar to dijkstra's algorithm, but uses the heuristic evaluation of each node to determine which node should first be explored.

The A* algorithm is both complete [will always find a path if one exists] and optimal [finds the shortest path] if the heuristic function provided is admissible. If more than one path exists with the same "lowest" cost score, the algorithm will return the path first explored.

Usage example: Finding a path for an agent on a grid-like plane, from a single source to a target.

1187 questions
21
votes
3 answers

Finding good heuristic for A* search

I'm trying to find the optimal solution for a little puzzle game called Twiddle (an applet with the game can be found here). The game has a 3x3 matrix with the number from 1 to 9. The goal is to bring the numbers in the correct order using the…
Martin Thurau
  • 7,564
  • 7
  • 43
  • 80
21
votes
4 answers

A* Pathfinding in a hexagonal grid

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…
Alexus
  • 1,887
  • 1
  • 23
  • 50
20
votes
5 answers

Is A* really better than Dijkstra in real-world path finding?

I'm developing a path finding program. It is said theoretically that A* is better than Dijkstra. In fact, the latter is a special case of the former. However, when testing in the real world, I begin to doubt that is A* really better? I used data of…
HanXu
  • 5,507
  • 6
  • 52
  • 76
19
votes
2 answers

What's the difference between best-first search and A* search?

In my text book I noticed that both these algorithms work almost exactly the same, I am trying to understand what's the major difference between them. The textbook traversed this example using A* the same way it did with best-first search. Any help…
Computerphile
  • 391
  • 2
  • 3
  • 13
19
votes
1 answer

What is the point of IDA* vs A* algorithm

I don't understand how IDA* saves memory space. From how I understand IDA* is A* with iterative deepening. What's the difference between the amount of memory A* uses vs IDA*. Wouldn't the last iteration of IDA* behave exactly like A* and use the…
tcui222
  • 319
  • 2
  • 3
  • 10
19
votes
3 answers

Why is the complexity of A* exponential in memory?

Wikipedia says on A* complexity the following (link here): More problematic than its time complexity is A*’s memory usage. In the worst case, it must also remember an exponential number of nodes. I fail to see this is correct because: Say we…
Paul
  • 2,862
  • 3
  • 18
  • 18
19
votes
6 answers

What can be the efficient approach to solve the 8 puzzle problem?

The 8-puzzle is a square board with 9 positions, filled by 8 numbered tiles and one gap. At any point, a tile adjacent to the gap can be moved into the gap, creating a new gap position. In other words the gap can be swapped with an adjacent…
Ravindra S
  • 6,302
  • 12
  • 70
  • 108
18
votes
3 answers

Is A-star guaranteed to give the shortest path in a 2D grid

I am working with A-star algorithm, whereing I have a 2D grid and some obstacles. Now, I have only vertical and horizontal obstacles only, but they could vary densely. Now, the A-star works well (i.e. shortest path found for most cases), but if I…
Kraken
  • 23,393
  • 37
  • 102
  • 162
16
votes
9 answers

How do you solve the 15-puzzle with A-Star or Dijkstra's Algorithm?

I've read in one of my AI books that popular algorithms (A-Star, Dijkstra) for path-finding in simulation or games is also used to solve the well-known "15-puzzle". Can anyone give me some pointers on how I would reduce the 15-puzzle to a graph of…
Sean
15
votes
1 answer

How do I adapt AStar in Godot to platformers?

I've been looking for a robust method of pathfinding for a platformer based game I'm developing and A* looks like it's the best method available. I noticed there is a demo for the AStar implementation in Godot. However, it is written for a grid/tile…
Matthew
  • 768
  • 1
  • 11
  • 25
14
votes
2 answers

A* Search Algorithm

I would like to have something clarified with regards to the following A* Search example: The sections highlighted with the red ellipses are the areas that I do not understand; it appears that {S,B} f=2+6=8 has been taken/moved/copied from Expand S…
Mus
  • 7,290
  • 24
  • 86
  • 130
14
votes
4 answers

A* heuristic to create Bresenham lines

From what I understand about A* heuristics and how the Bresenham algorithm works, this may not be be possible since only the current state and goal state are passed to the heuristic function. But maybe someone has a clever solution to this…
peskal
  • 1,213
  • 1
  • 12
  • 28
14
votes
1 answer

Correct formulation of the A* algorithm

I'm looking at definitions of the A* path-finding algorithm, and it seems to be defined somewhat differently in different places. The difference is in the action performed when going through the successors of a node, and finding that a successor is…
Eli Bendersky
  • 263,248
  • 89
  • 350
  • 412
14
votes
6 answers

How to straighten unneeded turns in a A* graph search result?

I have been working on a JavaScript implementation of the early 90's adventure games and specifically plotting a path from the place the hero is standing to the location the player has clicked on. My approach is to first determine if a strait line…
Jason Sperske
  • 29,816
  • 8
  • 73
  • 124
14
votes
5 answers

Fastest cross-platform A* implementation?

With so many implementations available, what is the fastest executing (least CPU intensive, smallest binary), cross-platform (Linux, Mac, Windows, iPhone) A* implementation for C++ using a small grid? Implementations Google…
Dave Jarvis
  • 30,436
  • 41
  • 178
  • 315
1
2
3
78 79