-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAStar_Solver.h
More file actions
36 lines (27 loc) · 841 Bytes
/
Copy pathAStar_Solver.h
File metadata and controls
36 lines (27 loc) · 841 Bytes
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
#ifndef ASTAR_SOLVER_H
#define ASTAR_SOLVER_H
#include "Solver.h"
#include "Utils.h"
#include <queue>
#include <vector>
#include <utility>
#include <SFML/System/Clock.hpp>
class AStar_Solver : public Solver {
public:
explicit AStar_Solver(const Maze& maze);
void step() override;
private:
using Node = std::pair<int, int>;
struct NodeData {
int f; Node pos;
bool operator>(const NodeData& other) const { return f > other.f; }
};
// Data structure: A min-priority-queue (binary heap)
std::priority_queue<NodeData, std::vector<NodeData>, std::greater<NodeData>> openSet;
std::vector<std::vector<int>> gScore;
std::vector<std::vector<bool>> visited;
int heuristic(int r, int c) const;
// Clock for timing the algorithm
sf::Clock m_clock;
};
#endif // ASTAR_SOLVER_H