Documentation
MathPets language
MathPets is the source language for the models that run in this Studio. It is small on purpose: declarations describe what exists, lifecycle sections describe how it changes, and the patch grid does most of the heavy lifting.
A MathPets file is mostly declarations followed by a setup section and one or more step sections. The compiler turns that source into browser-runnable code, but the model file remains the readable contract. The same file you hand to a teammate is the file the Studio runs.
Each chapter below covers one surface of the language. Essentials is the shared vocabulary; the three agent chapters are independent and can be read in any order, depending on what you are modeling.
world: x: -25..25 y: -18..18 topology: box params: density: number = slider(62, 0..100) patches: state: empty | tree | burning | burned = empty setup: patches: state := if (random-float(100) < density) then tree 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)Chapter 1
Essentials
How a model file is laid out: declaration sections, types, expressions, control flow, defs, and the lifecycle. Read this first; the other chapters assume it.
Open chapter →Chapter 2
Patches
The grid agents. World bounds, topology at the edges, patch fields, neighborhood reporters, diffusion, and zone aggregates.
Open chapter →Chapter 3
Pets
Moving agents grouped by breed. Continuous coordinates, the patch under the pet, movement and sensing commands, breed queries, and actions.
Open chapter →Chapter 4
Graph
Links — first-class agents that connect pets. Directed and undirected breeds, network construction patterns, and traversal from either side.
Open chapter →