Creative coding / Simulation

Emergent Sandbox

A particle sandbox where simple attraction and repulsion rules create clusters, chasing loops and moving swarms.


I built Emergent Sandbox with Codex as an open-ended simulation for emergent behavior. Simple attraction and repulsion rules produce clusters, chasing loops, orbiting pairs and moving swarms. The program runs locally in the browser.

Emergent Sandbox showing clusters of amber, mint, lilac and pink particles alongside starting presets and a directed interaction matrix.
The Color islands preset: particles gather into clusters according to their attraction and repulsion rules.

The Color islands preset: particles gather into clusters according to their attraction and repulsion rules.

Changing the rules

An interaction matrix controls how two to eight particle colors respond to each other. The rules can be asymmetric: one color can chase another without being chased back. Live controls adjust force strength, interaction range, damping, gravity and optional Fibonacci distance bands, making it easy to explore how small changes affect the larger pattern.

Interacting with the scene

Grab, spawn or erase particles, paint solid obstacles, and explore the world with pan and zoom. Selecting a particle reveals the forces acting on it, while live measurements track clustering, color segregation, heading diversity and organized activity. These tools connect the visible patterns to the local interactions that produce them.

Repeatable experiments and automated exploration

Pause the simulation, advance one step or replay a seeded scene to examine how it develops. Background searches explore rule combinations for interesting patterns, and configurations can be saved, loaded or shared through JSON. This makes it possible to return to a setup and compare the effects of different choices.

  • TypeScript
  • Particle Simulation
  • Agentic Development
Next projectPresentations