Skip to content

'continuous' action space env.reset() does not reset player position #20

@m0re4u

Description

@m0re4u

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:

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

output_1640023971 97719121
output_1640023972 14017224
output_1640023972 55107307
output_1640023972 84333348
output_1640023973 22247696
output_1640023973 40249443

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..

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions