-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathagent.py
More file actions
49 lines (39 loc) · 1.32 KB
/
agent.py
File metadata and controls
49 lines (39 loc) · 1.32 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
__all__ = ['Agent']
class Agent(object):
'''Base class for an autonomous agent.
Attributes:
level_scene (list): a 22x22 numpy array containing the elements of the
level, including blocks and enemies.
on_ground (bool): whether Mario is on ground or not.
can_jump (bool): whether Mario can jump or not.
mario_floats (list): 2-tuple with mario position.
enemies_floats (list): list of 2-tuples with enimies_positions.
episode_over (bool): whether the episode is over or not.
'''
def __init__(self):
'''Contructor.'''
self.level_scene = None
self.on_ground = None
self.can_jump = None
self.mario_floats = None
self.enemies_floats = None
self.episode_over = False
def reset(self):
'''New episode.'''
self.episode_over = False;
def sense(self, obs):
'''Receive sense.'''
if len(obs) != 6:
self.episode_over = True
else:
self.can_jump = obs[0]
self.on_ground = obs[1]
self.mario_floats = obs[2]
self.enemies_floats = obs[3]
self.level_scene = obs[4]
def act(self):
'''Return an action.'''
pass
def give_rewards(self, reward, cum_reward):
'''Register current reward.'''
pass