# Grain Garden: Six Terraces of Falling-Sand Puzzles

> Paint soil, water, seeds, ember, magma, frost, acid and more into a live falling-sand simulation and solve six terraces, in one offline HTML file: drain a reservoir onto a dry bed, grow sprouts past a line, burn through a log gate, melt an ice plug, seal a leak and contain an acid spill, or play in a free garden. No terrace solves itself, and a gauge shows how close you are. Ported from sandspiel by Max Bittker (MIT), keeping its Rust/wasm cell simulation, with a new layout, palette, renderer and goals.

- Type: Lab Skill (downloadable Agent Skill)
- Category: [Game creation](https://www.sandbase.ai/skills/games)
- Version: 0.1.1
- Runs online: yes
- Page: https://www.sandbase.ai/skills/games/grain-garden

## What you get

Bring the terraces and their goals, and optionally the palette, the element tray, the layout and the text. The Skill returns a downloadable Skill (the simulation game project with its wasm core, a customize guide, headless verification) and one playable example run.

## Install

Download the Skill package from https://www.sandbase.ai/skills/games/grain-garden (sign-in required), unzip it into your agent's skills folder, then ask your agent to use it:

```text
/grain-garden make a falling-sand puzzle game with <your terraces> and <your goals>
```

## How it works

1. **Create the garden project** Grain Garden starts with node scripts/new-project.mjs --out my-garden and npm ci. references/customize.md maps each request to files and symbols. Most start in src/config.js under LOOK, ELEMENTS, BRUSHES and STR, while levels and goals live in src/game/levels.js and src/game/goals.js. A prompt such as "Use grain-garden to make a falling-sand puzzle with flooded rice terraces" sets the theme.
2. **Paint elements on terraces** Pick an element in the bottom tray and drag on the canvas. Water pools, sand piles into slopes, seeds sprout in wet soil, embers creep along a wood fuse and acid eats everything but brick. Six terraces each state a goal, such as guiding water to the dry bed, and a gauge fills as you approach it. A Rust cellular automaton compiled to WebAssembly runs the 288 by 192 grid.
3. **Shoot every terrace** npm run build:single writes dist-single/index.html, at most 8 MiB, with the wasm inlined as base64 and no network, fonts, storage or workers. npm run shoot needs local Chrome and covers painting, opening a wall, water reaching the bed, sprouting, burning, melting, acid, breeze, undo, reset and a phone game. Check that each terrace stays unsolved after 900 ticks without input.

## FAQ

### Can I add an element to Grain Garden?

Grain Garden adds an element only if its wasm core already simulates it. The engine knows more species than the twelve in the tray, such as Oil, Fungus and Mite; add an entry to ELEMENTS in src/config.js and the tray and palette pick it up. New physics need a rebuilt wasm from the Rust source in crate/.

### How do I make a Grain Garden level?

Copy a block in src/game/levels.js. Grain Garden levels draw the scene in sim cells with setup(paint) and name a win check in goal, such as speciesInRegion, speciesAbove or speciesBelowCount with optional holdTicks. Then add a verify.json step that solves it, because goal regions count cells and level switches inside a step break comparisons.

### Does Grain Garden save my garden?

No. Grain Garden has no save beyond one Undo stack, which keeps one snapshot per stroke up to 50 deep. Inside the sandbox a reload starts over. An open garden mode drops the goals for free play, and Reset restores the current terrace.

### Is Grain Garden a fluid simulation?

No. Grain Garden is a cellular automaton on a grid of cells, and its breeze tool is a splat, not a GPU fluid solver. Very fast strokes can leave gaps when they exceed the interpolation budget, so use a larger brush. It does not support multiplayer or shared canvases.

### Does Grain Garden call a model?

No. Grain Garden loads nothing and calls no model; an agent edits the code locally, so it is free to run. Rendering is raw WebGL, and WebAssembly compiles inside the page under wasm-unsafe-eval. The simulation core keeps its MIT licence file in the package.

### Does Grain Garden work on phones?

Yes. Grain Garden lets a finger drag paint on a phone, and the tray and header buttons are at least 44 px. It is verified under touch emulation, not on real devices. The UI ships in English and Chinese using the system font stack.

## Examples

- Grain Garden falling-sand puzzle (scene)
- Dry Bed Terraces (video)
