-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.cpp
More file actions
38 lines (32 loc) · 891 Bytes
/
Copy pathnode.cpp
File metadata and controls
38 lines (32 loc) · 891 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
37
38
#include "node.h"
Node::Node(bool _walkable, qreal _worldPosX, qreal _worldPosY,int _gridX, int _gridY, int _difficulty) {
walkable = _walkable;
worldPositionX = _worldPosX;
worldPositionY = _worldPosY;
gridX = _gridX;
gridY = _gridY;
gCost = INT_MAX;
hCost = INT_MAX;
parentX = 0;
parentY = 0;
difficulty = _difficulty;
}
Node Node::value() {
Node tempNode(walkable,worldPositionX,worldPositionY,gridX,gridY);
return tempNode;
}
long double Node::fCost() {
return (gCost + hCost);
}
bool Node::operator == (Node node) {
if((gridX == node.gridX) && (gridY == node.gridY)) return true;
return false;
}
bool Node::operator!= (Node node) {
if((gridX == node.gridX) && (gridY == node.gridY)) return false;
return true;
}
bool Node::operator >(Node node) {
if (fCost() > node.fCost()) return true;
return false;
}