Skip to content
This repository was archived by the owner on Apr 3, 2026. It is now read-only.

[WIP] Last action tracker#9

Draft
treeform wants to merge 8 commits into
mainfrom
andre-last-action-tracker
Draft

[WIP] Last action tracker#9
treeform wants to merge 8 commits into
mainfrom
andre-last-action-tracker

Conversation

@treeform
Copy link
Copy Markdown
Contributor

No description provided.

@treeform treeform force-pushed the andre-last-action-tracker branch from ba2e737 to d8bc797 Compare December 16, 2024 19:43
@@ -0,0 +1,61 @@
import gymnasium as gym
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks correct, but we discussed implementing this in cython for performance. Otherwise the step() function slows the env down significantly

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Doing it in python first is simpler. I want to get it working. There were so many things to figure out. Now that I have a python version working I can make the Cython version.

I do like your idea of "Feel free to edit grid_env.pyx directly if you think that's cleaner than adding a wrapper, just make sure we can turn it off via config". I'll try that too.

0,
255,
(box.shape[0] + 2, box.shape[1], box.shape[2]),
np.uint8
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

grab the dtype from the existing shape, so that if we change it we don't have to update this code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe single_observation_space?

# last action argument:
for agentId in range(shape[0]):
last_action_feature[
agentId, :, shape[2]//2, shape[3]//2
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

avoid doing the // in the loop. move it to the constructor since the index stays the same.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try that.

I lose a ton of speed resizing and creating the new tensors. I feel like I need another hook during their creation time so that they can be made the right size from the start.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants