-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathenvironment.py
More file actions
38 lines (26 loc) · 913 Bytes
/
environment.py
File metadata and controls
38 lines (26 loc) · 913 Bytes
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
from abc import ABCMeta, abstractmethod
import random
class Environment(object):
__metaclass__ = ABCMeta
class ActionSpace(object):
def __init__(self, as_leng):
print ("Environment class > ActionSpace")
self.as_list = range(as_leng)
def sample(self):
return random.choice(self.as_list)
def __init__(self, as_leng, renderer=None):
self.as_leng = as_leng
self.renderer=renderer
self.episode_number = 0
self.action_space = self.ActionSpace(as_leng)
def render(self):
pass
@abstractmethod
def step(self, action):
"""
RETURN: (observation, reward, done, info)
"""
raise NotImplementedError("step must be explicitly overridden")
@abstractmethod
def reset(self):
raise NotImplementedError("reset must be explicitly overridden")