Skip to content

Conversation

@daveey
Copy link
Contributor

@daveey daveey commented Dec 25, 2025

TL;DR

Added a Commons system to MettaGrid that allows multiple grid objects to share a common inventory.

What changed?

  • Added Commons and CommonsConfig classes to implement shared inventories
  • Extended GridObject with methods to associate objects with a commons
  • Updated MettaGrid to initialize commons from config and associate objects via tags
  • Added support for specifying commons in Python configuration
  • Objects can be associated with a commons via a tag (commons:name) or directly in config
  • Added comprehensive tests for the commons functionality

How to test?

  1. Create a commons configuration:
CommonsConfig(
    name="team_storage",
    inventory=InventoryConfig(
        initial={"gold": 100},
        limits={"resources": ResourceLimitsConfig(limit=1000, resources=["gold"])}
    )
)
  1. Associate objects with the commons:
ChestConfig(name="team_chest", commons="team_storage")
  1. Access the shared inventory through any associated object

  2. Run the test suite:

python -m mettagrid.tests.test_commons

Why make this change?

This change enables shared resource management between multiple grid objects, which is useful for:

  • Team-based resource sharing
  • Creating common resource pools for groups of objects
  • Implementing economic systems with shared inventories
  • Supporting collaborative gameplay mechanics where multiple agents can contribute to and withdraw from a common resource pool

Copy link
Contributor Author

daveey commented Dec 25, 2025

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants