-
-
Notifications
You must be signed in to change notification settings - Fork 429
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
Env creation tutorial 2 : grid size inconsistent #1036
Env creation tutorial 2 : grid size inconsistent #1036
Conversation
There were two mistakes - The grid is 8x8, not 7x7 : the guard starts at position (7,7) - The type was integers and it conflicts with the characters we assign in the function
For info, I want to have this PR validated before doing a C/C for tutorial 3 of env creation |
@@ -104,7 +104,7 @@ def step(self, actions): | |||
return observations, rewards, terminations, truncations, infos | |||
|
|||
def render(self): | |||
grid = np.zeros((7, 7)) | |||
grid = np.full((7,7), ' ', dtype='U1') |
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.
What does the second argument to np.full do here? And I googled around to see what exactly dtype U1 is but I'm confused about how this site says https://note.nkmk.me/en/python-numpy-dtype-astype/ the dtype should be <U1?
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 render space doesn't have to be the same as the observation space to be fair, but I can see how if we're overriding an array of integers with characters as the input that's a little sloppy. Granted, numpy lets you do that so it's like, ultimately it doesn't matter and is arguably cleaner code, but not as strictly correct. Could do it as a list of lists of size 49 or some other data type as well, but this is probably cleaner
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.
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.
But you're right that numpy does type inference and selects an appropriate type, so there's no need to manually specify that it's Unicode, I can remove U1
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.
Ah I see, thanks for testing it out. Looks good just doing full with a space character
If you can fix pre commit I’d be happy to merge |
There were two mistakes
render()
was integers and it conflicts with the characters we assign in the functionDescription
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
Fixes # (issue), Depends on # (pull request)
Type of change
Checklist:
pre-commit
checks withpre-commit run --all-files
(seeCONTRIBUTING.md
instructions to set it up)pytest -v
and no errors are present.pytest -v
has generated that are related to my code to the best of my knowledge.Most of those at not relevant, it's a doc change