Cave (also sold as Corral or Bag) in the browser with four rule
sets inside. Shade some cells of an n×n grid. The unshaded cells — the
cave — form one orthogonally connected group, every shaded wall
connects through walls to the border, and each number sits in the cave
and counts the cave cells it sees in the four directions, itself
included, before a wall or the edge stops the view. Puzzle #36 in the
solver series.
Demo: https://sen.ltd/portfolio/cave/
Repo: https://github.com/sen-ltd/cave
I picked this one because the answer space has a name of its own.
The answers are the hole-free polyominoes
Strip the numbers away and ask what a finished board can look like. The
cave is connected; every wall reaches the border — and the second rule is
just "no pocket of walls sealed inside the cave", i.e. no holes. So a
valid configuration is exactly a hole-free polyomino, and its boundary
— the grid edges between a cave cell and a wall or the outside — is a
single closed non-crossing loop on the lattice points.
The correspondence is a bijection: one valid board per simple cycle of the
(n+1)×(n+1) grid graph. That is why the same puzzle ships under two names —
shade the cells and it's Cave, draw the fence and it's Corral. Same object.
Counted, both ways. Exhaustive enumeration of clue-free boards: 13 on
2×2, 213 on 3×3, 9,349 on 4×4. An independently written
simple-cycle counter on the lattice — it knows nothing about polyominoes —
returns 13 / 213 / 9,349. All three match OEIS A140517, the cycle
counts of the grid graph.
The pattern no rule mentions
A checkered 2×2 — cave on one diagonal, wall on the other — never survives,
though no stated rule bans it. The cave path joining the two cave corners
closes into a curve that fences one of the wall cells away from the
border. In boundary-loop language, a checkered window is a pinch
point, where the loop touches itself. It is connectivity's local shadow,
and it does a full rule set's worth of work in the solver.
The generator: a 3×3 stamp from digital image topology
How do you sample hole-free polyominoes? Backtracking over shadings fights
the structure instead of using it. Digital image processing already has the
right tool: a cell whose flip preserves the topology of the picture is
called a simple point, and it is recognized locally.
Read the 8 cells around a candidate in a circle (off-grid counts as wall).
The flip is safe exactly when:
- the circle changes color exactly twice — one cave arc, one wall arc;
- an orthogonal neighbor already has the flip's new color.
Consecutive ring cells are orthogonal neighbors of each other, so an arc is
automatically connected; two changes mean both sides of the flip stay in
one piece, and the arc condition keeps the pinch — the checkered 2×2 — out.
Seed one random cell, grow, then mix with thousands of random safe flips.
Every intermediate picture is a valid configuration, no global
connectivity check ever runs, and no backtracking exists to be needed.
Verified on 1,500 generated configurations: one boundary component, zero
pinch points, V = E (closed), 1,500/1,500.
Four rule sets
| level | rule |
|---|---|
count |
the clue arithmetic, made exact: a clue v splits as 1 + four ray extents; an extent claims its cells cave and its stopper wall; convolve the four feasible-extent sets as sum bitmasks and force what every completion agrees on |
corner |
a 2×2 admits 14 of its 16 shadings — only the two checkered ones die, and only connectivity says so |
bridge |
both connectivity rules made local, one articulation-point DFS each: cave cells stay mutually reachable through (cave ∪ free); walls stay reachable from a virtual outside node through (wall ∪ free); sealed-off cells take the other color, cut vertices take the color they carry |
probe |
assume one color on one cell, run the rules below to a fixpoint, drop the assumption if that alone is a contradiction |
Incremental vs ablation — the cleanest split yet
Measured on 300 raw generator boards per size (85% of the cave cells
clued; unfiltered by uniqueness or difficulty, so the numbers aren't shaped
by the property they measure — fraction finished by the fixpoint alone, no
guessing):
| board | count | +corner | +bridge | +probe | unique answers in the raw stream |
|---|---|---|---|---|---|
| 6×6 | 16.0% | 44.0% | 72.7% | 73.3% | 73.3% |
| 8×8 | 6.3% | 29.0% | 55.3% | 55.7% | 55.7% |
| 10×10 | 2.3% | 23.0% | 52.0% | 53.0% | 53.0% |
The incremental table credits corner with 21–28 points — a solid
supporting role. Then run the ablation (full ladder minus one rule):
| board | full | −count | −corner | −bridge |
|---|---|---|---|---|
| 6×6 | 73.3% | 0.0% | 73.3% | 44.0% |
| 8×8 | 55.7% | 0.0% | 55.7% | 29.3% |
| 10×10 | 53.0% | 0.0% | 53.0% | 23.7% |
Removing corner costs 0.0 points at every size — not one board.
Corner is the shadow of connectivity, and once bridge — connectivity
itself — enters the room, the shadow vanishes. Removing count drops
everything to 0.0%: it is the only rule that reads the clues at all.
That's the fourth puzzle in a row where a rule is redundant but not
useless: corner still defines a genuine difficulty grade in the shipped
bank, and it is the pattern a human actually spots.
Probe's solve rate = the uniqueness rate, again
At every size the probe column equals the uniqueness column exactly. A
sound fixpoint cannot decide a cell that two answers disagree on, so the
uniqueness rate is a ceiling — and the ladder sits on it.
Cave's ambiguity lives in single-cell flips
Cave is starving for clues under random reveals — clues can only sit on
cave cells, so every wall is a free cell forever. But it starves in the
opposite way from Yin-Yang.
Call a flip silent when it keeps the board valid and leaves every clue
count unchanged. Each silent flip is a free second solution, so
P(unique) ≤ P(no silent flip). 10×10, 150 raw boards per point:
| density | unique | no-silent-flip ceiling | bridge-solved | count-solved |
|---|---|---|---|---|
| 0.50 | 1.3% | 3.3% | 1.3% | 0.0% |
| 0.60 | 6.0% | 12.0% | 6.0% | 0.0% |
| 0.70 | 20.7% | 26.0% | 20.7% | 0.0% |
| 0.80 | 38.0% | 47.3% | 37.3% | 2.0% |
| 0.90 | 65.3% | 72.7% | 64.7% | 1.3% |
| 1.00 | 100.0% | 100.0% | 100.0% | 2.0% |
Yin-Yang's measured uniqueness crawled far below its flip ceiling — its
ambiguity lived in multi-cell reroutes of the curve. Cave's uniqueness
hugs the ceiling all the way up. As bare configurations the space is
loose (a random 10×10 board has ~50 flippable cells), but the sight-line
arithmetic silences almost all of them, and what ambiguity survives is
almost entirely single silent flips.
Two columns deserve a stare. Clue every cave cell (density 1.00) and the
board is always unique — yet count alone still finishes only 2% of
them. The numbers pin the answer without being able to reach it: only
connectivity knows the cave is one room and the walls have doors. And once
connectivity propagates, proving uniqueness stops being a search: a median
of 0 guesses with bridge at 10×10 (mean 1.0) — while the
connectivity-free levels already explode at 6×6, riding the never-clued
free walls.
The shipped bank's boards, thinned adversarially instead of randomly, pin a
10×10 board with a median of 23–27 clues — half the budget a random reveal
needs for a coin-flip's chance.
Verification
Every claim is counted two independent ways. One engine searches with the
rule ladder propagating at each of the four levels. The other is a brute
force sharing no code with any of them: row-major DFS over free cells,
pruned only by the three definitional rules (clue min/max brackets,
cave reachability, wall-to-border reachability), every leaf scored by a
standalone validator. On every board the brute force can reach, all levels
must agree on the solution count: 400/400 (board, level) pairs.
Exhaustive anchors: clue-free 2×2 / 3×3 / 4×4 boards number 13 / 213 /
9,349, matching the independent lattice-cycle counter on all three
(A140517). The boundary-loop theorem is verified not just on generator
output (that would be circular) but on every valid board up to 4×4. And
every flip the 3×3 stamp accepts is re-checked by the standalone validator
— never a broken board. All 25 tests.
Play it
The Hint button proves one cell at a time at the selected level; the rule
selector doubles as the difficulty dial, and the bank only serves boards
that first become guess-free at that level. The cave's boundary is drawn
live in purple — you can watch it close into a single fence as the board
finishes. The moment it closes, you have also solved the Corral.
Next up: probably another puzzle with a solver inside.
SEN LLC — software development experiments, shipped in public.
More portfolio: https://sen.ltd/portfolio/

Top comments (0)