-
Notifications
You must be signed in to change notification settings - Fork 8.6k
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
Change done
field to integers for handling truncation vs termination
#2608
Conversation
@@ -648,7 +648,7 @@ def _worker(index, env_fn, pipe, parent_pipe, shared_memory, error_queue): | |||
|
|||
elif command == "step": | |||
observation, reward, done, info = env.step(data) | |||
if done: | |||
if bool(done): |
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.
I don't think this actually does anything, the conditional works even with an integer:
if 2:
print("Hi")
> Hi
An argument might be made for readability, but I don't think casting to bool actually makes it more readable
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.
The fact that if done
still works is actually a pretty good showcase of the (mostly) backwards-compatibility of this
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.
An argument might be made for readability, but I don't think casting to bool actually makes it more readable
Yes, I put this for readability. This explicit type casting is made for "keep in mind that expression
is not a boolean in statement bool(expression)
".
@XuehaiPan could you please fix the merge conflicts? |
Closed because it is preferred to explicitly add two booleans |
Change value range for
done
from(False, True)
to(0, 1, 2)
. See #2510 (comment) for more details.Resolves #2510
Old API:
done
is booleanType and Value Range
Sampling
Value iteration
This cannot distinguish truncation and termination. The
done
value for both situation isTrue
.New API:
done
is integer in{0, 1, 2}
Type and Value Range
NOTE: It's better to reference constants by name rather than value.
Sampling
NOTE: in
if expression
/while experssion
/not expression
, the explicit type castingbool(done)
can be ommited.Value iteration
The only change is:
or