-
Notifications
You must be signed in to change notification settings - Fork 29
/
custom_environment_stub.py
70 lines (53 loc) · 1.65 KB
/
custom_environment_stub.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
"""
Use a custom environment.
"""
from adept.env import EnvModule
from adept.scripts.local import parse_args, main
class MyCustomEnv(EnvModule):
# You will be prompted for these when training script starts
args = {"example_arg1": True, "example_arg2": 5}
ids = ["scenario1", "scenario2"]
def __init__(self, action_space, cpu_ops, gpu_ops, *args, **kwargs):
super(MyCustomEnv, self).__init__(action_space, cpu_ops, gpu_ops)
@classmethod
def from_args(cls, args, seed, **kwargs):
"""
Construct from arguments. For convenience.
:param args: Arguments object
:param seed: Integer used to seed this environment.
:param kwargs: Any custom arguments are passed through kwargs.
:return: EnvModule instance.
"""
pass
def step(self, action):
"""
Perform action.
ActionID = str
Observation = Dict[ObsKey, Any]
Reward = np.ndarray
Terminal = bool
Info = Dict[Any, Any]
:param action: Dict[ActionID, Any] Action dictionary
:return: Tuple[Observation, Reward, Terminal, Info]
"""
pass
def reset(self, **kwargs):
"""
Reset environment.
ObsKey = str
:param kwargs:
:return: Dict[ObsKey, Any] Observation dictionary
"""
pass
def close(self):
"""
Close any connections / resources.
:return:
"""
pass
if __name__ == "__main__":
import adept
adept.register_env(MyCustomEnv)
main(parse_args())
# Call script like this to train agent:
# python -m custom_env_stub.py --env scenario1