Modelly Core Examples#

This repository contains a curated set of classic agent-based models implemented using Modelly. These core examples are maintained by the Modelly development team and serve as both demonstrations of Modelly’s capabilities and starting points for your own models.

Overview#

The examples are categorized into three groups:

  1. Basic Examples - Simpler models that use only stable Modelly features; ideal for beginners

  2. Advanced Examples - More complex models that demonstrate additional concepts

  3. Behaviour Examples - Models built on the behaviour building blocks (modelly.behaviour): meta-agents and continuous states

Basic Examples#

The basic examples are relatively simple and use only the core building blocks: agents, spaces, scenarios, data collection and the browser visualization. They are good starting points for learning how to use Modelly.

Boltzmann Wealth Model#

Completed code to go along with the tutorial on making a simple model of how a highly-skewed wealth distribution can emerge from simple rules.

Boids Flockers Model#

Boids-style flocking model, demonstrating the use of agents moving through a continuous space following direction vectors.

Conway’s Game of Life#

Implementation of Conway’s Game of Life, a cellular automata where simple rules can give rise to complex patterns.

Schelling Segregation Model#

Modelly implementation of the classic Schelling segregation model.

Virus on a Network Model#

This model is based on the NetLogo Virus on a Network model.

Advanced Examples#

The advanced examples are more complex. They are good starting points for learning how to build more complex models.

Epstein Civil Violence Model#

Joshua Epstein’s model of how a decentralized uprising can be suppressed or reach a critical mass of support.

Demographic Prisoner’s Dilemma on a Grid#

Grid-based demographic prisoner’s dilemma model, demonstrating how simple rules can lead to the emergence of widespread cooperation – and how a model activation regime can change its outcome.

Sugarscape Model with Traders#

This is Epstein & Axtell’s Sugarscape model with Traders, a detailed description is in

Chapter four of Growing Artificial Societies: Social Science from the Bottom Up (1996).

The model shows how emergent price equilibrium can happen via decentralized dynamics.

Wolf-Sheep Predation Model#

Implementation of an ecological model of predation and reproduction, based on the NetLogo Wolf Sheep Predation model.

Behaviour Examples#

These examples use modelly.behaviour (meta-agents, continuous states and thresholds) and modelly.time.signals. Those packages follow semantic versioning like the rest of Modelly; the tram model still lives in the experimental/ example folder.

Alliance Formation Model#

Demonstrates modelly.behaviour.meta_agents: agents form alliances through a game-theoretic process, and the resulting alliances become meta-agents that can themselves form higher-level alliances.

Tram Route Model#

Demonstrates continuous states and thresholds: a tram accelerates, coasts, brakes and dwells its way along a route, with every transition solved for analytically and scheduled on the event queue rather than polled for on each tick.

Spatial Examples#

These examples use the geospatial space (modelly.space.geo, the geo extra) and the dynamic and multilayer networks (modelly.space.networks). Their data are generated, so they run offline.

Commuting City#

Residents from a synthetic population commute across city zones on a street network, choosing workplaces by a gravity rule and routing around congestion.

Layered Epidemic#

An age-structured SIR epidemic on household, school and work layers, with school closure as a change of one layer’s weight.

Language-Model Agent Examples#

This example uses modelly.llm. It runs offline with a fake provider and replays from a bundled response cache, so it needs no API key.

Opinions of Persona Agents#

Two hundred citizens with personas debate a protected bike lane on a small network; each decision goes through the reproducible modelly.llm client.