-
Notifications
You must be signed in to change notification settings - Fork 249
Expand file tree
/
Copy path__init__.py
More file actions
161 lines (133 loc) · 4.55 KB
/
Copy path__init__.py
File metadata and controls
161 lines (133 loc) · 4.55 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
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
"""Custom Gym environments.
Every class inside this module should extend a gym.Env class. The file
structure should be similar to gym.envs file structure, e.g. if you're
implementing a mujoco env, you would implement it under gym.mujoco submodule.
"""
import gym
CUSTOM_GYM_ENVIRONMENTS_PATH = __package__
MUJOCO_ENVIRONMENTS_PATH = f'{CUSTOM_GYM_ENVIRONMENTS_PATH}.mujoco'
MUJOCO_ENVIRONMENT_SPECS = (
{
'id': 'Swimmer-Parameterizable-v3',
'entry_point': (f'gym.envs.mujoco.swimmer_v3:SwimmerEnv'),
},
{
'id': 'Hopper-Parameterizable-v3',
'entry_point': (f'gym.envs.mujoco.hopper_v3:HopperEnv'),
},
{
'id': 'Walker2d-Parameterizable-v3',
'entry_point': (f'gym.envs.mujoco.walker2d_v3:Walker2dEnv'),
},
{
'id': 'HalfCheetah-Parameterizable-v3',
'entry_point': (f'gym.envs.mujoco.half_cheetah_v3:HalfCheetahEnv'),
},
{
'id': 'Ant-Parameterizable-v3',
'entry_point': (f'gym.envs.mujoco.ant_v3:AntEnv'),
},
{
'id': 'Humanoid-Parameterizable-v3',
'entry_point': (f'gym.envs.mujoco.humanoid_v3:HumanoidEnv'),
},
{
'id': 'Pusher2d-Default-v0',
'entry_point': (f'{MUJOCO_ENVIRONMENTS_PATH}'
'.pusher_2d:Pusher2dEnv'),
},
{
'id': 'Pusher2d-DefaultReach-v0',
'entry_point': (f'{MUJOCO_ENVIRONMENTS_PATH}'
'.pusher_2d:ForkReacherEnv'),
},
{
'id': 'Pusher2d-ImageDefault-v0',
'entry_point': (f'{MUJOCO_ENVIRONMENTS_PATH}'
'.image_pusher_2d:ImagePusher2dEnv'),
},
{
'id': 'Pusher2d-ImageReach-v0',
'entry_point': (f'{MUJOCO_ENVIRONMENTS_PATH}'
'.image_pusher_2d:ImageForkReacher2dEnv'),
},
{
'id': 'Pusher2d-BlindReach-v0',
'entry_point': (f'{MUJOCO_ENVIRONMENTS_PATH}'
'.image_pusher_2d:BlindForkReacher2dEnv'),
},
{
'id': 'Humanoid-RLLab-v0',
'entry_point': (f'{MUJOCO_ENVIRONMENTS_PATH}'
'.rllab_humanoid:RLLabHumanoidEnv'),
},
{
'id': 'Swimmer-RLLab-v0',
'entry_point': (f'{MUJOCO_ENVIRONMENTS_PATH}'
'.rllab_swimmer:RLLabSwimmerEnv'),
},
)
GENERAL_ENVIRONMENT_SPECS = (
{
'id': 'MultiGoal-Default-v0',
'entry_point': (f'{CUSTOM_GYM_ENVIRONMENTS_PATH}'
'.multi_goal:MultiGoalEnv')
},
)
MULTIWORLD_ENVIRONMENT_SPECS = (
{
'id': 'Point2DEnv-Default-v0',
'entry_point': 'multiworld.envs.pygame.point2d:Point2DEnv'
},
{
'id': 'Point2DEnv-Wall-v0',
'entry_point': 'multiworld.envs.pygame.point2d:Point2DWallEnv'
},
)
MUJOCO_ENVIRONMENTS = tuple(
environment_spec['id']
for environment_spec in MUJOCO_ENVIRONMENT_SPECS)
GENERAL_ENVIRONMENTS = tuple(
environment_spec['id']
for environment_spec in GENERAL_ENVIRONMENT_SPECS)
MULTIWORLD_ENVIRONMENTS = tuple(
environment_spec['id']
for environment_spec in MULTIWORLD_ENVIRONMENT_SPECS)
GYM_ENVIRONMENTS = (
*MUJOCO_ENVIRONMENTS,
*GENERAL_ENVIRONMENTS,
*MULTIWORLD_ENVIRONMENTS,
)
def register_mujoco_environments():
"""Register softlearning mujoco environments."""
for mujoco_environment in MUJOCO_ENVIRONMENT_SPECS:
gym.register(**mujoco_environment)
gym_ids = tuple(
environment_spec['id']
for environment_spec in MUJOCO_ENVIRONMENT_SPECS)
return gym_ids
def register_general_environments():
"""Register gym environments that don't fall under a specific category."""
for general_environment in GENERAL_ENVIRONMENT_SPECS:
gym.register(**general_environment)
gym_ids = tuple(
environment_spec['id']
for environment_spec in GENERAL_ENVIRONMENT_SPECS)
return gym_ids
def register_multiworld_environments():
"""Register custom environments from multiworld package."""
for multiworld_environment in MULTIWORLD_ENVIRONMENT_SPECS:
gym.register(**multiworld_environment)
gym_ids = tuple(
environment_spec['id']
for environment_spec in MULTIWORLD_ENVIRONMENT_SPECS)
return gym_ids
def register_environments():
registered_mujoco_environments = register_mujoco_environments()
registered_general_environments = register_general_environments()
registered_multiworld_environments = register_multiworld_environments()
return (
*registered_mujoco_environments,
*registered_general_environments,
*registered_multiworld_environments,
)