Phaser 4TypeScriptWeb AudioVitest
Controls
- Tap or click a flask to lift it, then tap another to pour, or drag one flask onto another; flasks that can take the pour show a brass marker
- Liquid lands only on the same colour or in an empty flask, and the whole top run of one colour pours at once, as much as fits; tapping a flask that cannot take it picks that flask instead
- Undo, Restart, Hint (the next pour of a real solution), Spare (one extra empty flask per level, costs the third star) and Symbols (a glyph on every colour)
- Keyboard: arrow keys choose a flask (up and down change shelf), Enter or Space picks and pours, 1 to 9 and 0 jump to a flask, Escape puts it back, Z undoes, H hints, S adds the spare flask, R restarts, G toggles symbols
- A level in progress is kept in this browser: Continue in the formulary picks it up with its undo history
- Add ?level=12 to the address to open a level directly, or ?demo=12 to watch the solver play it
Needs WebGL. Without it the poster is shown. Respects the reduced-motion setting: flasks do not fly or tilt, levels change with a short fill, and there are no sparks, bubbles or sloshing. Sound is off until you turn it on. Progress is saved in this browser.
Questions
How do I play Tincture?
Tap a flask to lift it, then tap another to pour, or drag one onto another. Liquid lands only on the same colour or in an empty flask.
How many levels are there?
48 levels in five chapters, with stars against par. Smoked flasks hide their layers and wax seals close finished colours.
What if I get stuck?
Use Undo or Restart, ask for a Hint (the next pour of a real solution from the built-in solver), or add one Spare flask, which costs the third star.
Does it save progress?
Yes. Progress is saved in this browser, and a level in progress keeps its undo history.
How it’s built
A liquid sort puzzle on an apothecary's shelf: pour layers of coloured tinctures between glass flasks until every flask holds one colour. 48 levels in five chapters, each chapter adding one idea: more colours, smoked flasks that hide their layers, wax seals that open when a colour is finished, and both together.
How it's built
- Rules and drawing are separate.
core/ is plain TypeScript with no Phaser imports: the rules (a pour moves the whole top run of one colour, as much as fits, onto the same colour or into an empty flask), the solver, the level generator and the game (undo, spare flask, stars). The Phaser scene only shows a state and animates what a pour result says happened. - Hidden layers are a bottom prefix. In a smoked flask only the top layer is known; a hidden layer never joins a pour, and it is revealed when it becomes the top or when the flask is completed. Because pours never touch the hidden prefix, undo can restore the flasks while keeping everything the player has already seen.
- Wax seals. A sealed flask cannot be poured from or into until a flask is completed in the seal's colour. The generator never seals a flask that holds its own seal colour or another seal's colour, so seals cannot lock each other.
- A real solver. Weighted A* over pour sequences; flasks that differ only in order count as the same state, and the heuristic counts colour breaks. It plays by the player's rules (hidden layers never join a run) but sees the true colours. It powers the Hint button (the next pour of an actual solution, or a clear "no way out from here" when the current position is lost) and the
?demo=12 mode that plays a level by itself. - Levels are generated, then frozen. Each level is a recipe (colours, empty flasks, smoke, seals, hardness). A build step (
levels.build.test.ts, run on demand) shuffles layouts from a fixed seed, rejects ones that look sorted, solves each with three solver weights to set par, and picks harder candidates for later levels. The result is checked into levels.data.ts, so every player gets the same 48 levels. Unit tests check every level's counts and that the solver still solves it. - Stars against par. Three stars for finishing at or under par without the spare flask, two within one and a half times par or with the spare flask, one otherwise. Undo is free.
- The pour is simulated. Liquid is the flask's inside cut by lines level with the world, computed in the flask's local space every frame (polygon clipping and a bisection on area), so the surface stays level however the flask tilts. During a pour the flask is carried over the target and tips exactly as far as needed to keep the surface at the lip; as it empties it tips further, and its position is solved so the lip stays put. The stream bends from the lip into the target, whose level rises in step. Surfaces slosh and settle after each move. These functions are unit-tested (volume is kept at any tilt, the pour angle puts the surface on the lip).
- Saved runs. The level in progress (flasks, undo history, pours, spare flask) is saved after every move; Continue resumes it after a reload. A saved run is checked against its level (same colours and counts, valid hidden and seal data) before it is used, so stale or edited data is ignored.
- Comfort. Tap to lift and tap to pour, or drag one flask onto another (a live arc shows the target). A lifted flask marks every flask that can take its pour with a bobbing brass chevron; tapping a flask that cannot take it picks that flask instead. Brass plates on the shelf number the flasks, matching the digit keys and the announcements.
- Drawing. Phaser 4 (WebGL). Everything is drawn with Phaser Graphics: glass with a real wall thickness and a thick bottom, graduation marks, highlights and a rolled lip, liquid lit just under its surface with a meniscus that climbs the walls, cylinder shading on each layer, smoky layers with a question mark that fade to colour when revealed, corks that drop into finished flasks, wax seals stamped with their colour's glyph that crack open with sparks, a wooden shelf with brass brackets, bubbles, sparks and a breath of vapour from particle emitters, and a win with a light sweep, hopping flasks and a rain of coloured drops. Behind the shelf, a CSS and SVG room: carved cornice, a high shelf of jars, swaying herb bundles and candles whose flames flicker (all still under reduced motion). The camera zooms by the device pixel ratio so the vector drawing stays sharp. Phaser's own input, sound and scaling are off; the page hit-tests flasks itself.
- Accessible colours. Every tincture has a glyph (dot, triangle, square and so on); Symbols draws it on every layer and seals always carry it. All controls work by keyboard (arrows, Enter, digits, Z, H, S, R, G). Everything readable is HTML: the plaque, the formulary, notes and results; a polite live region announces each pour, reveal, seal and cork, and a hidden list describes every flask.
- Reduced motion. Flasks do not fly or tilt; levels change with a short linear fill; no sloshing, sparks, bubbles, drop-in or candle flicker. The game stays fully playable.
- Performance. The pixel ratio is capped at 2 (1.5 on devices with 4 or fewer cores or 4 GB or less memory, which also get fewer particles). Flasks redraw only when something changes. The Phaser loop sleeps while the shelf is off screen or the tab is hidden. If the graphics context is lost, the poster covers the shelf until it returns.
- Sound is generated with Web Audio (no files) and is off until turned on: glass clinks, a pour of filtered noise and small glugs whose pitch rises as the target fills, a cork pop, a crackling seal and a chime for a win. Progress, best results and settings are saved in this browser (
localStorage, versioned key; nothing breaks if storage is blocked).