An implementation of the A* search algorithm taking data directly from NASA's satellite images of Mars. The generated path has been designed to return to favor the ‘smoothest’ ride possible, meaning it punishes rapid changes in altitude.
I've wanted to explore pathfinding for some time and really grasp the 'magic' behind these algorithms. This was a great opportunity to take some brand new cartographic information while also indulging my inner astronomist.
Deployed - v1.0.1
- React
- Redux
- Node.js
- Express.js
- P5.js
The heart of Phobosy is how it calculates a traversable graph from an image. The way this happens is that the image is converted to greyscale, then the heuristic function for A* is then updated to read the absolute difference in contrast between two points in the graph.
if (this.grayscaleWeights) {
if (fromNeighbor && fromNeighbor.x != this.x && fromNeighbor.y != this.y) {
return Math.abs(this.weight - fromNeighbor.weight) * 1.41421
} else {
return Math.abs(this.weight - fromNeighbor.weight)
}
}
Thus, favoring level ground and avoiding areas of high contrast. The darker the pixel value, the lower it assumes the terrain is - the brighter the higher:
Simply clone this repo down to your machine. Then:
npm i
Once completed:
npm run start-dev
Simply click between two points on the map and watch the path load! You can clear the paths by clicking 'Clear coordinates' in the top-right corner.
MIT © Sam Peach