aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorymherklotz <ymherklotz@gmail.com>2016-12-10 00:02:43 +0000
committerymherklotz <ymherklotz@gmail.com>2016-12-10 00:02:43 +0000
commit963a8d2b5f80a111514dc6eaa56d6b637ee783e1 (patch)
tree590efd6021b2c49b3afc13e08069a5be1488a1a8 /include
parent879f058f89cd51e87c741025df1b13146e3aef1b (diff)
downloadA-star-algorithm-963a8d2b5f80a111514dc6eaa56d6b637ee783e1.tar.gz
A-star-algorithm-963a8d2b5f80a111514dc6eaa56d6b637ee783e1.zip
starting astar algorithm
Diffstat (limited to 'include')
-rw-r--r--include/astar.hpp17
-rw-r--r--include/node.hpp14
2 files changed, 25 insertions, 6 deletions
diff --git a/include/astar.hpp b/include/astar.hpp
index bcff452..a3d2178 100644
--- a/include/astar.hpp
+++ b/include/astar.hpp
@@ -5,6 +5,7 @@
#include "node.hpp"
#include <ostream>
+#include <vector>
// defines the number of nodes one can go to
// we don't need this as we will have the queues
@@ -13,10 +14,22 @@
// TODO add constructors and functions to calculate heuristics etc..
class AStar {
public:
- AStar();
+ AStar(int *curr_graph, const unsigned int& width, const unsigned int& height);
private:
PriorityQueue<Node> open_set;
- Node current;
+ std::vector<Node> closed_set;
+
+ int *graph;
+ int graph_width;
+ int graph_height;
+
+ Node current_node, start_node, end_node;
+
+ void set_start_end();
+
+ Node get_neighbour(const Node& n_in, const int& neighbour_num);
+
+ void calc_heuristic(Node& n);
};
#endif // ASTAR_HPP
diff --git a/include/node.hpp b/include/node.hpp
index 314fc7c..3b81b1c 100644
--- a/include/node.hpp
+++ b/include/node.hpp
@@ -3,13 +3,19 @@
#include <ostream>
+class AStar;
+
class Node {
+ friend AStar;
public:
Node();
- void set_f(int i) {
- f_score = i;
- }
+ void set_x(int x_in);
+ void set_y(int y_in);
+ void set_h_score(int h);
+ void set_g_score(int g);
+
+ void compute_f();
// overloading operators for ease of use.
friend bool operator<(const Node& n1, const Node& n2);
@@ -31,7 +37,7 @@ private:
int f_score;
// path length to get to that node.
int g_score;
-// heulistic length to destination.
+// heuristic length to destination.
int h_score;
// the x and y coordinates of the node in the grid