-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_env.py
50 lines (30 loc) · 1.14 KB
/
test_env.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
import gymnasium as gym
import numpy as np
from PIL import Image
from core.utils import pixel_replication
# TEST ENVIRONMENTS IMAGES
NAME_TRANSFER = 'transfer_tasks.png' # name of transfer task image to be saved
NAME_VIRTUAL = 'vf5.png' # name of virtual task image to be saved
def plot_virtual_tasks(virtual_task=1):
'''
creates an image of environment with virtual tasks defined in MazEnv
inputs:
-virtual_task: which virtual task to create (1 or 2)
'''
env = gym.make('core:MazEnv-v0', virtual_goal=virtual_task)
image = Image.fromarray(pixel_replication(env.return_virtual_goals(), 18), "RGB")
image.save(NAME_VIRTUAL)
def plot_transfer_tasks():
'''
creates an image of environment with transfer tasks defined in MazEnv
'''
env = gym.make('core:MazEnv-v0')
state, _ = env.reset()
state[9, 11] = np.array([0, 200, 0])
state[1, 4] = np.array([0, 200, 0])
image = Image.fromarray(pixel_replication(state, 18), "RGB")
image.save(NAME_TRANSFER)
def main():
plot_transfer_tasks()
if __name__ == '__main__':
main()