question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Always return full state dict (even when only one agent)

See original GitHub issue

Describe the bug In some cases, generic code that is meant to be compatible with any of the Holodeck worlds is required (more specifically for my application: any of the worlds that contain a UavAgent). Currently, it is not possible to access the state after ticking with the same syntax for all the worlds containing UavAgent. This is because some worlds have multiple agents while others have only one, and the dictionary returned for multiple agents is agent name to sensor, but for a single agent world it is a sensor to data dict.

I understand that the setup code for the two different world types needs to be different, but in my case, I have separated the setup code from the main script, and the setup code is different depending on which world is specified. My main script, however, contains a lot of logic and operations that are meant to work for a UavAgent in any world, and I need to access the state multiple times throughout.

To Reproduce The following code works fine for a multi-agent world:

uav_state = env.tick()['uav0']

But fails if the world has only one agent.

Expected behavior It seems to me that the syntax should be consistent regardless of the number of agents. I don’t see a strong need for a different interface between one or multiple agents (other than for slightly simpler code in the single-agent case), and I am of the opinion that the state should simply always return as an agent name to sensor dict.

I tested changing the following lines of environments.py (in the reset function) from

if self.num_agents == 1:
    self._default_state_fn = self._get_single_state
else:
    self._default_state_fn = self._get_full_state

to

self._default_state_fn = self._get_full_state

and the code for accessing the state in a multi-agent world (the Ocean world) had no problems accessing the state in a single-agent world (UrbanCity) as well.

I realize I may be missing something and am open to other solutions.

Version Information:

  • OS: Ubuntu
  • Version: 18.04
  • Holodeck Version: 0.2.2dev (boat-freeze branch)
  • World/Scenario version: 0.2.2dev

Additional context Also, I noticed that self._default_state_fn is set in both the __init__ and reset functions of HolodeckEnvironment. Isn’t one or the other redundant?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
nickwaltoncommented, Sep 11, 2019

We discussed and decided that while env.step() should follow openai GYM api. But env.tick() should behave the same whether its a single or multi agent world @allisoncl8

0reactions
daniekpocommented, Oct 24, 2019

@nickwalton, can we close this issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to set a openai-gym environment start with a specific ...
How can I tell the gym.env that I want set the initial observation as ns and let the agent know the specific start...
Read more >
Saving and Loading Models - PyTorch
Saving and Loading Models. Author: Matthew Inkawhich. This document provides solutions to a variety of use cases regarding the saving and loading of...
Read more >
NetLogo 6.3.0 User Manual: NetLogo Dictionary
Note: nobody is not an agentset. You only get nobody back in situations where you were expecting a single agent, not a whole...
Read more >
The Complete Reinforcement Learning Dictionary
Bandits have no different states, but only one — and the reward taken under consideration is only the immediate one.
Read more >
52 essential real estate terms you should know - Opendoor
Listing & property info · Conventional sale · Land lease · Probate sale · Real-estate owned (REO) · Rent back · Subject to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found