Using PropertyLayer instead of stationary patch agents in some examples
- Dominant language
- Python
- Stars
- 252
- Forks
- 279
- Avg merge
- 8d 9h
- Merged PRs (30d)
- 2
Description
Hi everyone,
While exploring the mesa-examples repository and experimenting with Mesa’s newer APIs, I noticed that some spatial models represent environment state using stationary patch agents. For example, in the forest fire model, each grid cell is represented by a `TreeCell `agent whose main purpose is just to store the cell’s state (Fine, Burning, Burned).
Since Mesa now provides `PropertyLayer `for storing grid-based properties, I was wondering if some of these cases could be simplified by moving environment state to a property layer attached to the grid rather than creating thousands of patch agents.
For example, instead of something like:
```
class TreeCell(Agent):
def __init__(self, model, pos):
super().__init__(model)
self.condition = "Fine"
```
the model could store this information directly on the grid using a PropertyLayer, e.g.:
```
fire_state = PropertyLayer(...)
```
with something like:
```
fire_state[x, y] = 0 # fine
fire_state[x, y] = 1 # burning
fire_state[x, y] = 2 # burned
```
The simulation step would then update the grid state directly instead of modifying agent attributes.
The idea would be to apply this only in examples where patch agents are acting purely as containers for environment state, not where they represent actual acting entities.
Some potential steps could be:
- Identify examples where patch agents are used mainly for environment variables (e.g., forest fire–type models).
- Replace those patch agents with one or more PropertyLayers attached to the grid.
- Update the model step logic to read/write from the property layer instead of agent attributes.
- Ensure the simulation behavior remains the same as the original example.
The motivation is mainly to:
- align examples with newer Mesa patterns (especially as the project moves toward Mesa 4),
- reduce unnecessary object overhead when cells are just storing simple state,
- and show new users how PropertyLayer can be used for environment data.
Before trying to work on something like this, @jackiekazil @EwoutH I wanted to check:
- whether this direction makes sense for the examples repository,
- and if there are particular models where this approach would be recommended or discouraged.
Contributor guide
Research direction
Start by inventorying the examples that use stationary patch agents, beginning with the forest fire model and its TreeCell agent, then compare their state needs with Mesa's PropertyLayer API. Confirm with maintainers which models should change and verify that each migrated example preserves its original simulation behavior and teaches the intended pattern.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- developer-experience
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100