-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.py
More file actions
30 lines (26 loc) · 740 Bytes
/
Copy pathnode.py
File metadata and controls
30 lines (26 loc) · 740 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
from terrain import Terrain
import sys
"""
A class to represent the pixels in the map in a way that makes using a*
to find a path easier.
"""
class Node:
def __init__(self):
self.coords = (0,0)
self.previous = None
self.g = sys.maxsize
self.h = sys.maxsize
self.f = 0
self.elevation = 0
self.terrain = Terrain.ERROR
#sorts by fcost
def __lt__(self, other):
if type(other) == Node:
return self.f < other.f
return False
#nodes are the same node if they're in the same location
def __eq__(self, other):
if type(other) == Node:
if self.coords == other.coords:
return True
return False