Questions tagged [pathfinding]

Pathfinding or pathing is the plotting of the shortest route between two points. It is a more practical variant on solving mazes. This field of research is based heavily on Dijkstra's algorithm for finding the shortest path on a weighted graph.

Filter by
Sorted by
Tagged with
1 vote
2 answers
75 views

Finding the cheapest path between two points using Dijkstra

I am trying to use Dijkstra to find the cheapest path between two pixels in an image. Implementation: ...
2 votes
2 answers
130 views

Optimizing a recursive path finding algorithm

On input i get width and height of matrix, string of text and another string of finalText I want to reach. The characters of the first string are assigned to matrix. My goal is to find shortest way to ...
  • 21
5 votes
0 answers
76 views

Dijkstra's algorithm in Perl

I have this Perl module project. My implementation of the Dijkstra's algorithm follows: ...
  • 26.1k
3 votes
1 answer
172 views

The shortest path between airports

Airlines need to provide their customers with flights to every corner, so they need an app that allows them to do so. The customer must be able to transfer when there is no direct connection. The ...
3 votes
1 answer
92 views

Traditional vs. bidirectional Dijkstra's algorithm in C

I have this CLion project on GitHub. It constructs a directed, weighted graph consisting of 100 thousand nodes and 500 thousand directed arcs, picks two random nodes, and computes the shortest paths ...
  • 26.1k
2 votes
1 answer
59 views

Priority Queue for D* Lite

So, I needed a priority queue for D* lite and I wanted to know whether this is an acceptable implementation or not. ...
  • 57
4 votes
1 answer
336 views

Searching for a performance bug in a C++20 pathfinding algorithm (NBA*) - follow up

I have followed some advice in the previous iteration, yet even the current version is too slow compared to the Java implementation of the same algorithm. (C++ version with ...
  • 26.1k
4 votes
1 answer
125 views

Searching for a performance bug in a C++20 pathfinding algorithm (NBA*)

(See the next iteration.) I have this pathfinding algorithm: DirectedGraph.hpp ...
  • 26.1k
1 vote
1 answer
79 views

Pathfinders.hpp - Dijkstra's algorithm

I have this Visual Studio 2022 project, in which I compared the performance of 4 point-to-point shortest path algorithms. This one presents the Dijkstra's algorithm: ...
  • 26.1k
1 vote
0 answers
44 views

My code generates a path through a grid - How can I simplfy it in terms of list, dictionary's, stacks and queues?

This code works but is cluttered and I think could be improved in terms of how it is implemented. Basically my code works - what it does is from the start location, it chooses a random direction and ...
2 votes
2 answers
203 views

Graph Implementation with Dijkstra's Algorithm

Graph Interface: ...
  • 51
4 votes
3 answers
182 views

Improving generic A* algorithm performance

Here is my A* algorithm. I tried hard to implement it generically, but come up only with one idea to use lambdas for heuristic and next nodes (neighbours / successors) functions. I know that using ...
  • 51
2 votes
1 answer
107 views

Shortest route algo terribly slow

First post. I posted this on stack as well but somebody suggested I post it here too/instead. I wrote a shortest-path script for a Unity game project, and while it works, it gets so slow when applied ...
  • 21
4 votes
3 answers
587 views

Compute shortest path in undirected graph

In a recent coding interview I was asked to write a program which takes as input two text lines: The first one represents a graph, formatted as a sequence of undirected edges like ...
1 vote
1 answer
249 views

Google Foobar challenge optimization

I am trying to solve Google Foobar challenge prepare-the-bunnies-escape using my own approach, instead of BFS. I attempt to solve two ends of the maze and try to ...
2 votes
0 answers
52 views

AStar Implementation and Efficiency

This is my implementation of an AStar-like algorithm for maze solving. A quick summary of the problem I am trying to solve with my algorithm might be: A simple binary maze is given to you to solve, ...
2 votes
0 answers
45 views

Dijkstra from scratch

I implemented the Dijkstra algorithm from scrath and wonder if I can save some code? The whole algorithm is here. n is the number of nodes, and m the number of edges. 1 ≤ 𝑛 ≤ 10^4, 0 ≤ 𝑚 ≤ 10^5, 𝑢 ...
2 votes
1 answer
317 views

How can I speed up my IDA* algorithm for N-puzzle?

I'm trying to solve the N-Puzzle problem using IDA* algorithm with a Manhattan heuristic. I already implemented the algorithm from the pseudocode in this Wikipedia page (link). Here's my code so far : ...
  • 133
3 votes
1 answer
307 views

A* Pathfinding Algorithm

I have programmed a A* Pathfinding algorithm in the Console. I would now like to know if there are any things that I could do to improve the time it takes, to find a path. Right now it takes around ...
  • 31
8 votes
3 answers
1k views

A* (shortest path) with the ability to remove up to one wall

Problem You are given an HxW matrix. Each element is either 0 (passable space) or 1 (wall). Given that you can remove one wall, find the shortest path from [0,0] (start) to [width-1, height-1] (end). ...
  • 183
4 votes
1 answer
63 views

Navigating the robot by finding the shortest way

I have this task where I have to make my robot find the shortest way when I enter a destination point. I've created some functions to assign numbers (distances) for each square and counts its way back ...
  • 49
10 votes
2 answers
3k views

Implementation of Dijkstra's algorithm in Python

I have implemented Dijkstra's algorithm for my research on an Economic model, using Python. In my research I am investigating two functions and the differences ...
  • 103
6 votes
1 answer
845 views

Python: Astar algorithm implementation

I have implemented Astar algorithm for a problem on an online judge relating to maze given start and end positions along with a grid representing the maze. I output the length of the path along with ...
5 votes
1 answer
117 views

A* and ALT pathfinding in C tips

I adding some pathfinding to a game I'm working on. It primarily used A* with as suggested in the pathfinding articles at reb blob games. It works, but isn't very fast. It is a square grid map that (...
  • 161
6 votes
2 answers
299 views

C#: A* pathfinding - performance and simplicity

Yet another implementation of A* pathfinding. It is focused on: Performance (both speed and memory allocations). Readability and simplicity. Well defined objects and methods. Accordance with general ...
  • 380
4 votes
2 answers
129 views

Speed Up Flow Field Algorithm?

I am slowly creating a flow field pathfinding solution for Unity3D. I'm trying to follow Elijah Emerson's description, which appears in the book 'Game AI Pro' (volume 1). In this question I ask about ...
3 votes
1 answer
84 views

Coordinates Struct for Flow Field Pathfinding... am I doing this right?

I am slowly creating a flow field pathfinding solution for Unity3D. I'm trying to follow Elijah Emerson's description, which appears in the book 'Game AI Pro' (volume 1). The map is divided into ...
4 votes
2 answers
282 views

I wrote my first pathfinding algorithm

I'm currently writing a small game in Lua, using the Love2d framework. I guess I'm doing it as a practice of sorts, but it did give me the opportunity to write my first pathfinding algorithm. I wrote ...
  • 41
2 votes
1 answer
259 views

Sum of all Paths in Binary Tree

Problem For the given binary tree return the list which has sum of every paths in a tree. i.e Every path from root to leaf. I've written following solution. ...
1 vote
0 answers
224 views

Directed graph and Dijkstra algorithm using heap

I have implemented directed graph and Dijkstra algorithm using heap in Python. I first implemented an abstract base class WeightedGraph, of which ...
5 votes
2 answers
90 views

Performance Enhancement of A Star Path Finder algorithm with 1024 multidimentional array

I have the below code for a A* pathfinder, however it is taking upwards of 10 minutes to find a solution using a simple 1024 x 1024 array. I had to comment out ...
1 vote
0 answers
73 views

Python3 BFS Flood Fill with Deque and 2D Indexing

I'm currently in a programming competition where time is key, therefore I'm trying to optimize my solution as much as possible. I am trying to implement a BFS Flood Fill solution on a map size of ...
  • 111
3 votes
2 answers
131 views

Bellman Ford algorithm using vector

I have written this code for bellman-ford algorithm. Please review and suggest improvements: This code takes input graph as an adjacency matrix, and stores it the ...
  • 354
4 votes
1 answer
114 views

A* pathfinding for integer Vectors

This class is for calculating the shortest path in a 2D World (without minding obstacles). I'm using the A* algorithm and 2D Vectors (from the SFML Framework). It is working but takes (a lot of) time ...
  • 61
4 votes
1 answer
48 views

Advice on path-finding visualisation program

Im looking for some help on improving my code which visualizes path-finding algorithms. The code is working however I know it can be improved. Any suggestions would be appreciated. Github code - ...
4 votes
2 answers
639 views

Dijkstra Algorithm implementation in C++

I have implemented Dijkstra's algorithm in C++, but it seems a bit complicated since I really tried to follow the process of the algorithm as much as I could. If there's any simplification you would ...
11 votes
2 answers
676 views

Path finding solution for a maze whose state changes during the solve

This is not a traditional maze where you find the shortest path (like the gif on the left). In order to solve it, you need to visit every available node before reaching the end, where once a node is ...
  • 119
2 votes
2 answers
111 views

A-Star for 2D Graph (not grid)

This is my A-Star implementation for a 2D space of nodes but allowing to specifically set connections between nodes because my usecase does not have points tied to a grid (however for clarification ...
3 votes
1 answer
219 views

A Brushfire algorithm to generate a distance map in a grid

I'm working on implementing a goal-based pathfinding. first step is to set a goal and calculate the shortest walkable distance between the goal and all points in the grid, using a brushfire algorithm. ...
7 votes
2 answers
2k views

Find the closest enemy in a 2D grid with wrapping allowed

I'd like feedback on my solution to the outlined programming challenge. Is numpy a good candidate module for this? What might be a more efficient or Pythonic solution? Closest Enemy II Have ...
  • 733
5 votes
1 answer
1k views

Speeding up Dijkstra's algorithm

I have Dijkstra's algorithm: ...
  • 153
7 votes
2 answers
4k views

Find the correct path through a 5 x 5 grid (coderbyte 'Correct path')

I've completed the following coderbyte question and would like feedback as to whether it follows Python best practices, is efficient and so forth. The coderbyte problem: Have the function ...
  • 733
2 votes
0 answers
97 views

Codewars: Remote Control Virtual Keyboard

This is my solution to the Codewars problem TV Remote (symbols). Description In short, you are given a virtual keyboard with 3 modes between which can be switched by pressing the ...
2 votes
1 answer
650 views

ROS implementation of Dijkstra's algorithm to shortest path

I am making a ros node to implement dijkstra's algorithm on a 1000x1000 pixel map. I have used map_server to convert the map into an nav_msgs/OccupancyGrid. The map is in the form of a row dominant ...
8 votes
2 answers
6k views

Implementation of A* algorithm in C++

I have implemented the A-Star path finding algorithm for a 2D grid. The function returns a list of positions of an acceptable path. main.cpp : ...
2 votes
0 answers
36 views

Fast algorithms in Javascript for shortest path queries in directed unweighted graphs - follow-up

(See the previous iteration.) Now I have reworked my pathfinder program, and I ended up with this: ...
  • 26.1k
3 votes
0 answers
84 views

Fast algorithms in Javascript for shortest path queries in directed unweighted graphs

(There is a follow-up question available to this: Follow-Up Question) So I have this: ...
  • 26.1k
7 votes
1 answer
242 views

Random Maze Pathfinder

I just finished a huge project of mine; a maze pathfinder. At the start, the maze that the program is traversing is randomly generated, with a 25% change to place a wall (...
  • 9,652
4 votes
1 answer
311 views

Maze algorithm to find path between points

I am creating an algorithm to find the shortest path between two points in a maze but my current solution is too slow. This is what I did: Helper classes: ...
  • 143
5 votes
1 answer
593 views

Shortest pathway across a snakes and ladders board (Update)

Earlier I posted a fairly inefficient recursive solution to the problem of getting across a snakes and ladders board in the smallest number of moves. I have created a much faster solution to this ...
  • 2,033

1
2 3 4 5