aboutsummaryrefslogtreecommitdiffstats
path: root/include/node.hpp
blob: f126fc4c36f5729a90ac34b0a33a709a17066f07 (plain)
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
#ifndef NODE_HPP
#define NODE_HPP

#include <ostream>

class AStar;

class Node {
	friend AStar;
public:
	Node();

	// overloading operators for ease of use.
	friend bool operator<(const Node& n1, const Node& n2);
	friend bool operator==(const Node& n1, const Node& n2);
	friend bool operator>(const Node & n1, const Node & n2);
	friend bool operator<=(const Node& n1, const Node& n2);
	friend bool operator>=(const Node& n1, const Node& n2);
	friend bool operator!=(const Node& n1, const Node& n2);
	friend std::ostream& operator<<(std::ostream& out, const Node& n);
private:
	// pointer to previous node so that I can backtrack without using recursion.
	int x_prev, y_prev;
	// pointers to the next nodes of which there are 4 in a grid.
	// We do not need this as we are implementing a priority queue;
	//Node *next_nodes[NEIGHBOUR_NUM];

	// score that is used to compare to other nodes to see if the other path is
	// more efficient.
	int f_score;
	// path length to get to that node.
	int g_score;
	// heuristic length to destination.
	int h_score;

	// the x and y coordinates of the node in the grid
	int x, y;

	// see if node has been visited.
	// We don't need this as we will have an open and a closed set
	//bool visited;
};

#endif // NODE_HPP