Public API
aquarium-simulator publishes one module. Everything below is imported from the
package root — there are no subpath entry points, and nothing reaches past the
barrel.
| Property | Value |
|---|---|
| Package | aquarium-simulator, MIT |
| Format | ESM only, types included |
| Published | dist/ — the engine. The web UI is not part of the package |
| Runtime dependency | immer, and nothing else |
| Mutation | None. Every entry point returns a new state |
The shape of a session
Section titled “The shape of a session”Build a tank, advance it an hour at a time, act on it between hours, and read whatever you need off the state you were handed. The host owns the clock, the storage and the rendering.
import { createSimulation, tick, applyAction } from 'aquarium-simulator';
let state = createSimulation({ tankCapacity: 60 });
state = applyAction(state, { type: 'feed', amount: 0.5 }).state;
for (let hour = 0; hour < 24; hour++) { state = tick(state);}Capabilities
Section titled “Capabilities”| Capability | Key exports | What it gives you |
|---|---|---|
| Create a tank | create, Simulation, settle, DEFAULT_, DEFAULT_, DEFAULT_, DEFAULT_ | A tank from a capacity and whatever devices you name. Everything else falls back to a default, and a non-finite or impossible input throws rather than settling. Its optics and plants should be the ones you tick with: the first day’s light is read through them and seeded plants stocked on them, the shipped ones by default. settle settles the passive readings after writing equipment or optics |
| Start from a preset | PRESETS, DEFAULT_, get, create, preset, Preset, Preset | The five shipped tanks; create builds one on the tunables you will tick with |
| Seed a starting state | Preset, Tank, Seed, Seed, Seed, Seed, Seed, cycled, cycled, cycled, cycled, cycled, cycled, starting | Open a tank part-way through its life — a colony, a bed, a roster. The cycled* helpers answer what a month-old tank of a given build carries |
| Advance time | tick, get, get | One tick is one hour. tick is pure: same state and config in, same state out |
| Act on the tank | apply, Action and the per-verb action types, Action | The twelve husbandry verbs — feed, water change, top-off, dose, root tab, trim, scrub, add and remove plants and fish, sell fry — dispatched through one call; alone, scrub and add take the plants config |
| Ask before acting | can, can, can, can, can, on, check, check, stocked, get, get, get | Whether the tank can be dosed, tabbed, stocked or trimmed — and what a scrub would take off the glass — asked before the verb runs, so a control greys rather than fails. can asks whether its footprint fits the floor left, can whether the trim names a plantable target and a plant over it; check answers with the floor free, the floor needed and add’s refusal. get meters by the Fertilizer handed it — pass the config’s, the one dose mixes to. The other refusals — a water change out of range, a top-off on a full tank, a non-positive feed, an id that names nothing, selling with no fry — carry no preflight; the action’s message reports them |
| Use the engine’s own option sets | WATER_, MAX_, MAX_, MIN_, is, STOCKED_, MAX_, is | The values an action legitimately takes, so a caller offers choices the engine will accept |
| Read the state | Simulation, Tank, Resources, Environment, Equipment, Plant, Fish, Clutch, Algae, Blooms, Alert, quiet | The whole tank as plain data. Nitrogen compounds and nutrients are stored as mass in mg, KH and GH as mg of CaCO₃; dissolved gases as mg/L. A plant’s and a bloom’s budget is a Flora, a fish’s a Deb, and a fish’s load a Toxin in ppm; food, waste, a fish’s gut and the bed’s mulm are Organics |
| Read it in display terms | Resource, All, Resource, Resource, Food, Waste, get, get, get, get, get | Per-resource metadata — bounds, unit, display precision — so a host formats a reading the way the engine means it. The registry holds every scalar stock; the organic pools — food, waste and mulm among the Resources — move as Organics, and Food and Waste carry only a unit and a precision |
| Read pH | get, carbonate | pH is not stored: it is derived from CO₂ and KH, and these read it off a tank or off any pair of values |
| Understand a number | compute, compute, compute, compute, build, build, build, build, plant, Vitality, Vitality, Algae | The per-factor breakdown behind a condition score — which stressors charge, which benefits pay, how much, and what the reserve repaired — off the hour the organism’s budget ran, a fish’s Fish or a flora’s Flora; plant is the nitrate a species takes harm past |
| Read a planting | read, Plant, canopy, Canopy, Light, size, unit, Planted, Unit, plant, leaf, rate, LEAF_, floor, floor, floor, plant, is | What each plant stands in — its size, height and leaf in cm² and rate units, read off a Unit (unit), PAR at its mean leaf and crown top, the day there against its rated day, and what took the lamp’s light on the way — and the planting’s floor cover, shade and light, and the share of its light each bloom takes. read builds the canopy once for the whole planting |
| Follow a flora’s budget | plant, unit, bloom, Flora, Flora, Flora, store, store, droop, droop, full, fill, flora, stocked, scale, offshoot, offshoot, offshoot, VIGOUR_ | Each kind’s parameters, and a unit’s at its vigour; each store’s fill, gap and Droop limit, the ruling one, its ceiling on full stores, and the fill an edge sits at; the organics a flora holds; a flora stocked, or a share of one; a plant’s offshoot — ready, how far built, its size — and the span its vigour is drawn within |
| Read any budget’s reserve | reserve, well, starvation, oxygen, NO_, Deb | How full an organism’s reserve stands and how well fed that leaves it, the share of its upkeep an hour left unpaid, and the oxygen pace and stress multipliers every budget takes |
| Follow a fish’s budget | fish, fish, fish, FISH_, fry, egg, fish, count, mature, deb, incubation, Deb, Deb, ready, pays, Fish | What a fish’s budget reads as — its weight, its size against grown length, the organics it holds and what a gram of them, an egg or a brood is made of, its maturity and life stage — its species’ parameters and incubation, and whether it spawns or pays toward a brood this hour |
| Follow a clutch | clutch, clutches | What a clutch’s eggs weigh, and which clutches still have a mother to carry them |
| Follow a hunted fish | predation, predator, prey | The damage its predators do a young fish an hour before hardiness, each predator’s weight on it, and how its exposure falls as it grows |
| Follow a fish’s load | water, TOXINS, Toxin, Toxin | What the water holds of each toxin a fish loads — the free share of its ammonia, its nitrite, its nitrate, in ppm — the levels every fish’s load moves toward. A Toxin is one figure each of them — a load, the load rates |
| Follow a feeder’s nutrients | species, form, form, bed, tank, plant, pool, nutrients, tissue, Feeder, Nutrient, Tank, Pool, Nutrient, Form | The water and the bed a feeder draws on, how much of its stores’ ask each form meets — nitrogen as ammonia, then nitrate — where it feeds, a plant by its form’s roots, and the grams a size of plant weighs |
| Follow the blooms | ALGAE, ALGAE_, Algae, Algae, Algae, EMPTY_, empty, is, map, habitat, habitat, place, Habitat, Habitat, REMOVED_, Bloom, bloom, column, Bloom, light, water, column, bloom, Light, Bloom, Bloom, bloom, coverage, bloom, bloom, bloom, bloom, spores, land, coverage, clear, thriving, allelopathy | Each kind and where it lives — its habitat’s size and the light over it — its coverage off its tissue and back, what it fixes and feeds at, its spores, and the exudates of thriving leaf per litre that lower its assimilation; the light each kind takes off a Bloom — green water in the water’s extinction, film as a coat on every leaf — its coverage at a place, a place laid bare, and the verb that takes each habitat’s bloom out |
| Build an organism’s factors | hardened, Vitality, Vitality | Scale a stressor list by 1 − hardiness before it reaches compute, which charges every factor as given and adds the points the reserve healed |
| Follow a fish’s feeding | appetite, gut, full, ration, reserve, Pace, tank | A fish’s appetite and what its gut holds at a pace — τ, ω and its load’s stress — the fullness under which its gut digests less than its budget can take up, the food whose assimilation pays the upkeep it owes, the reserve a gram of a food builds at a body’s composition, and the pace every fish in a tank runs at |
| Adjust the model | Tunable, Fertilizer, Nutrient, DEFAULT_ | The whole constant surface as one object. Pass a modified copy to tick and it takes effect that hour. A Nutrient is one figure each of NO₃, PO₄, K and Fe — a formula, a root tab, the bed’s store |
| Inspect the catalogs | FISH_, PLANT_, GROWTH_, growth, Fish, Fish, Plant, Plant, Growth, Growth, Fish | What each species is: tolerance bands, hardiness, growth, lifespan, breeding, and what one full unit of a plant’s growth form is |
| Read the flora law | Flora, plant, saturation, daily, flora, TISSUE_, shed, Flora | The traits a plant species and a bloom are both written in — plant reads a species into them — the PAR each saturates at and its rated day, the pace its tissue lives at, the grams in a rate unit of tissue, and the share low condition sheds and what losses leave as waste, a dead flora’s stores with it |
| Build and read equipment | FILTER_, FILTER_, SUBSTRATE_, SUBSTRATE_, SUBSTRATE_, SUBSTRATE_, HARDSCAPE_, HARDSCAPE_, create, POWERHEAD_, HEATER_, LIGHT_, LID_, get, get, get, calculate, calculate, scheduled, scheduled, daily, rescape, place, lift, reset, disturb | Every device catalog, and the functions that turn a device into the surface, flow and light the tank gets — by the hour and over the day — what a fresh bed of a type holds for roots, and what a bed leaks an hour |
| Size a tank | calculate, calculate, calculate, calculate | The geometry a capacity implies — depth for the light calculation, floor for the planting, glass area for the colony, slots for the scape |
| Run schedules | Daily, is, is, format | The start-hour-plus-duration shape every scheduled device uses, and the check for whether it is on |
| Watch for trouble | check, alerts, Alert, Alert, bloom, bloom, bloom, Bloom, water, PLANT_, BLOOM_, BLOOM_, bloom, FREE_, NITRITE_, NITRATE_, OXYGEN_, OXYGEN_, tolerance | The alerts a tick raises, one per kind of bloom among them; the lines the water level, each bloom — by the plants’ light it takes and its coverage, read as a Bloom — free ammonia, nitrite, nitrate and oxygen alert at, and the coverage a bloom shows from, and whether one does; how far hardiness carries a fish’s own edge past them; and where the O₂ benefit is full |
| Read the log | Log, Log, Log, Log, Log, Quantity, create, measured, liters, celsius, coverage, log, metric | The event stream a tick appends to, and the constructor for a host’s own entries. A line’s volumes, temperatures and a die-back’s coverage stay quantities — built with measured`…${liters(x)}…` — and log reads it in the host’s units, metric by default |
| Weigh organic matter | Organics, NO_, Organic, add, scale, at, food, Recipe, scarcest | Organic matter as food, a gut, waste and mulm hold it — grams, the carbon in them and the N, P, K and Fe — pooled or scaled; food at its recipe; and the element one composition runs out of first building another |
| Follow the rot | decomposition, rot, pool, rot, decompose, decompose, Pool, Pool | How fast rot runs at a temperature, the shares of a pool an hour takes — aerobic, anaerobic and settling — and what that hour does to the pool it meets: the matter rotted and settled, and the O₂ and CO₂ it trades |
| Reproduce a run | Rng | The seed and stream position every draw comes off. Serialize it and the tank replays exactly |
| Reach into a tick | System, core, tier, Effect, Effect, apply, process, Flora, process, process, Bloom, offer, plant, Carbon, and the per-system calculators | The tick’s own machinery, to measure one step of the hour. A system’s update takes the oxygen tier solves for its tier — the level all its aerobic draws and the air leave the water at as the hour ends. process runs plants and every bloom in one pass, returning each one’s vitality, light and budget fluxes, and the stores’ uptake from the water — the plants’ summed, each bloom’s its own, with its spores and the exudates’ hold; process every fish’s budget, feeding and health, with each one’s hour and vitality, and process the clutches, broods and males’ buffers after it, with what they burn and leave as Organics; offer gives every carbon fixer its share of one CO₂ stock |
Types you inherit
Section titled “Types you inherit”Every state shape, every configuration shape, every enum a host would otherwise restate — species ids, filter and substrate and lid and hardscape types, action types, life stages, breeding modes — is exported as a type. A consumer’s own model can be written against them rather than beside them.
What is not in it
Section titled “What is not in it”| Absent | Why it matters |
|---|---|
| The web UI | It consumes this package like any other host; nothing in dist/ knows it exists |
| CommonJS | The exports map offers import only |
| Persistence | The engine has no storage opinion. State is plain serializable data — the host decides where it goes |
| A mass-to-ppm helper | get turns a test-kit reading into stored mass. The inverse is not on the barrel, so a host displaying a concentration divides by resources. itself |
| A clock | Nothing schedules a tick. Autoplay, stepping and speed belong to the host |