-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathenvironment.py
More file actions
80 lines (58 loc) · 1.23 KB
/
environment.py
File metadata and controls
80 lines (58 loc) · 1.23 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
####
#
# Environment Terrain Objects
# Jake Kinsman
# 11/28/2014
#
####
import random
class terrain:
def __init__(self):
self.terrainWorld = list()
for _ in range(10):
section = list()
for __ in range(10):
obj = random.choice([grass(), water(), mountain(), forest()])
section.append(obj)
self.terrainWorld.append(section)
def showTerrain(self):
for i in range(10):
print self.terrainWorld[i]
def showScores(self):
for i in range(10):
print map( lambda n: n.getScore(), self.terrainWorld[i])
class terrainObject:
def __init__(self):
pass
def __repr__(self):
pass
def getScore(self):
pass
class grass(terrainObject):
def __init__(self):
self.score = 5
def __repr__(self):
return 'grass'
def getScore(self):
return self.score
class mountain(terrainObject):
def __init__(self):
self.score = 3
def __repr__(self):
return 'mountain'
def getScore(self):
return self.score
class water(terrainObject):
def __init__(self):
self.score = 4
def __repr__(self):
return 'water'
def getScore(self):
return self.score
class forest(terrainObject):
def __init__(self):
self.score = 4
def __repr__(self):
return 'forest'
def getScore(self):
return self.score