Overhaul pathfinding algorithm

This commit is contained in:
2023-11-24 20:25:21 +01:00
parent 6e977b7433
commit b77e939c52
8 changed files with 127 additions and 68 deletions

View File

@@ -9,15 +9,15 @@ typedef struct PathNode {
i32 weight; // fCost = g + h
i32 gCost; // from start cost
i32 hCost; // to target cost
bool visited;
TilePosition pos;
} PathNode;
typedef struct PathClosedNode {
typedef struct PathNodeRecord {
bool visited : 1;
bool open : 1;
i8 x : 3;
i8 y : 3;
} PathClosedNode;
} PathNodeRecord;
typedef struct PathfindingDesc {
Position start;
@@ -25,11 +25,11 @@ typedef struct PathfindingDesc {
BzObjectPool *pool;
BzTileMap *map;
PathNode *openSet; // heap (size: width * height)
PathClosedNode *closedSet; // size: width * height
PathNodeRecord *closedSet; // size: width * height
Path *outPath;
} PathfindingDesc;
bool findPath(const PathfindingDesc *desc);
bool pathfindAStar(const PathfindingDesc *desc);
// TODO: Flowfield
void calculateFlowField();