danijar / dreamerv3

Mastering Diverse Domains through World Models
https://danijar.com/dreamerv3
MIT License
1.28k stars 219 forks source link

Dict based action space #90

Closed ChrisAGBlake closed 5 months ago

ChrisAGBlake commented 1 year ago

I seem to get an error when attempting to use a gym environment with a Dict action space like as follows:

self.action_space = gym.spaces.Dict({'direction': gym.spaces.Discrete(5), 'foil': gym.spaces.Discrete(2)})

in agent.py it seems to expect only one action with the key 'action'

class Agent(nj.Module):

  configs = yaml.YAML(typ='safe').load(
      (embodied.Path(__file__).parent / 'configs.yaml').read())

  def __init__(self, obs_space, act_space, step, config):
    self.config = config
    self.obs_space = obs_space
    self.act_space = act_space['action']

in from_gym.py FromGym seems to add the key 'action' if there's only 1 action however if it's a dict based action space it doesn't modify it in a way that seems to be compatible with Agent().

Is there a way I can use a Dict based action space or a way to have more than 1 discrete action?

danijar commented 11 months ago

Hi, I already have dict action support implemented for the agent and hope to push the changes in a larger update in a few weeks.

ChrisAGBlake commented 11 months ago

Thanks very much! This is a fantastic algorithm.

sai-prasanna commented 9 months ago

@danijar Will there be an update anytime soon? And do you need help with the repo maintenance? I can lend a hand

danijar commented 5 months ago

Just updated the paper and code, which now supports dict action spaces.

ChrisAGBlake commented 5 months ago

Awesome. I'll test it out. Thanks