SORTING SEARCH · BFS VERIFIED
Water Sort Solver & Strategy Guide: Empty-Tube Math, Deadlocks & Optimal Pours
Winning hard Water Sort boards comes down to one core invariant: protect your empty buffer bottles while excavating the deepest buried colors first. Although a four-layer tube puzzle looks simple, computer scientists Takehiro Ito, Jun Kawahara, Shin-ichi Minato, Yota Otachi, Toshiki Saitoh, Akira Suzuki, Ryuhei Uehara, Takeaki Uno, Katsuhisa Yamanaka, and Ryo Yoshinaka (2022, arXiv:2202.09495) proved two striking theorems about the game: Water Sort (pouring contiguous top runs) and Ball Sort (moving one unit at a time) are 100% equivalent in solvability, and deciding whether an arbitrary board is solvable is NP-complete.
Why Water Sort Solvers Use State-Space Search & Symmetry Pruning
Because Water Sort is NP-complete in general (and even supports physical card-based zero-knowledge proofs of solvability; see Suthee Ruangwises, 2023, arXiv:2302.07251), there is no one-line formula like Lights Out's matrix reduction. Instead, automated Water Sort solvers treat each board configuration as a node in a directed state graph and run Breadth-First Search (BFS) or heuristic A* search with three powerful pruning rules that humans can apply directly at the board:
- Canonical Tube Order (Bottle Symmetry): Swapping which physical slot holds an empty bottle or a finished color does not create a new position. Solvers sort bottle states canonically to collapse duplicate branches by orders of magnitude.
- Zero-Gain Pure-Stack Ban: Never pour a bottle that already holds only one color (like
[3, 3]) into an empty bottle. That move uncovers zero buried colors and creates no new consolidation target. - Single-Empty-Target Pruning: When two empty tubes exist, pouring into the first empty tube is mathematically identical to pouring into the second—never branch on empty-slot choice.
Exact 5-Pour Deadlock Proof: How Burning Both Empty Tubes Kills a Solvable Board
Every level on Water Sort Online gives you k colors and k + 2 four-unit bottles (2 empty buffers) and is verified solvable before publication. Yet filling both empty bottles prematurely can lock a solvable puzzle into a true zero-legal-move dead end within five moves! Here is an exact counterexample verified directly on our live engine for Level 6 (Color Garden, 5 colors, 7 bottles, bottom-to-top arrays):
Start state: B1=[4,5,2,3], B2=[1,1,1,3], B3=[5,2,3,4], B4=[4,5,4,2], B5=[5,3,1,2], B6=[], B7=[].
- Pour
B1 → B6(moves Color3into emptyB6). - Pour
B2 → B6(stacks second3onB6;B2now exposes[1,1,1]). - Pour
B3 → B7(spends the second empty buffer on Color4!). - Pour
B3 → B6(adds third3toB6 = [3,3,3]). - Pour
B3 → B1(pours Color2ontoB1 = [4,5,2,2], fillingB1to capacity4).
Inspect the resulting 7-bottle board: B1=[4,5,2,2] (full), B2=[1,1,1] (top 1), B3=[5] (top 5), B4=[4,5,4,2] (full), B5=[5,3,1,2] (full), B6=[3,3,3] (top 3), B7=[4] (top 4). Every bottle with open capacity shows a different top color (1, 5, 3, 4), while all three tubes topped with Color 2 are 100% full (length 4). Legal moves remaining: 0! That single greedy step #3 (pouring 4 into the last empty buffer before freeing a tube) caused an immediate crash—even though the exact same starting board solves cleanly in 15 pours.
Four Human Solver Rules That Mirror Optimal BFS Play
Watch what our exact BFS solver does across all 12 Puzzle Fern boards—it follows four clean tactical habits you can copy without a computer:
- Build One Complete Color Before Touching Your Second Empty Tube: Treat Empty Bottle #1 as your active collector for a color that already has 2–3 exposed top units (or a 3-unit bottom base like
B2=[1,1,1,3]in Color Garden). Keep Empty Bottle #2 untouched unless spending it immediately empties another bottle within 1–2 pours. - Free a Mixed Bottle to Manufacture a Fresh Empty Tube: A bottle containing four distinct singles (like
B1=[3,1,3,1]in Three Streams) is actually an asset: clearing its top layers flips it into a brand-new empty buffer! - Count Top-Layer Visibility Before Pouring Into Empty Space: Never park a lone color into an empty tube unless doing so uncovers a color you can immediately combine onto an existing matching top or finish a 4-unit tube.
- Avoid Splitting Contiguous Runs Across Half-Full Tubes: Because Water Sort pours as much of the top continuous color as fits, pouring a 2-unit run into a tube with only 1 empty slot splits that color back into two fragments—raising the board's transition entropy instead of lowering it.
Worked BFS-Optimal Walkthroughs (Three Streams & Four Corners)
Here are two complete, engine-verified shortest solutions (bottles numbered B1–B6 left to right, layers read bottom to top):
- Three Streams (3 colors, 5 bottles — exact BFS optimum:
10pours): StartB1=[3,1,3,1],B2=[3,1,2,2],B3=[1,3,2,2],B4=[],B5=[]. Rather than dumping the 2-unit2s into empty space first, drainB1completely intoB4andB5soB1becomes the dedicated home for Color2:1. B1→B4 (1)·2. B1→B5 (3)·3. B1→B4 (1)·4. B1→B5 (3)(nowB1is completely empty!) ·5. B2→B1 (2×2)·6. B2→B4 (1)·7. B2→B5 (3)·8. B3→B1 (2×2 — Color 2 complete!)·9. B3→B5 (3 — Color 3 complete!)·10. B3→B4 (1 — Color 1 complete!). - Four Corners (4 colors, 6 bottles — exact BFS optimum:
13pours): StartB1=[3,2,1,3],B2=[4,2,4,1],B3=[3,3,4,1],B4=[2,1,4,2],B5=[],B6=[]. DedicateB5to Color3andB6to Color1, collecting three1s immediately:1. B1→B5 (3)·2. B1→B6 (1)·3. B2→B6 (1)·4. B3→B6 (1)·5. B2→B3 (4)·6. B2→B1 (2)·7. B3→B2 (4×2)·8. B3→B5 (3×2)·9. B4→B1 (2)·10. B4→B2 (4 — Color 4 complete!)·11. B4→B6 (1 — Color 1 complete!)·12. B1→B4 (2×3 — Color 2 complete!)·13. B1→B5 (3 — Color 3 complete!).
Exact BFS-Optimal Pour Benchmarks Across All 12 Puzzle Fern Levels
Every level below was solved to proven minimum pours using exact canonical Breadth-First Search directly against Puzzle Fern's water-sort/engine.mjs rules (and replayed move by move through pour() and isComplete()). Use these benchmarks as par targets when replaying on Water Sort Online:
| Level Name | Colors / Bottles | Empty Buffers | Verified Shortest Pours (BFS Optimal) | Canonical States Explored |
|---|---|---|---|---|
| First Pour | 2 colors / 4 bottles | 2 | 3 pours | 6 |
| Three Streams | 3 colors / 5 bottles | 2 | 10 pours | 36 |
| Pebble Pool | 3 colors / 5 bottles | 2 | 11 pours | 62 |
| Riverside | 4 colors / 6 bottles | 2 | 12 pours | 161 |
| Four Corners | 4 colors / 6 bottles | 2 | 13 pours | 218 |
| Color Garden | 5 colors / 7 bottles | 2 | 15 pours | 375 |
| Quiet Fountain | 5 colors / 7 bottles | 2 | 15 pours | 318 |
| Stepping Water | 5 colors / 7 bottles | 2 | 16 pours | 85 |
| Six Springs | 6 colors / 8 bottles | 2 | 18 pours | 517 |
| Blue Lagoon | 6 colors / 8 bottles | 2 | 19 pours | 479 |
| Garden Estuary | 7 colors / 9 bottles | 2 | 21 pours | 1,429 |
| Rainbow Brook | 7 colors / 9 bottles | 2 | 23 pours | 1,076 |
Notice how smoothly the par pour count scales with color count—roughly 3.0 to 3.3 pours per color on well-mixed k + 2 layouts—and why the hardest 7-color boards still yield cleanly once you protect your empty swap tube. Try beating par on Water Sort Online (complete with 200-step Undo and numeric color labels), or test reversible planning on Sokoban Online.
Frequently Asked Questions
Is Water Sort Puzzle mathematically hard for computers too?
Yes. Ito et al. (2022, arXiv:2202.09495) proved that Water Sort and Ball Sort have identical solvability and that deciding whether an arbitrary configuration can be solved is NP-complete, even though bounded 2-to-7-color levels solve rapidly with breadth-first search (BFS).
Why do most Water Sort boards give you two empty bottles?
Two empty bottles act as a working swap buffer. Filling both empty bottles with partial stacks of different colors collapses your workspace to zero, which can trigger a 0-legal-move deadlock in as few as five pours.
Should you ever pour a single-color stack into an empty bottle?
No. Moving a pure stack (such as [2, 2] with nothing underneath) into an empty bottle changes zero color boundaries and wastes a pour without uncovering any buried layer.
What is the shortest pour count for Puzzle Fern Water Sort levels?
Exact breadth-first search across Puzzle Fern's 12 original levels proves minimum pour counts ranging from 3 pours on First Pour (2 colors, 4 bottles) up to 21 pours on Garden Estuary and 23 pours on Rainbow Brook (7 colors, 9 bottles).
Sources & Primary References
- Takehiro Ito, Jun Kawahara, Shin-ichi Minato, Yota Otachi, Toshiki Saitoh, Akira Suzuki, Ryuhei Uehara, Takeaki Uno, Katsuhisa Yamanaka, and Ryo Yoshinaka (2022) — Sorting Balls and Water: Equivalence and Computational Complexity (arXiv:2202.09495).
- Suthee Ruangwises (2023) — Physical Zero-Knowledge Proof for Ball Sort Puzzle (arXiv:2302.07251).
- Wolfram MathWorld — Breadth-First Traversal (shortest-path unweighted state-space search used to verify minimum pour counts).
- Solver Verification: All 12 optimal pour counts, both worked walkthroughs (
three-streamsandfour-corners), and the 5-pour 0-legal-move deadlock oncolor-gardenwere verified and replayed step by step against Puzzle Fern's livesrc/games/water-sort/engine.mjsmodule.