Chapter 4 - Examples of ABMs built with Mesa#
Video overview
This short video previews the five Mesa models explored in Chapter 4.
With your first model built in Chapter 3, this chapter puts Mesa to work on four classic agent-based models, then hands you a fifth to extend on your own.
Learning objectives
By the end of this chapter, you will be able to:
Build and run classic agent-based models in Mesa, including a simple economy, the Game of Life, traffic, and a virus spreading on a network (Models 1–4).
Work with different environments, from regular grids to networks, and see how structure shapes the resulting behaviour.
Collect model and agent data with Mesa’s DataCollector, and run parameter sweeps with batch runs.
Visualise model dynamics and interpret the emergent patterns they produce.
Extend and experiment with each model by completing its interactive tasks and exercises (Model 5).
This chapter presents a set of simple, focused models that consolidate the agent-based modelling (ABM) concepts and Mesa features from Chapter 3. The models differ in their grid structures and levels of complexity, ranging from simple spatial grids to network-based environments, and each one highlights a particular Mesa feature. Every model is structured in two parts: an introduction to the model and its learning objectives, followed by interactive tasks and exercises that ask you to reflect on model behaviour, discuss findings, and extend the code.
A wealth-exchange model, focusing on the DataCollector and visualisation.
The classic cellular automaton, focusing on agent behaviour and visualisation.
A one-lane traffic model, focusing on the DataCollector and batch runs.
Disease spreading over a network, focusing on agent behaviour and the DataCollector.
Speeding up a model by scheduling events instead of activating every agent each step.
Begin with Model 1, the simple economy, and work through the models in order.