Resetting the player position does not seem to work when starting the environment with the action space set to continuous.
import gym
import iglu
from PIL import Image
from collections import OrderedDict
import numpy as np
import time
env = gym.make("IGLUSilentBuilder-v0", action_space='continuous')
env.observation_space
obs = env.reset()
noop_action = OrderedDict([('move_x', np.array(0)), ('move_y', np.array(0)), ('move_z', np.array(0)), ('camera', np.array([0, 0], dtype=np.float32)), ('hotbar', np.array(1)), ('attack', np.array(0)), ('use', np.array(0))])
start_fly = OrderedDict([('move_x', np.array(0)), ('move_y', np.array(1)), ('move_z', np.array(0)), ('camera', np.array([0, 0], dtype=np.float32)), ('hotbar', np.array(1)), ('attack', np.array(0)), ('use', np.array(0))])
look_down = OrderedDict([('move_x', np.array(0)), ('move_y', np.array(0)), ('move_z', np.array(0)), ('camera', np.array([90, 0], dtype=np.float32)), ('hotbar', np.array(1)), ('attack', np.array(0)), ('use', np.array(0))])
look_up = OrderedDict([('move_x', np.array(0)), ('move_y', np.array(0)), ('move_z', np.array(0)), ('camera', np.array([0, 0], dtype=np.float32)), ('hotbar', np.array(1)), ('attack', np.array(0)), ('use', np.array(0))])
place_block_1 = OrderedDict([('move_x', np.array(0)), ('move_y', np.array(0)), ('move_z', np.array(0)), ('camera', np.array([0, 0], dtype=np.float32)), ('hotbar', np.array(1)), ('attack', np.array(0)), ('use', np.array(1))])
def make_action(action, wait=False):
obs, _, _, _ = env.step(action)
im = Image.fromarray(
obs["pov"],
).resize((256, 256))
im.save(f"output_{time.time():10.8f}.png")
if wait:
for _ in range(4):
make_action(noop_action, wait=False)
make_action(noop_action, wait=True)
make_action(look_down)
make_action(start_fly, wait=True)
make_action(start_fly, wait=True)
make_action(place_block_1)
make_action(start_fly, wait=True)
make_action(start_fly, wait=True)
env.reset()
make_action(noop_action, wait=True)
make_action(look_down, wait=True) # we're still flying
If you look at the final output image, you can see the agent is still floating in mid-air, but the block is gone. Also when the environment is reset, the camera is reset to (0,0). It seems to be a problem in the movement command?
I checked the communication with Malmo, it also seems to generate the fake reset command for FakeResetCommandImplementation properly, perhaps the x,y,z in player.setPositionAndRotation(x, y, z, yaw, pitch); are not set correctly (see CODE) ?
This is where I lost track..
Hi @artemZholus,
Resetting the player position does not seem to work when starting the environment with the action space set to
continuous.Here's a MWE:
If you look at the final output image, you can see the agent is still floating in mid-air, but the block is gone. Also when the environment is reset, the camera is reset to (0,0). It seems to be a problem in the movement command?
I checked the communication with Malmo, it also seems to generate the fake reset command for
FakeResetCommandImplementationproperly, perhaps thex,y,zinplayer.setPositionAndRotation(x, y, z, yaw, pitch);are not set correctly (see CODE) ?This is where I lost track..