Skip to content

Conversation

@Mallory3125
Copy link

Summary

This PR adds the Painted Desert Challenge example adapted from NetLogo to mesa-examples. It demonstrates emergent sorting behavior and self-organization using Mesa agents and Solara visualization.

Motive

The Painted Desert Challenge model is a valuable addition to Mesa as it:

  • Illustrates emergent behavior: Shows how simple local agent rules lead to complex global patterns (sorted colored chip piles).
  • Demonstrates self-organization: Agents organize their environment without central coordination, merging smaller piles into larger ones.
  • Teaches decentralized systems: No single agent is in charge, yet the system as a whole accomplishes a sophisticated task.
  • Showcases Mesa’s spatial capabilities: Uses OrthogonalMooreGrid with property layers for chip colors, and Solara-based visualization for dynamic spatial modeling.

Implementation

The model simulates chip collector agents (representing termites) moving on a grid with colored wood chips, sorting them into distinct piles by color.

Model Structure:

  • ChipCollectorModel (painted_desert/model.py):

    • Initializes a grid with patches (cells) and a pcolor property layer for chip colors (0 = empty, 1+ = colored chips).
    • Populates the grid with chips based on density and creates agents at random positions.
  • ChipCollector Agent (painted_desert/agents.py):

    • Behavior rules:
      1. find_chip: Wander until finding a chip of assigned color, pick it up, and move away.
      2. find_new_pile: Locate another chip of the same color to identify a pile.
      3. find_empty_spot: Deposit the chip near the pile in an empty adjacent cell.
      4. wiggle/get_away: Random movement functions for exploration and relocation.
  • Visualization(app.py):

    • Renders agents (white when empty-handed, colored to match carried chips) and chip patches.
    • Adjustable parameters via sliders: grid size, chip density, number of agents, and number of chip colors.

Usage Examples

To run the example:

solara run examples/painted_desert/app.py
painted_desert_screenshot

@EwoutH EwoutH requested review from quaquel and tpike3 January 14, 2026 19:32
@EwoutH
Copy link
Member

EwoutH commented Jan 14, 2026

Thanks for the PR!

@quaquel could your review the use of the discrete grid in this example model?

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