Sign in to see your models

Save models to your account and pick up where you left off on any device.

Sign-in is temporarily unavailable. Please try again later.

Agent-based modelling in the browser

Agent-based models
you can read.

MathPets is a small language in the NetLogo tradition: patches on a grid, agents that move across them, links between agents, and rules that run each tick. Most models in the library are under 100 lines.

Runs in the browser. No account needed.

fire.petOpen model
world:  x: -60..60  y: -44..44  topology: box params:  density = slider(62, 0..100) monitors:  burned-trees = count patches where burned  burning-trees = count patches where burning  living-trees = count patches where tree patches:  state: empty | tree | burning | burned = empty setup:  patches:    state := tree chance density else empty     where (tree and px = min-x):      state := burning step staged:  patches:    where burning:      state := burned     where (tree and any neighbors4 where burning):      state := burning stop when (count patches where burning = 0) 
step
0
burning
0
trees
0
burned
0

The complete Fire model, 32 lines, running beside its source.

Write

A model is one .pet file with named sections: world, params, patches, pets, setup, step. Sliders and readouts are declared in the file, so there is no interface to wire up.

Read the language reference

Run

Models compile and run in the browser. Each run has a seed, so it can be replayed exactly. Inspect any patch or agent on the board, and change parameters while it runs.

Browse the models

Edit

Every model in the library opens with its source. Change a rule or a colour, apply it to the running model, and keep your version.

Follow the quickstart

From the library

Four models, running live

Scroll to switch between them. Each one opens in the studio with its source.

View all models
01

Flocking

Reynolds' boids. Each bird turns away from a neighbour that is too close; otherwise it turns toward its neighbours' average heading and their centre.

No bird leads and nothing is global. Flocks form, split and merge, and leave one edge of the torus to come back on the other.

Open model
02

Ants

Ants that find food carry it home and drop a chemical on the way. It diffuses and evaporates, and searching ants follow its gradient.

Trails form to the nearest food pile first and fade once it is empty. The three piles are usually emptied in order of distance.

Open model
03

Lenia

Bert Chan's continuous Game of Life: cells hold values between 0 and 1, neighbours are weighted by a ring-shaped kernel, and a smooth growth rule replaces birth and survival.

The seed settles into Orbium, a glider that keeps its shape and crosses the board at about half a cell per tick. Raise sigma from 0.016 to 0.02 and it splits until rings fill the board.

Open model
04

Wolves and sheep

Sheep eat grass, wolves eat sheep, and grass regrows after a delay. Moving costs energy, births are random, and an animal dies when its energy runs out.

The populations cycle, with wolves lagging sheep. Switch model-version to sheep-wolves (no grass) and the cycles usually end in extinction.

Open model

Free course

A short course in
agent-based modelling

6 units, from patch rules to network dynamics. Lessons are narrated over a live model, with exercises that have you run it, tune it and edit its code.

  • Narration synced to the model on screen
  • Exercises on the board and in the code
  • A short checkpoint at the end of each unit
Units
6
Lessons
27
Self-paced
≈ 120 min

Documentation

The language reference, a quickstart that builds Fire and Ants line by line, and the physics, sound and X libraries.

Read the docs

Connect an AI

Connect an MCP client such as Claude Code to the model you have open. It can search the docs, render previews and edit the draft, and its edits are highlighted as they land.

Set up a connection

Open-source core

The parser, compiler, deterministic runtime and VS Code extension are Apache-2.0 on GitHub. You can compile and run model files without this site.

Read about the core