Pathfinder Performance Test

pathfinder performance test - corner to corner

This post will compare the performance of the four pathfinding algorithms we coded in previous tutorials. We will look at each algorithm and find out which one is the fastest, which one generates the best path and which one explores the least nodes.

Algorithms

We first coded depth first search and watched it explore a node graph.

depth first search exploring a node graph searching for a goal point
Depth first search exploring a node graph searching for a goal point

Then we coded breadth first search, and watched it explore a rectangular grid.

breadth first search exploring a grid searching for a goal point
Breadth first search exploring a grid searching for a goal point

Next we coded greedy best first search, and watched it explore a hexagonal grid.

finding a path with greedy best first search
Finding a path with greedy best first search

Finally we coded at a-star search, and watched it explore a triangular grid.

a-star pathfinding exploring a grid of triangles
A-star pathfinding exploring a grid of triangles

Hexagon Grid

The test will be carried out on a large hexagon grid made up of 8,064 hexagon cells, some of which are walls. Only the cells which aren’t walls are connected as a node graph. The grid is made up of 48 columns by 168 rows.

pathfinder race - large hexagon grid
Large hexagon grid

Here is what the node graph looks like.

pathfinder race - large hexagon grid node graph
Node graph

Corner to Corner

The four pathfinding algorithms start in the top left corner, and seek the goal in the bottom right corner.

The chosen path each algorithm took. A-star (yellow) and breadth first search (green) take a path of the same length, but pick slightly different nodes. Greedy best first search (red) and depth first search (blue) picked routes which are far from perfect.

pathfinder race hexagon grid - all algorithms - chosen path only
All algorithms – chosen path only

The nodes explored by breadth first search. This is almost the worst case scenario, since it explored almost every node except one (the one in blue).

pathfinder race hexagon grid - breadth first search - explored nodes and chosen path
Breadth first search – explored nodes and chosen path

The nodes explored by a-star. Not as many as breadth first search, but still a large amount.

pathfinder race hexagon grid - a-star search - explored nodes and chosen path
A-star search – explored nodes and chosen path

The nodes explored by both depth first search (in blue) and greedy best first search (in red). Both algorithms explored far less nodes than a-star and breadth first search.

pathfinder race hexagon grid - depth first search and greedy best first search - explored nodes and chosen path
Depth first search and greedy best first search – explored nodes and chosen path

The data from the test.

  • Algorithm – The pathfinding algorithm.
  • Time (ms) – The time taken by each algorithm to calculate a path from the start point to the goal point in milliseconds.
  • Path Length – The length of the chosen path from the start point to the goal point.
  • Explored Nodes – The nodes explored by each algorithm.
AlgorithmTime (ms)Path LengthExplored Nodes
A Star Search9.16091553623
Breadth First Search1.62721554875
Depth First Search0.5373325362
Greedy Best First Search0.57082531051

A chart showing the execution time of each pathfinding algorithm. As you can see, a-star is by far the slowest.

pathfinder hexagon grid - execution time
Execution time

A chart showing the path length of each pathfinding algorithm. A-star and breadth first search both pick the shortest path in terms of the number of nodes. However they both pick slightly different paths. Depth first search picks the worst path.

pathfinder hexagon grid - path length
Path length

A chart showing the explored nodes of each pathfinding algorithm. Depth first search explores the least nodes. Breadth first search explores the most nodes.

pathfinder hexagon grid - explored nodes
Explored nodes

Corner to Middle

Next we will reuse the same hexagonal grid, and set the goal point to the middle of the grid.

The chosen path each algorithm took. A-star (yellow) and breadth first search (green) take a path of the same length, but pick slightly different nodes. Greedy best first search (red) picked a fairly good route, but depth first search (blue) picked a crazy long route!

pathfinder race hexagon grid - corner to middle - all algorithms - chosen path only
All algorithms – chosen path only

The nodes explored by breadth first search. It explores a lot of nodes, before it finds the goal.

pathfinder race hexagon grid - corner to middle - breadth first search - explored nodes and chosen path
Breadth first search – explored nodes and chosen path

The nodes explored by a-star. It explores less nodes than breadth first search.

pathfinder race hexagon grid - corner to middle - a-star search - explored nodes and chosen path
A-star search – explored nodes and chosen path

The nodes explored by depth first search. It explores a crazy number of nodes this time.

pathfinder race hexagon grid - corner to middle - depth first search - explored nodes and chosen path
Depth first search – explored nodes and chosen path

The nodes explored by greedy best first search. It explores a lot less nodes than the other algorithms.

pathfinder race hexagon grid - corner to middle - greedy best first search - explored nodes and chosen path
Greedy best first search – explored nodes and chosen path

The data from the test.

  • Algorithm – The pathfinding algorithm.
  • Time (ms) – The time taken by each algorithm to calculate a path from the start point to the goal point in milliseconds.
  • Path Length – The length of the chosen path from the start point to the goal point.
  • Explored Nodes – The nodes explored by each algorithm.
AlgorithmTime (ms)Path LengthExplored Nodes
A Star Search2.609476662
Breadth First Search0.9098761749
Depth First Search1.780916572294
Greedy Best First Search0.1797213

A chart showing the execution time of each pathfinding algorithm. As you can see, a-star is the slowest.

pathfinder hexagon grid - corner to middle - execution time
Execution time

A chart showing the path length of each pathfinding algorithm. A-star and breadth first search both pick the shortest path in terms of the number of nodes. However they both pick slightly different paths. Depth first search picks the worst path.

pathfinder hexagon grid - corner to middle - path length
Path length

A chart showing the explored nodes of each pathfinding algorithm. Depth first search explores the most nodes this time. Greedy best first search explores the least nodes.

pathfinder hexagon grid - corner to middle - explored nodes
Explored nodes

Top Edge

Next we will reuse the same hexagonal grid, and set the goal point to the top right of the grid.

The chosen path each algorithm took. A-star (yellow), breadth first search (green) and greedy best first search (red) picked similar routes. Depth first search (blue) picked a crazy long route!

pathfinder race hexagon grid - top edge - all algorithms - chosen path only
All algorithms – chosen path only

The nodes explored by breadth first search. It explores a lot of nodes, before it finds the goal.

pathfinder race hexagon grid - top edge - breadth first search explored nodes
Breadth first search – explored nodes and chosen path

The nodes explored by a-star. It explores less nodes than breadth first search.

pathfinder race hexagon grid - top edge - a star explored nodes
A-star search – explored nodes and chosen path

The nodes explored by depth first search. It explores a crazy number of nodes.

pathfinder race hexagon grid - top edge - depth first search explored nodes
Depth first search – explored nodes and chosen path

The nodes explored by greedy best first search. It explores a lot less nodes than the other algorithms.

pathfinder race hexagon grid - top edge - greedy best first search explored nodes
Greedy best first search – explored nodes and chosen path

The data from the test.

  • Algorithm – The pathfinding algorithm.
  • Time (ms) – The time taken by each algorithm to calculate a path from the start point to the goal point in milliseconds.
  • Path Length – The length of the chosen path from the start point to the goal point.
  • Explored Nodes – The nodes explored by each algorithm.
AlgorithmTime (ms)Path LengthExplored Nodes
A Star Search4.53611141011
Breadth First Search1.47031144068
Depth First Search1.976219172619
Greedy Best First Search0.1561122172

A chart showing the execution time of each pathfinding algorithm. As you can see, a-star is the slowest.

pathfinder hexagon grid - execution time - top edge
Execution Time

A chart showing the path length of each pathfinding algorithm. A-star and breadth first search both pick the shortest path in terms of the number of nodes. However they both pick slightly different paths. Depth first search picks the worst path.

pathfinder hexagon grid - path length - top edge
Path Length

A chart showing the explored nodes of each pathfinding algorithm. Breadth first search explores the most nodes. Greedy best first search explores the least nodes.

pathfinder hexagon grid - explored nodes - top edge
Explored Nodes

Left Edge

Next we will reuse the same hexagonal grid, and set the goal point to the bottom left of the grid.

The chosen path each algorithm took. A-star (yellow), breadth first search (green), greedy best first search (red) and depth first search (blue).

pathfinder race hexagon grid - left edge - all algorithms - chosen path only
All algorithms – chosen path only

The nodes explored by breadth first search.

pathfinder race hexagon grid - left edge - breadth first search explored nodes
Breadth first search – explored nodes and chosen path

The nodes explored by a-star.

pathfinder race hexagon grid - left edge - a star explored nodes
A-star search – explored nodes and chosen path

The nodes explored by depth first search.

pathfinder race hexagon grid - left edge - depth first search - explored nodes
Depth first search – explored nodes and chosen path

The nodes explored by greedy best first search.

pathfinder race hexagon grid - left edge - greedy best first search - explored nodes
Greedy best first search – explored nodes and chosen path

The data from the test.

  • Algorithm – The pathfinding algorithm.
  • Time (ms) – The time taken by each algorithm to calculate a path from the start point to the goal point in milliseconds.
  • Path Length – The length of the chosen path from the start point to the goal point.
  • Explored Nodes – The nodes explored by each algorithm.
AlgorithmTime (ms)Path LengthExplored Nodes
A Star Search3.5537103908
Breadth First Search1.32731033431
Depth First Search2.76541584527
Greedy Best First Search0.1455121157

A chart showing the execution time of each pathfinding algorithm. As you can see, a-star is the slowest.

pathfinder hexagon grid - execution time - left edge
Execution Time

A chart showing the path length of each pathfinding algorithm. A-star and breadth first search both pick the shortest path in terms of the number of nodes. However they both pick slightly different paths. Depth first search picks the worst path.

pathfinder hexagon grid - path length - left edge
Path Length

A chart showing the explored nodes of each pathfinding algorithm. Depth first search explores the most nodes. Greedy best first search explores the least nodes.

pathfinder hexagon grid - explored nodes - left edge
Explored Nodes

No Walls

Next we will reuse the same hexagonal grid, and set the goal point to the bottom right corner of the grid. Except this time, the map will contain no walls!

The chosen path each algorithm took. A-star (yellow), breadth first search (green), greedy best first search (red) and depth first search (blue).

pathfinder race hexagon grid - no walls - all algorithms - chosen path only
All algorithms – chosen path only

The nodes explored by breadth first search. As you can see, it explores almost every node.

pathfinder race hexagon grid - no walls - breadth first search - explored nodes
Breadth first search – explored nodes and chosen path

The nodes explored by a-star. It explores quite a lot of nodes, but a lot less than breadth first search.

pathfinder race hexagon grid - no walls - a star - explored nodes
A-star search – explored nodes and chosen path

The nodes explored by depth first search. Depth first search gets lucky in this scenario and simply follows the edges of the map until it finds the goal.

pathfinder race hexagon grid - no walls - depth first search - explored nodes
Breadth first search – explored nodes and chosen path

The nodes explored by greedy best first search. It heads quickly to the goal point, as expected.

pathfinder race hexagon grid - no walls - greedy best first search - explored nodes
Greedy best first search – explored nodes and chosen path

The data from the test.

  • Algorithm – The pathfinding algorithm.
  • Time (ms) – The time taken by each algorithm to calculate a path from the start point to the goal point in milliseconds.
  • Path Length – The length of the chosen path from the start point to the goal point.
  • Explored Nodes – The nodes explored by each algorithm.
AlgorithmTime (ms)Path LengthExplored Nodes
A Star Search13.78261314345
Breadth First Search3.07831318061
Depth First Search0.4169177177
Greedy Best First Search0.1383131131

A chart showing the execution time of each pathfinding algorithm. As you can see, a-star is the slowest by a considerable margin. Probably because it is overwhelmed by adjacent nodes, looking for a shortest path, when there are actually many possibilities.

pathfinder hexagon grid - execution time - no walls
Execution Time

A chart showing the path length of each pathfinding algorithm. A-star, breadth first search and greedy best first search all pick the shortest path in terms of the number of nodes. However they all pick very different paths. Depth first search picks the worst path, as usual.

pathfinder hexagon grid - path length - no walls
Path Length

A chart showing the explored nodes of each pathfinding algorithm. Breadth first search explores almost all the nodes. Depth first search and greedy best first search explore the least nodes, and there path length is equal to the number of nodes they explore.

pathfinder hexagon grid - explored nodes - no walls
Explored Nodes

Conclusion

The worst algorithm by far is depth first search. The path it generates is to random to be useful for pathfinding from a start point to a goal point.

Greedy best first search is super quick, and usually explores a smaller number of nodes. However it’s path usually isn’t perfect, but it could be considered ‘good enough’, if speed is all you care about.

Breadth first search and A-Star search both calculate the shortest path, sometimes with slight differences in adjacent nodes. They can’t usually compete with greedy best first search in terms of execution time and the number of nodes explored. But they do generate the perfect path every time, which is what we want at the end of the day.

Breadth first search explores more nodes than A-Star search, however it’s execution time is usually a lot faster (as proven in the two examples above).

The reason it works better than A-Star in this case, is because we are using an unweighted graph. If we had to consider movement costs for a weighted graph, then A-Star should perform better. For example we could have mountain or swamp tiles which cost more time to cross.

The A-Star algorithm is also more complex. It needs to keep a container sorted, in this case we use a priority queue. It also needs to make sure there are no duplicates in the frontier. Although breadth first search handles duplicates in a different way, since it only explores each node once. Whilst A-Star can explore the same node multiple times.

Breadth first search could be slower in a very large map, where the goal is very far away. Greedy best first search would likely suffer more on a larger more complex map.

Overall breadth first search is the best pathfinding algorithm for unweighted graphs. It generates the best and shortest path in a good execution time.

Optimising A-Star

The current version of A-Star is based on the pseudocode from Wikipedia. We can clearly see that it works, since it always finds the shortest path. However it is not the fastest.

You can see the code for the full a-star search algorithm here.

Here are two optimisations which can greatly speed it up.

  1. Remove the duplicate check – allow duplicates in the frontier.
  2. Adjust the heuristic to prioritise the goal point.

So first off, we will remove the code which stops duplicates from being added to the frontier:

boolean duplicate = false;
for(Node f : frontier)
{
  if(f == node)
  {
    duplicate = true;
    break;
  }
}
if(!duplicate)
{
  frontier.add(node);
}

And replace it with this code, which will simply add the node to the frontier.

frontier.add(node);

Next we will create a multiplier variable at the start of the a-star function.

final float multiplier = 1.4;

We will use it when setting the goal score for the start node.

start.goalScore = Distance(start.position, goal.position) * multiplier;

And then later on, when we loop over the adjacent nodes.

node.goalScore = tentativeScore + Distance(node.position, goal.position) * multiplier;

So if we run this new code when the start point is the top left corner, and the goal point is the bottom right corner. Then we will get this:

The chosen path each algorithm took. A-star (yellow) and breadth first search (green) take a path of the same length, but pick different nodes. Greedy best first search (red) and depth first search (blue) picked routes which are far from perfect.

pathfinder race hexagon grid - a-star optimised - corner to corner - all algorithms - chosen path only
All algorithms – chosen path only

The only difference I can see is that a-star takes a slightly different path in the bottom right corner to get to the goal. Notice how it diverges from breadth first searches path just before the goal point.

However the path length of both a-star and breadth first search is still the same.

The data from the test.

  • Algorithm – The pathfinding algorithm.
  • Time (ms) – The time taken by each algorithm to calculate a path from the start point to the goal point in milliseconds.
  • Path Length – The length of the chosen path from the start point to the goal point.
  • Explored Nodes – The nodes explored by each algorithm.
AlgorithmTime (ms)Path LengthExplored Nodes
A-Star9.16091553623
Optimised A-Star4.61021552639
Breadth First Search1.62721554875

So as we can see, the optimised a-star is almost two times faster than the original a-star. The path length is also the same. The optimised a-star also explores less nodes.

However you need to be careful with the value you pick for the multiplier. The larger the multiplier, the less accurate the algorithm will become. We used 1.4 above, and that worked great. However if we use a multiplier of 2.0. Then we will get an a-star path which is longer and less accurate.

pathfinder race hexagon grid - a-star optimised - corner to corner - all algorithms - chosen path only - multiplier of 2
All algorithms – chosen path only

As you can see, the execution time is no quicker, the path length is now longer, but the number of explored nodes is a lot less.

AlgorithmTime (ms)Path LengthExplored Nodes
Optimised A-Star4.64011641526

If you choose to use the multiplier, then it is likely you will need to adjust it for different maps.

Removing the duplicate check, so that duplicates are allowed into the frontier seems to have worked great for performance. However, I cannot guarantee that this won’t have side effects in certain scenarios.

So whichever algorithm you choose to use, make sure you thoroughly test it.

Full code for the optimised version of A-Star.

boolean AStarSearchFast(Node start, Node goal, ArrayList<Node> path, ArrayList<Node> exploredNodes, final float multiplier)
{
  path.clear();
  exploredNodes.clear();
  int moves = 0;
  
  start.startScore = 0.0f;
  start.goalScore = Distance(start.position, goal.position) * multiplier;
  
  PriorityQueue<Node> frontier = new PriorityQueue<Node>(10, new NodeGoalScoreComparator());
  frontier.add(start);
  Node current = null;
  float tentativeScore = 0;
  while(!frontier.isEmpty())
  {
    ++moves;
    current = frontier.poll();
    exploredNodes.add(current);
    
    if(current == goal)
    {
      println("Goal has been found in " + moves + " moves");
      while(current != null)
      {
        path.add(current);
        current = current.parent;
      }
      Collections.reverse(path);
      return true;
    }
    
    for(Node node : current.adjacentNodes)
    {
      tentativeScore = current.startScore + Distance(current.position, node.position);
      if (tentativeScore < node.startScore)
      {
        // This path to neighbour is better than any previous one. Record it!
        node.parent = current;
        
        node.startScore = tentativeScore;
        node.goalScore = tentativeScore + Distance(node.position, goal.position) * multiplier;
        
        frontier.add(node);
      }
    }
  }
  
  println("Failed to find the goal in", moves, "moves");
  return false;
}

Improved Testing

Running the tests in the Processing ‘setup’ function has caused some slowdowns. It turns out the algorithms are a lot faster when ran later, when the code has been warmed up.

To improve the tests I am now running each algorithm 100 times, then taking the average like so:

  time = 0;
  for(int i=0; i<total; ++i)
  {
    ResetAllNodes();
    timer.Start();
    AStarSearch(startNode, goalNode, aStarPathRenderer.pathList, aStarPathRenderer.exploredNodes);
    time += timer.GetMillis();
  }
  println(aStarPathRenderer.name, time / (double)total, aStarPathRenderer.pathList.size(), aStarPathRenderer.exploredNodes.size());

However, the tests are also slow when ran for the first time, so I ran all the tests 10 times by pressing a button. Every button press executes a new test. Then I use the data from the last test. So this means that each algorithm is ran 1000 times.

  if(key == 'r' || key == 'R')
  {
    RunPathfinderTest();
  }

So if the corner to corner map is used again, but with the fast A-Star added, then the paths look like this:

The chosen path each algorithm took. A-Star (yellow), fast A-Star (Cyan), breadth first search (green), greedy best first search (red) and depth first search (blue).

pathfinder race hexagon grid - a-star optimised - corner to corner - all algorithms - chosen path only
All algorithms – chosen path only

Here is the data from the first test.

AlgorithmTime (ms)Path LengthExplored Nodes
A-Star1.6752049809694291553623
Fast A-Star0.51410603076219561552639
Breadth First Search0.36978788077831271554875
Depth First Search0.13196402050554754325362
Greedy Best First Search0.203371989279985432531051

And the data from the tenth test:

AlgorithmTime (ms)Path LengthExplored Nodes
A-Star0.6569890731573111553623
Fast A-Star0.2622969308495521552639
Breadth First Search0.1513410292565821554875
Depth First Search0.0153920302167535325362
Greedy Best First Search0.09806406944990162531051

Notice how the algorithms are much slower on the first test, even though this is ran outside of the Processing ‘setup’ function at a time of my choosing when I press a button. Also tests two to nine are similar to ten, and not to one. The first test is very much an anomaly.

However when the original A-Star algorithm was ran in the setup function, it took ‘9.1609’ milliseconds. Which is a massive difference.

I currently do not know why the A-Star algorithm takes ‘1.675204980969429’ milliseconds in the first test, and only ‘0.656989073157311’ milliseconds in the tenth test.

I would guess it could have something to do with one or all of the following:

  • Processing is doing something in the background
  • Caching
  • Automatic garbage collection

In relation to caching, the majority of the variables and containers are created and destroyed within each algorithms function. The nodes are reset before each test. The path list and explored nodes list have there capacities set to the number of nodes in the grid.

Here are the charts with the new data.

pathfinder hexagon grid - execution time - a-star optimised - corner to corner
Execution time
pathfinder hexagon grid - path length - a-star optimised - corner to corner
Path Length
pathfinder hexagon grid - explored nodes - a-star optimised - corner to corner
Explored Nodes

So no new changes overall despite the speed increase. The breadth first search algorithm is still outperforming both a-star algorithms.

Now lets take a look at the same map, but without the walls.

pathfinder race hexagon grid - a-star optimised - no walls - corner to corner - all algorithms - chosen path only
All algorithms – chosen path only
AlgorithmTime (ms)Path LengthExplored Nodes
A-Star1.005768063068391314345
Fast A-Star0.01687483988702131131
Breadth First Search0.1780060184001921318061
Depth First Search0.0216510004643351177177
Greedy Best First Search0.017456190418452131131
pathfinder hexagon grid - execution time - a-star optimised - corner to corner - no walls
Execution Time
pathfinder hexagon grid - path length - a-star optimised - corner to corner - no walls
Path Length
pathfinder hexagon grid - explored nodes - a-star optimised - corner to corner - no walls
Explored Nodes

So at last we have a case where the optimised version of A-Star beats breadth first search. This is down to A-Star following the path of greedy best first search. Notice how the number of explored nodes are the same as the path length. This is why the multiplier is important. However, this was not the case when we had a map with walls.

Small Map

Next we will look at a map which is half the size of the one we used previously.

pathfinder race hexagon grid - small map - a-star optimised - corner to corner - all algorithms - chosen path only
All algorithms – chosen path only
AlgorithmTime (ms)Path LengthExplored Nodes
A-Star0.12842795044183775920
Fast A-Star0.026183939930051675376
Breadth First Search0.0246970299445093751196
Depth First Search0.00530396993272007148162
Greedy Best First Search0.006569009982049477992
pathfinder hexagon grid - execution time - small map - a-star optimised - corner to corner
Execution Time
pathfinder hexagon grid - path length - small map - a-star optimised - corner to corner
Path Length
pathfinder hexagon grid - explored nodes - small map - a-star optimised - corner to corner
Explored Nodes

Looks like breadth first search is faster than A-Star, but only by a sliver.

Now we will look at the same map but without the walls.

pathfinder race hexagon grid - small map - a-star optimised - corner to corner - all algorithms - chosen path only - no walls
All algorithms – chosen path only
AlgorithmTime (ms)Path LengthExplored Nodes
A-Star0.175745959877968651081
Fast A-Star0.007195000066421936565
Breadth First Search0.0379140102863312652013
Depth First Search0.003773910014424478787
Greedy Best First Search0.006822999953292316565
pathfinder hexagon grid - execution time - small map - a-star optimised - corner to corner - no walls
Execution Time
pathfinder hexagon grid - path length - small map - a-star optimised - corner to corner - no walls
Path Length
pathfinder hexagon grid - explored nodes - small map - a-star optimised - corner to corner - no walls
Explored Nodes

The optimised version of A-Star is faster than breadth first search.

Very Small Map

Next we will look at one more map, which is half the size of the small map.

pathfinder race hexagon grid - very small map - a-star optimised - corner to corner - chosen path
All algorithms – chosen path only
AlgorithmTime (ms)Path LengthExplored Nodes
A-Star0.013575010122731357257
Fast A-Star0.012107009924948257274
Breadth First Search0.0051140000671148357274
Depth First Search0.00408098998013884106118
Greedy Best First Search0.0051700000511482461104
pathfinder hexagon grid - execution time - very small map - a-star optimised - corner to corner
Execution Time
pathfinder hexagon grid - path length - very small map - a-star optimised - corner to corner
Path Length
pathfinder hexagon grid - explored nodes - very small map - a-star optimised - corner to corner
Explored Nodes

Interestingly the optimised version of A-Star is a lot slower than breadth first search this time. I would guess the wall placement has had a significant effect.

Now lets look at the same map, but without the walls.

pathfinder race hexagon grid - very small map - a-star optimised - corner to corner - all algorithms - chosen path only - no walls
All algorithms – chosen path only
AlgorithmTime (ms)Path LengthExplored Nodes
A-Star0.023015030138194632255
Fast A-Star0.004446029961109163232
Breadth First Search0.011036990052089132501
Depth First Search0.002088009986327964242
Greedy Best First Search0.002787049978505823232
pathfinder hexagon grid - execution time - very small map - a-star optimised - corner to corner - no walls
Execution Time
pathfinder hexagon grid - path length - very small map - a-star optimised - corner to corner - no walls
Path Length
pathfinder hexagon grid - explored nodes - very small map - a-star optimised - corner to corner - no walls
Explored Nodes

Again we have another case where the optimised A-Star algorithm is faster than breadth first search. But of course on an open map without walls, we don’t even need pathfinding algorithms.

Conclusion Two

Overall it seems like breadth first search is still the best choice overall for an unweighted graph, since it is consistent. If you want to use A-Star, then you will need to play with the multiplier to balance speed with the shortest path.

Leave a comment