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.

1078 questions
157
votes
11 answers

How does Dijkstra's Algorithm and A-Star compare?

I was looking at what the guys in the Mario AI Competition have been doing and some of them have built some pretty neat Mario bots utilizing the A* (A-Star) Pathing Algorithm. (Video of Mario A* Bot In Action) My question is, how does A-Star…
KingNestor
  • 59,315
  • 50
  • 115
  • 149
105
votes
6 answers

What is the difference between graph search and tree search?

What is the difference between graph search and tree search versions regarding DFS, A* searches in artificial intelligence?
Rayhanur Rahman
  • 1,051
  • 2
  • 8
  • 4
70
votes
9 answers

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

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…
40
votes
5 answers

A* Admissible Heuristic for die rolling on grid

I need some help finding a good heuristic for the following problem: You are given an R-by-C grid and a six-sided die. Let start and end be two distinct cells on this grid. Find a path from start to end such that the sum of the faces of the…
Paul Manta
  • 27,853
  • 27
  • 109
  • 192
38
votes
4 answers

Is A* the best pathfinding algorithm?

It is generally said that A* is the best algorithm to solve pathfinding problems. Is there any situation when A* is not the best algorithm to find solution? How good is A* compared to BFS, DFS, UCS, etc?
Zombie
  • 473
  • 1
  • 8
  • 11
37
votes
2 answers

How to implement an A* algorithm?

Which should be the way to get a simple implementation of A* (A star) algorithm in C#?
A New Chicken
  • 653
  • 1
  • 7
  • 18
37
votes
3 answers

Consistent and Admissible Heuristics

Any consistent heuristic is also admissible. But when is a heuristic admissible but not consistent (monotone)? Please provide an example in which this is the case.
RoarG
  • 683
  • 1
  • 6
  • 20
34
votes
3 answers

Python - Speed up an A Star Pathfinding Algorithm

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…
DizzyDoo
  • 1,359
  • 5
  • 16
  • 29
33
votes
10 answers

How to optimally solve the flood fill puzzle?

I like playing the puzzle game Flood-It, which can be played online at: https://www.lemoda.net/javascript/flood-it/game.html It's also available as an iGoogle gadget. The aim is to fill the whole board with the least number of successive…
felix
  • 617
  • 1
  • 6
  • 10
29
votes
11 answers

How do I implement an A* pathfinding algorithm, with movement costs for every programming language?

Can we get people to post code of simple, optimized implementations of the A* pathfinding algorithm, in every single language? This is mostly for fun and to play with what stackoverflow itself is capable of... although I actually am interested in…
IQpierce
  • 399
  • 2
  • 7
  • 17
22
votes
6 answers

A* heuristic, overestimation/underestimation?

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…
Mads Andersen
  • 3,023
  • 4
  • 34
  • 42
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,312
  • 7
  • 39
  • 76
21
votes
6 answers

Using A* to solve Travelling Salesman

I've been tasked to write an implementation of the A* algorithm (heuristics provided) that will solve the travelling salesman problem. I understand the algorithm, it's simple enough, but I just can't see the code that implements it. I mean, I get…
Puppy
  • 138,897
  • 33
  • 232
  • 446
21
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,187
  • 5
  • 45
  • 72
21
votes
2 answers

A* admissible heuristics on a grid with teleporters?

Suppose that you have a 2D grid of cells, some of which are filled in with walls. Characters can take a step from one square to any square that is one step horizontal or vertical from it, but cannot cross walls. Given a start position and an end…
templatetypedef
  • 328,018
  • 92
  • 813
  • 992
1
2 3
71 72