-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.py
More file actions
42 lines (35 loc) · 1.17 KB
/
node.py
File metadata and controls
42 lines (35 loc) · 1.17 KB
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
'''
class Node, cell world including pathfinding states
Created on 2010-09-09
@author: Artsimboldo
'''
#---------------------------------------------------------------------------------
class Node():
'''
classdocs
'''
#-----------------------------------------------------------------------------
def __init__(self, i = 0, j = 0, type = 0):
'''
Constructor
'''
self.i = i
self.j = j
self.type = type
# pathfinding variables
self.cost = 0.
self.heuristic = 0.
self.state = 0
self.parent = None
#-----------------------------------------------------------------------------
def __eq__(self, other):
if isinstance(other, Node):
return (self.i == other.i and self.j == other.j)
else:
return False
#-----------------------------------------------------------------------------
def __cmp__(self, node):
return cmp(self.heuristic + self.cost, node.heuristic + node.cost)
#-----------------------------------------------------------------------------
def __str__(self):
return str(self.type)