-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RLlib] Fix MultiAgentEpisode getter bugs. #44898
[RLlib] Fix MultiAgentEpisode getter bugs. #44898
Conversation
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
@@ -464,7 +464,7 @@ def _get_int_index( | |||
# If index >= 0 -> Ignore lookback buffer. | |||
# Otherwise, include lookback buffer. | |||
if idx >= 0 or neg_indices_left_of_zero: | |||
idx = self.lookback + idx - (_ignore_last_ts is True) | |||
idx = self.lookback + idx |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the actual bug fix.
@@ -1023,6 +1023,50 @@ def test_get_actions(self): | |||
act = episode.get_actions(-4, env_steps=False, fill="skip") | |||
check(act, {"a0": "skip", "a1": 0}) | |||
|
|||
episode.add_env_step( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this to the tests. Mostly to figure out, whether a hanging action at the edge of the episode or further back would make a difference in get_actions(-1)
.
@@ -975,7 +975,7 @@ def test_get_actions(self): | |||
check(act, actions[i]) | |||
# Access >=0 integer indices (expect index error as everything is in | |||
# lookback buffer). | |||
for i in range(1, 5): | |||
for i in range(0, 5): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idx=0 was NOT working properly before this fix.
@@ -1633,21 +1633,30 @@ def __repr__(self): | |||
) | |||
|
|||
def print(self) -> None: | |||
"""Prints this MultiAgentEpisode as a table of observations for the agents.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made this a little nicer. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. All tests passed for the MAERB, too. This was the remaining part in the puzzle. Awesome!
@@ -464,7 +464,7 @@ def _get_int_index( | |||
# If index >= 0 -> Ignore lookback buffer. | |||
# Otherwise, include lookback buffer. | |||
if idx >= 0 or neg_indices_left_of_zero: | |||
idx = self.lookback + idx - (_ignore_last_ts is True) | |||
idx = self.lookback + idx |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing how such a small modification changes the landscape completely.
Fix MultiAgentEpisode getter bugs.
e.g.:
Why are these changes needed?
Related issue number
Checks
git commit -s
) in this PR.scripts/format.sh
to lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/
under thecorresponding
.rst
file.