-
Notifications
You must be signed in to change notification settings - Fork 48
Refactor inventory system into dedicated InventoryConfig class #4356
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
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Merge activity
|
0735eea to
80c1cf6
Compare
80c1cf6 to
7668fd5
Compare
7668fd5 to
c8b1cf2
Compare
3e018fc to
490050d
Compare
packages/mettagrid/cpp/include/mettagrid/systems/observation_encoder.hpp
Outdated
Show resolved
Hide resolved
packages/mettagrid/cpp/include/mettagrid/systems/observation_encoder.hpp
Outdated
Show resolved
Hide resolved
packages/mettagrid/cpp/include/mettagrid/systems/observation_encoder.hpp
Outdated
Show resolved
Hide resolved
sasmith
left a comment
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.
Requesting changes again.
If you want to extract the increased inventory amounts, that would be fine. If you want to leave them in, the base-vs-max issue needs to get fixed (it will have a nice side effect of capping the number of tokens to 2).
38ea7cd to
ef5f7f2
Compare
ef5f7f2 to
0fdcc0b
Compare
|
I somehow merged the multi-token changes into this branch, instead of the one above. i folded them both into one, so it makes more sense now |
|
Looks like there are a few issues preventing this PR from being merged!
If you'd like me to help, just leave a comment, like Feel free to include any additional details that might help me get this PR into a better state. You can manage your notification settings |
| } | ||
|
|
||
| // Encode inventory amount using multi-token encoding with configurable base. | ||
| // inv:{resource} = amount % token_value_base (always emitted) |
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.
Sort of interesting that we leave this off if the total resource value is zero, but we include it if the total value is non-zero, even if this particular component is zero. Seems fine -- just interesting.
## Summary - Default the agent obs shim to ignore inventory power tokens (`inv:*:pN`) and remap feature IDs to legacy ordering - Restore legacy inventory normalization (100.0) for those remapped features - Fix power-token detection regex so the shim is effective ## Why Inventory power tokens introduced in #4356 shifted feature IDs and broke older policies trained on the pre-split inventory encoding. We only care about counts up to 255 for agents, so remapping to the legacy scheme restores compatibility. ## Changes - `ObsShimTokens` now defaults `ignore_inventory_power_tokens=True` - Power-token names are detected correctly and remapped to UNKNOWN - Legacy feature ID ordering + legacy normalization restored for inventory features ## Testing - `uv run cogames run -m machina_1.open_world -c 4 -v heart_chorus -p s3://softmax-public/policies/relh.machina_bc_dinky_sup.hc.1221.10b.0.35/relh.machina_bc_dinky_sup.hc.1221.10b.0.35:v2700.mpt -e 1 -s 1000 --format json`

TL;DR
Refactored inventory management by introducing a dedicated
InventoryConfigclass and restructuring inventory-related properties across the codebase.What changed?
InventoryConfigclass to encapsulate inventory-related propertiesAgentConfigandChestConfiginto the newInventoryConfig:initial_inventory→inventory.initialresource_limits→inventory.limitsdefault_resource_limit→inventory.default_limitinventory_regen_amounts→inventory.regen_amountsHow to test?
Why make this change?
This refactoring improves code organization by grouping related inventory properties into a dedicated class, making the codebase more maintainable and easier to understand. The change also removes unused features like inventory diversity tracking and soul-bound resources, simplifying the codebase. The increased inventory quantity size allows for larger inventory values, providing more flexibility in game design.