Deepgrain Foundry: move from a claude.ai artifact to a local repository

The game as of artifact version 24, ready for local development with
coding agents.

- Source split from three large files into 52 small ones under src/sim,
  src/render and src/ui, joined in the order in src/manifest.json by
  build.py. The joined code is unchanged apart from comments; every
  headless suite gives the same output, and screenshots in both looks
  are pixel-identical to before.
- Light tidying with no change in behaviour: one movement scan loop,
  shared hazard-stripe and belt shader helpers, unused code removed, a
  shared check helper for the test suites.
- World files can be exported as an ordinary download outside claude.ai.
- Tests: broken old scripts removed, experiments moved to tools/,
  test/run_all.py added. Tools: shot.py (repeatable screenshots),
  where.py, map.py.
- Docs: AGENTS.md, CLAUDE.md, NOTES.md (the owner's to-do inbox),
  docs/PROJECT_MAP.md, DESIGN.md, TESTING.md, systems notes, the
  owner's requests and an agent log.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K9kLmYADKSEjuwUN3rFxDA
This commit is contained in:
2026-10-23 16:05:31 -04:00
co-authored by Claude Opus 5.5
commit b270c4e818
97 changed files with 11710 additions and 0 deletions
+86
View File
@@ -0,0 +1,86 @@
# Dig tools: decisions
Decided 2026-10-19. The resonance drill went in on 2026-10-20, and the same day its widths were
reworked so that each one has a use. Handling of stray bits was added on 2026-10-22 and revised
the same day: rock too hard for the bit never crumbles, and world generation makes no tiny hard
specks instead. The code is in `src/sim/drill.js` and `src/sim/worldgen.js` (`clearHardSpecks`).
## Main tool: Resonance drill
It replaced the old "darken and delete" drill cursor.
- **How it works.**
- Holding the button sends pulses from the bot toward the cursor.
- Each pulse is a fan of rays leaving the whole face of the bot, so rock right beside the bot
is hit too.
- Rock a pulse passes through shakes: it pales, shivers, and shows cracks that grow finer as
it nears breaking. Then it shatters into its loose grains.
- The pulse loses energy as it goes deeper.
- **Pulse width** is changed on the fly with Q/E while the drill is selected. Each width has its
own reach.
| Width | Shape | Reach | Good for |
|---|---|---|---|
| Narrow | A beam a little wider than the bot | ×1.45 the bit's reach | The fastest and longest tunnels, big enough to fly down |
| Medium (default) | A cone | ×1 | General digging |
| Wide | A broad fan | ×0.7 | Opening the most rock per second, but only close to the bot |
Measured with a stone bit, moving with the face: narrow tunnels about 13 grains a second,
medium about 9, and wide about 7. Wide opens the most rock per second.
- **Tuning** (R over a material, R again to untune): the pulse passes through everything else
and shatters only that material.
- **Loose grains** a pulse passes are jostled back toward the bot, so a shattered vein pours out
of the wall and a bore clears itself.
- **Hardness and base reach** still come from the cast bit tiers: stone, copper, iron, steel.
- **Built blocks, machines and molds** soak up pulses unharmed and shield what is behind them.
- **Trees** in the path come apart into wood chunks (not with a tuned pulse).
- **The bot** never moves loose material. Sand, rubble and water pass straight through it.
### Stray bits
Most leftover obstacles were specks of rock too hard for the current bit, such as iron ore or
granite inside stone when you have a stone bit.
The rule: **rock too hard for your bit never breaks, crumbles or comes loose, however small.**
Crumbling it into ore would let players get ore without the right bit, and confuse them.
Crumbling it into stone would lose ore.
These keep specks out of the way instead:
- **World generation makes no tiny hard specks.**
- Iron and zinc come in fewer, chunkier veins, with the same total ore.
- Any piece of 30 grains or fewer that is harder than the rock around it becomes that rock
(`SPECK_MIN`).
- Older saves get this cleanup once, when loaded.
- Basalt dikes in the granite were removed, because they walled off parts of it.
- **Cut-off pieces fall apart.** When a grain breaks and leaves a piece of natural rock of 16
grains or fewer touching nothing else, the piece falls into its loose grains. This only happens
if the bit could break every grain of it. A piece with too-hard rock in it stays whole.
- **Thin rock breaks faster.** Corners, nubs and slivers with open space on two or more sides
shake apart quicker than a flat face.
- **The bot slips around lips.** Flying straight into a ledge a grain or two deep, it slides past
instead of stopping dead. A real wall still stops it.
- **Tuned pulses** do none of this; they only touch the tuned material.
Upgrade ideas, not built yet:
- Amplifier: reaches deeper per pulse.
- Tuning fork: tuning could become an upgrade instead of being there from the start.
- Harmonics: breaks granite, then basalt (could replace the bit tiers).
The owner wants the whole upgrade system redesigned. The bit mold does not really fit a
resonance drill (see NOTES.md).
## Later: Grav pick (upgrade tool)
A gravity field locks onto a lump of rock, pries it out whole and carries it. It then crushes it
into grains or throws it, into a hopper or a furnace.
It is too slow for normal digging, but useful for selective digging and for moving material.
Upgrades:
- field coil: bigger lumps;
- stabilizer: range;
- compressor: crushes faster;
- sling: throws.
## Late game: Mining charges
Placed charges that blast a radius and throw debris, for digging out big areas.
## Concept art
Animated concepts for both tools are on the "Dig Tool Concepts" design canvas in claude.ai (not
in this repository).
+101
View File
@@ -0,0 +1,101 @@
# Waste rock and moving liquids
Built 2026-10-22; the uses for stone and sand were added 2026-10-23.
- Code:
- `src/sim/processors.js` (Refiner, Stone cutter, Silo);
- `src/sim/pipes.js`;
- `src/sim/conveyors.js` and `src/sim/machine-tick.js` (belts and tubes);
- `src/sim/economy.js` (prices, builders' orders).
- Tests: `test/t_pipes.js`, `test/t_stone.js`, `test/t_conveyors.js`.
## Refiner (machine, 3×3 blocks, $120)
An open hopper over a grinding floor. Grains that reach the floor are ground at about 30 a
second and come out of a chute under the machine. If the space under the chute is blocked, it
stops and says so.
For each grain ground, it tries for one grain of ore, in the order below. If none turns up, half
the time a grain of fine sand comes out; otherwise nothing does. So a refiner roughly halves a
pile of waste.
| Input | Chances of ore per grain |
|---|---|
| Stone rubble | copper ore 2.5%, coal 2%, iron ore 1.5%, tin ore 0.6% |
| Granite rubble | iron ore 2%, zinc ore 1.2%, copper ore 1%, silver ore 0.2% |
| Basalt rubble | iron ore 3%, zinc ore 1%, gold ore 0.3% |
| Gravel | iron ore 3%, copper ore 2%, tin ore 1%, zinc ore 0.3% |
| Sand | tin ore 1%, iron ore 0.8%, gold ore 0.15% |
| Dirt | clay lumps 8%, coal 1%, copper ore 0.8%, acorns 0.3% |
Measured: 400 stone rubble gave 28 grains of ore and 190 of sand. Anything it cannot grind,
such as ore, coal or liquids, drops straight through.
**Re-refining sand is allowed** (decided 2026-10-23). The sand a refiner puts out can go
through another refiner.
- Each pass gives about 2% ore and returns about 49% as sand.
- Refining it again and again, as with stacked refiners, eventually turns all the sand into
about 3.8% more ore per grain of sand. That is roughly 27% more ore from rubble overall.
- The owner kept it because it pays less than making glass. Players will do it when they need
ore rather than money.
## Pipes, pumps and outlets (blocks)
- **Pipe ($8).**
- Pipes are thin. Sand, water and anything else loose fall past them, so a run of pipe never
dams anything.
- Pipes, pumps and outlets that touch join into one line, which holds 16 grains per block.
Its contents are kept as a count, not simulated grain by grain.
- Taking a pipe back spills its share where it stood.
- **Pump ($70).**
- Draws liquid in at the tail of its arrow, from up to 3 grains away.
- Pushes it into the line through its other sides, at about 60 grains a second while there is
room.
- Takes only liquids cooler than 500°C (water, molten tin, zinc, brass and bronze), and one
liquid per line.
- F turns it on and off. Pumps and outlets are solid blocks.
- **Outlet ($15).** Pours the line's liquid out of the side its arrow points to, up to 2 grains a
tick, wherever there is room. F opens and closes it.
- **Water accounting.** Water in pipes counts in the world's water total, so the weather never
sends rain to replace it. Pipe contents are saved.
## Belts and screw tubes
- A heap on a belt moves as one: the whole stack, up to 96 grains deep, steps along together
instead of only its bottom layer. The owner reports that big piles still only move at the top
(see NOTES.md).
- Screw tubes run at belt pace, moving every other tick.
- A horizontal tube fed from a full hopper moves about 100–110 grains a second.
- A belt under its mouth keeps up, carrying a stream 3–5 grains deep at about the same rate.
- A vertical lift brings up about 40–60 grains a second.
- `tools/experiments/flow.js` measures these.
## Uses for stone and sand
- **Glass bricks.**
- Sand melts to molten glass in a fan furnace (peak about 2000°C measured).
- Cast in an Ingot mold, it knocks out as glass bricks, worth $14 each.
- Glass bricks build glass wall blocks. Glass is too brittle for a bit mold.
- **Stone cutter** (machine, 2×2, $90).
- A saw under a hopper. Every 8 grains of stone rubble become one stone brick, which drops out
underneath; put a belt under it.
- Anything else falls straight through.
- **Cut stone walls.**
- 2 stone bricks per block. They look like coursed masonry and stand more heat than rough
stone (they melt at 1450°C).
- Taking one back returns the bricks.
- **Silo** (machine, 3×6, $180). It was made to look like a real silo, not a magic black hole.
- A steel bin on legs, with a roof hatch, a sight-glass gauge, a ladder, and a cone with a
slide gate.
- Holds up to 4,000 grains of one loose material; drop grains in through the hatch.
- F opens the gate, letting about 60 grains a second out underneath; F again shuts it.
- It cannot be taken down or cut while it holds anything. Its contents are saved.
- **Builders' orders.**
- About 30% of new orders come from Builders. They want 400–1,500 rubble, 300–1,000 gravel,
300–900 sand or 20–80 stone bricks.
- They pay 4–6 times the market price for loose material, and 3–4 times for bricks.
- Ordinary buyers never ask for rubble or gravel.
- **Market prices.** Rubble sells for $0.02 a grain and gravel for $0.03 at the dock; a stone
brick sells for $0.60. Dirt earns nothing.
## Other ways to deal with stone
- The trade dock takes anything that drops through it, so it also works as a dump.
- Wall blocks store rubble compactly (16 grains each); take them back to get the rubble.
- The vacuum can blow rubble into old shafts as backfill.
- Not built yet: concrete.