Skip to content

Add dormant_alliances example demonstrating MetaAgent lifecycle features #459

@gargi025

Description

@gargi025

Summary

This proposes adding a new example dormant_alliances to demonstrate the new
MetaAgent lifecycle features being added in mesa/mesa#3684.

What it models

Countries (agents) form alliances (MetaAgents). Each step, countries lose power
from attrition. When a country's power hits zero it is defeated and removed. If
an alliance loses more than half its founding members, it goes DORMANT — suspended
but not destroyed. Dormant alliances can reactivate if they recruit enough
unaffiliated countries to recover.

Features demonstrated

Feature Where used
MetaAgentState (ACTIVE / DORMANT / DISSOLVED) Alliance.step()
deactivate() Triggered when >50% of founders are defeated
activate() Triggered when dormant alliance recruits enough members
on(signal, handler) Alliance registers _on_member_defeated
emit(signal, ...) CountryAgent fires "member_defeated" on defeat
cascade_step = True Alliance steps all members automatically
to_dict() Used by DataCollector for structured logging

Files

examples/dormant_alliances/ contains init.py, agents.py (CountryAgent + Alliance), model.py (DormantAlliancesModel), app.py (Solara visualization), and README.md.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions