-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathutils.py
120 lines (87 loc) · 2 KB
/
utils.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
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
from enum import Enum
import numpy as np
class InvalidMapError(Exception):
"""
Custom Exception for when an invalid map was created
"""
pass
class Directions(Enum):
EAST = 0
E = 0
NORTH = 1
N = 1
WEST = 2
W = 2
SOUTH = 3
S = 3
class MapTiles(Enum):
U = -1
UNKNOWN = -1
P = 0
PATH = 0
S = 1
SAND = 1
M = 2
MOUNTAIN = 2
W = 3
WALL = 3
tile_cost = {
MapTiles.PATH: 1,
MapTiles.SAND: 3,
MapTiles.MOUNTAIN: 10}
class MapObject(object):
def __init__(self):
self.strength = 0
self.label = 'mapobject'
self.delta = 0
def move(self):
"""
Returns
-------
direction: Directions
Which direction to move
"""
pass
class AgentPlaceholder(MapObject):
"""
A placeholder for an agent for when an agent appears in another agent's
visible part of the map
"""
def __init__(self, strength):
super().__init__()
self.strength = strength
self.label = 'agent'
self.delta = -strength
class StaticMonster(MapObject):
def __init__(self):
super().__init__()
self.strength = 10
self.label = 'skeleton'
self.delta = -10
class DynamicMonster(MapObject):
def __init__(self, initial_i, initial_j):
super().__init__()
self.initial_i = initial_i
self.initial_j = initial_j
self.strength = 10
self.label = 'skeleton'
self.delta = -10
def move(self):
"""
Returns
-------
direction: Directions
Which direction to move
"""
return np.random.choice(list(Directions))
class PowerUp(MapObject):
def __init__(self):
super().__init__()
self.label = 'medkit'
self.delta = 10
class Boss(StaticMonster):
def __init__(self):
super().__init__()
self.strength = 100
self.label = 'boss'
self.delta = -100