-
Notifications
You must be signed in to change notification settings - Fork 8
/
ta_state.py
44 lines (31 loc) · 1.02 KB
/
ta_state.py
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
"""
Created on Sat Apr 18 10:45:11 2020
@author: Pieter Cawood
"""
class Location(object):
def __init__(self, col, row):
self.col = col
self.row = row
def __eq__(self, other):
return self.col == other.col and self.row == other.row
def __hash__(self):
return hash(str(self.col) + str(self.row))
def __str__(self):
return str((self.col, self.row))
class State(object):
def __init__(self, time, location):
self.time = time
self.location = location
self.g = 0
self.f = 0
def __eq__(self, other):
return self.time == other.time and self.location == other.location
def __hash__(self):
return hash(str(self.time) + str(self.location.col) + str(self.location.row))
def __str__(self):
return str((self.time, self.location.col, self.location.row))
def __lt__(self, other):
if self.f < other.f:
return True
else:
return False