forked from aimacode/aima-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobjects.py
More file actions
56 lines (44 loc) · 1.53 KB
/
objects.py
File metadata and controls
56 lines (44 loc) · 1.53 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
52
53
54
55
56
class Object:
'''
This represents any physical object that can appear in an Environment. You subclass Object to get the objects you
want. Each object can have a .__name__ slot (used for output only).'''
# Mark: __repr__ exists to create a printable output of an object (in this case, name)
def __repr__(self):
if self.id == '':
return '<%s>' % getattr(self, '__name__', self.__class__.__name__)
else:
return '<%s id=%s>' % (getattr(self, '__name__', self.__class__.__name__), self.id)
def is_alive(self):
'''Objects that are 'alive' should return true.'''
return hasattr(self, 'alive') and self.alive
# is_grabbable()
def is_grabbable(self, obj):
return False
def destroy(self):
#print("Destroying %s" % self)
pass
# can the object be passed over, or does it occupy space.
blocker = False
#image_source = ''
#image = None
id = ''
class Dirt(Object):
def __init__(self):
pass
def is_grabbable(self, obj):
if hasattr(obj, 'holding'):
return True
else:
return False
class Wall(Object):
blocker = True
class DeadCell(Wall):
pass
class Fire(Wall):
def __repr__(self):
if self.id == '':
return '<%s t=%s>' % (getattr(self, '__name__', self.__class__.__name__), self.t)
else:
return '<%s t=%s id=%s>' % (getattr(self, '__name__', self.__class__.__name__), self.t, self.id)
def __init__(self):
self.t = 5