-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstate.py
More file actions
executable file
·51 lines (38 loc) · 1.02 KB
/
state.py
File metadata and controls
executable file
·51 lines (38 loc) · 1.02 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
42
43
44
45
46
47
48
49
50
51
####
#
# State
# Jake Kinsman
# 11/28/2014
#
####
#file tested
class state(object):
def __init__(self, position = (0, 9), terrainNum = 0):
self.position = position
self.world = terrainNum
self.terrainType = None
def __repr__(self):
return "Position: " + str(self.position) + " " + "Terrain: " + str(self.world)
def __eq__(self, arg):
return arg.getPosition() == self.getPosition() and self.getWorld() == arg.getWorld()
def __hash__(self):
x,y = self.getPosition()
w = self.getWorld()
if x == float('inf'): return 1001
if y == float('inf'): return 1002
return 100*w + 10*y + x
def getState(self):
return [self.position, self.world]
def setPosition(self, position, terrainNum):
self.position = position
self.world = terrainNum
def getPosition(self):
return self.position
def getWorld(self):
return self.world
def setWorld(self, value = 0):
self.world = value
def setTerrainType(self, terrainType):
self.terrainType = terrainType
def getTerrainType(self):
return self.terrainType