Skip to content

mmgrt/lawbox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LAWBOX

A pocket universe you can ruin, beautifully.

You are not a player here. You don't steer a character — you edit the laws of a tiny universe and watch a swarm of motes come alive in ways nobody scripted. Flip on named laws, watch the swarm obey, and combine them to discover named phenomena you collect in an Almanac. Discover enough and new laws wake up. The gray little cosmos slowly fills with colour and sound the more you meddle. No score. No timer. No way to lose.

Why this exists

Honestly? Someone was bored.

They asked a couple of AI agents to discuss and invent something fresh — out of this world — and then build it, vanilla HTML/CSS/JS, no frameworks. The agents argued it out in a shared turn-based message log (a "moot"), converged on the idea of a reality-editor instead of yet another character-you-steer, and shipped v1. v1 was pretty but goalless — so the human pushed back: "it lacks a goal, progress, more laws." That feedback became v2: the Almanac, unlockable laws, greater wonders, and soft cosmic requests. This repo is the result.

Play

Open index.html in any modern browser. Double-click works — no server, no build step, no internet connection required.

  1. Click OPEN THE BOX.
  2. Click a law at the bottom to wield it — up to three at once (a fourth replaces the oldest).
  3. Scroll a glowing law to push its intensity up or down.
  4. Click the empty space to scatter light for the Hungry motes to chase.
  5. Combine laws and a phenomenon gets a name — most are generated from your exact mix, so the space of wonders is effectively endless. Two laws make a discovery; three make a rarer greater wonder.
  6. Open the Almanac (top-right) to see which named wonders you've found and how close you are to waking the next law.
  7. Pin a state you love to the shelf. Everything you discover persists in localStorage, so your universe greets you when you come back.

The laws

Five are awake from the start. Three more unlock as you discover wonders.

Law Glyph What it does Unlocks at
Gravity motes tumble toward wells / your cursor start
Hunger motes chase the light-crumbs you scatter start
Echo every motion leaves a late ghost start
Orbit nearest neighbours become suns and moons start
Mischief a few motes defiantly disobey the rules start
Bloom stable clusters blossom into petals 4 wonders
Memory the swarm drifts home toward fossil shapes 9 wonders
Time warps the clock — dreamy slow-mo to frantic 15 wonders

The loop

Discover → collect → unlock → aspire. Wonders fill the Almanac; the Almanac's progress wakes new laws; new laws open new combinations and new wonders. Every so often the dark softly wishes for a pattern ("make something that circles while it eats") — fulfil it however you like, or ignore it and keep sandboxing. The goal emerges from mastery, never from chores.

Under the hood

Pure vanilla — classic scripts on a single global namespace (window.LAWBOX), no modules, no bundler, file://-safe. Each file owns one concern behind a small locked contract:

  • laws.js — law definitions, marquee combos, the procedural namer
  • sim.js — mote physics; reads active laws, writes a numeric snapshot
  • render.js — canvas drawing only (pixels in, nothing else out)
  • audio.js — WebAudio ambient layers + discovery stings
  • main.js — the conductor: rAF loop, UI, unlocks, Almanac, requests, memory

main.js also carries self-contained fallbacks for the other modules, so the toy can never hard-break even if a file fails to load.

Tests

node tests/lawbox-contract.test.js     # module contract: laws / sim / audio surfaces
node tests/integration-smoke.test.js   # full pipeline driven through a stubbed DOM
node tests/browser-smoke.js            # real headless-browser load (needs Edge/Chrome)

browser-smoke.js is optional and skips cleanly when no browser is available; set LAWBOX_BROWSER to point at a specific binary if needed.

Tip: add #demo to the URL for a hands-free attract mode.

How it was made

LAWBOX was designed and built collaboratively by two AI agents coordinating in a shared turn-based "moot," under the direction of one bored human:

  • Claude (Anthropic) — concept coordination, the shell, canvas renderer, and the conductor (index.html, styles.css, render.js, main.js).
  • Codex (OpenAI) — the simulation and rules (laws.js, sim.js, audio.js) and the contract/browser test harness.

The work was partitioned by file so the two agents never edited the same file, talking only through a small agreed contract. Credit shared, plainly and without overclaiming.

License

MIT © 2026 mmgrt — use it, remix it, ruin your own universe with it.

Releases

No releases published

Packages

 
 
 

Contributors