forked from dgcor/DGEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPathFinder.h
More file actions
executable file
·56 lines (41 loc) · 1.49 KB
/
Copy pathPathFinder.h
File metadata and controls
executable file
·56 lines (41 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#pragma once
#include "GameProperties.h"
#include "stlastar.h"
class LevelMap;
template <class T>
class AStarMapSearch : public AStarSearch<T>
{
public:
const LevelMap* map{ nullptr };
static constexpr int MaxNodes = 150;
AStarMapSearch(const LevelMap* map_) : AStarSearch<T>(MaxNodes), map(map_) {}
};
class MapSearchNode
{
private:
static constexpr float NodeInvalid = std::numeric_limits<float>::max();
static constexpr float NodeNotPassable = 9.f;
static constexpr float NodePassable = 1.f;
bool addSuccessor(AStarSearch<MapSearchNode>* astarsearch,
int16_t x_, int16_t y_, int16_t parent_x, int16_t parent_y);
public:
int16_t x;
int16_t y;
float cost;
PlayerDirection direction;
MapSearchNode() noexcept : x(0), y(0), cost(NodeNotPassable), direction(PlayerDirection::All) {}
MapSearchNode(const LevelMap& map, int16_t x_, int16_t y_,
const PlayerDirection& direction_) noexcept;
bool IsValid() const noexcept;
bool IsPassable() const;
float GoalDistanceEstimateC(const MapSearchNode& nodeGoal) const noexcept;
float GetCost() const;
float GoalDistanceEstimate(MapSearchNode& nodeGoal) noexcept;
bool IsGoal(MapSearchNode& nodeGoal) noexcept;
bool GetSuccessors(AStarSearch<MapSearchNode>* astarsearch, MapSearchNode* parent_node);
float GetCost(MapSearchNode& successor);
bool IsSameState(MapSearchNode& rhs) noexcept;
};
bool getNearestPassableEndNode(const LevelMap& map,
const MapSearchNode& start, MapSearchNode& end);
typedef AStarMapSearch<MapSearchNode> PathFinder;