Skip to main content

Install Emergent

Build your first simulation

A simulation in Emergent has four steps:
  1. Create an AgentModel
  2. Define an initial data function — what state does each agent start with?
  3. Define a timestep function — how does each agent update?
  4. Run the simulation

Step 1 — Create the model

By default this creates a model with 3 nodes on a complete graph. You can customize both:

Step 2 — Define the initial data function

Each node receives the return value of this function as its starting data. The function receives the model as its only argument.
Register it on the model:

Step 3 — Define the timestep function

This function is called once per timestep and should mutate node data on the graph. Use model.get_graph() to access the underlying NetworkX graph.
Register it on the model:

Step 4 — Run the simulation

Option A — Run to convergence Emergent can automatically stop when a tracked variable stabilizes within a given standard deviation threshold:
Option B — Run a fixed number of steps

Complete example

Next steps

AgentModel concepts

Deep dive into parameters, graphs, and convergence.

Graph structures

Choose the right graph topology for your simulation.