PathFinder
An optimized C# HPA* Pathfinder
Install / Use
/learn @Aptacode/PathFinderREADME
PathFinder is an optimized C# implementation of the A* Search Algorithm. In its current form it can be utilised to quickly find the shortest path between two points on a uniform grid with potential obstacles between the start and end point.
Overview
The main PathFinder class consists of a Map and INeighbourFinder. The Map is the class that contains all the information about the grid in which a path is to be found:
var map = new Map(new Vector2(20, 20), //The dimensions of the map
new Vector2(0, 0), //The starting position of the path
new Vector2(19, 19), //The end/target position of the path
new Obstacle(Guid.NewGuid(), //An obstacle in the grid
new Vector2(5, 5), //The obstacle's position, this is set from the top lefthand corner.
new Vector2(10, 10))); //The dimensions of the obstacle.
Image of map above can go here.
INeighbourFinder is used by the PathFinder class to determine which nodes will be considered neighbours of the open node being acted on by the A* algorithm. It is also used to set the cost (sometimes called the f cost) of movement from a node to its neighbour. There are currently two implementations of INeighbourFinder in PathFinder: DefaultNeighbourFinder and JumpPointSearchNeighbourFinder. The DefaultNeighbourFinder class can be used when the neighbouring nodes of node are the nodes adjacent to that node. The nodes considered to be adjacent will depend on the direction of movement allowed from one node to another.
DefaultNeighbourFinder.Straight(1.0f) //Movement is only permitted horizontally and vertically, the cost of this movement is 1.
DefaultNeighbourFinder.Diagonal(1.0f) //Movement is only permitted diagonally, the cost of this movement is 1.
DefaultNeighbourFinder.All(1.0f, 1.41f) //Movement is permitted in all directions, the cost of horizontal or vertical movement is 1, the cost of diagonal movement is 1.41 (An approximation for the square root of 2).
Maybe some images to example the above here.
Examples
PathFinder uses Aptacode's FlowDesigner to visualise the grid on which the path is found and the path itself. Here is an example of path on a grid where each node had a 20% chance of being obstructed:
Image will go here.
License
Related Skills
node-connect
343.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
90.0kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
343.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
343.1kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
