mesa-examples
mesa-examples copied to clipboard
fix: add adaptive risk agents example with relative-import tests
Thanks for opening a PR! Please click the Preview tab and select a PR template:
- 🐛 Bug fix
- 🛠 Feature/enhancement
Summary
This PR adds a new diagnostic example demonstrating adaptive risk-taking agents.
Each agent:
- chooses between safe and risky actions,
- maintains a short memory of past outcomes,
- adapts its risk preference based on recent experience.
The example is intentionally minimal and uses only core Mesa primitives.
Motivation
Many adaptive agent models in Mesa end up concentrating:
- decision-making,
- action execution,
- memory updates,
- and learning logic
inside a single agent.step() method.
This example is designed to make that complexity explicit, rather than hide it, and to serve as a concrete, example-first input for discussions around richer behavioral abstractions in Mesa.
Scope
- New example only (no API or behavior changes)
- Uses current Mesa patterns (no deprecated schedulers, no DataCollector)
- Relies on
model.randomfor reproducibility - Includes minimal smoke tests to ensure the model initializes and steps
Testing
- Added smoke tests verifying:
- model initialization
- stepping without errors
- Tests intentionally do not assert outcomes or dynamics
Notes
This example is exploratory and educational by design. It does not propose new abstractions or patterns, but highlights current modeling constraints through a working example.