Closed rllyryan closed 2 years ago
It's implemented this way to support both this specific case (only 0 and 255) and the general case (arbitrary weights). If you look at the maze_solver.py
example, you'll see some example code to transform a binary image to the appropriate weight matrix:
grid = maze.astype(np.float32)
grid[grid == 0] = np.inf
grid[grid == 255] = 1
Note that the minimum cost of any move must be at least 1 to ensure the heuristic remains admissible.
It's implemented this way to support both this specific case (only 0 and 255) and the general case (arbitrary weights). If you look at the
maze_solver.py
example, you'll see some example code to transform a binary image to the appropriate weight matrix:grid = maze.astype(np.float32) grid[grid == 0] = np.inf grid[grid == 255] = 1
From here:
Note that the minimum cost of any move must be at least 1 to ensure the heuristic remains admissible.
Thank you so much for your detailed reply! It makes sense to me!
Also, I did not know that numpy has an infinity attribute, that's is very useful!
Dear @hjweide
This is amazing work, I have been looking for a C++ A* implementation that is callable from Python. However, it seems that the code is reliant on the manual creation of a weights matrix for it to work.
Can I ask how would you utilise your package to traverse through an image of a 2D binarised map (consists of 0's and 255's only)?
Thank you so much!
Ryan