Skip to content

Repository files navigation

Cave — every answer is fenced by one closed loop

Cave (Corral / Bag) in the browser, with the solver's four rule sets built in. 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 clue sits in the cave and counts the cave cells it sees in the four orthogonal directions, itself included, before a wall or the edge stops the view.

Strip the numbers away and the two connectivity rules leave exactly one shape: the cave is 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. 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 (Cave) or draw the fence (Corral), it is the same object. Counted both ways: 13 boards on 2×2, 213 on 3×3, 9,349 on 4×4, matching the lattice cycle counts (OEIS A140517) exactly.

The generator runs the bijection backwards without ever touching a cycle: digital image topology recognizes a cell whose flip preserves the picture's topology — a simple point — by a 3×3 stamp. 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 twice and an orthogonal neighbor already has the new color. A random seed cell, a growth phase, thousands of random safe flips: every intermediate picture is a valid configuration, no global connectivity check is ever run, and no backtracking exists to be needed. Verified: 1,500 generated configurations, every one a single closed loop with zero pinch points.

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 and force what every completion agrees on
corner a 2×2 admits 14 of its 16 shadings: the two checkered ones are banned by no stated rule — the cave path joining the two cave corners fences one wall cell away from the border. Connectivity's local shadow
bridge the two connectivity rules made local, one articulation-point DFS each: cave cells must stay mutually reachable through (cave ∪ free), walls must 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, and drop the assumption if that alone is a contradiction

The numbers

Measured on 300 raw generator boards per size (clue density 0.85 over the cave cells, unfiltered, so the numbers are not 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 probe column equals the uniqueness column at every size: a sound fixpoint cannot decide a cell two answers disagree on, so the uniqueness rate is a ceiling — and the ladder sits on it.

Ablation (full ladder minus one rule) tells a different story than the incremental table. Remove count and everything drops to 0.0% — the arithmetic is the only rule that reads the clues at all. Remove corner and nothing drops, at any size, even though the incremental table credits it with 21–28 points: corner is the local shadow of connectivity, and once bridge — connectivity itself — enters the room, the shadow vanishes. Fourth puzzle in a row with a redundant-but-not-useless rule: corner still defines a genuine difficulty grade in the shipped bank, and it is the pattern a human actually spots.

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%

Cave is extremely clue-hungry under random reveals — clues only ever sit on cave cells, so every wall is a free cell forever. But unlike Yin-Yang, whose ambiguity lives in multi-cell reroutes far below its flip ceiling, Cave's ambiguity is almost entirely single-cell flips. Call a flip silent when it keeps the board valid and leaves every clue count unchanged — each one is a free second solution, so P(unique) ≤ P(no silent flip). The measured uniqueness curve hugs that ceiling the whole way (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%

Two columns deserve a stare. Clue every cave cell (density 1.00) and the board is always unique — yet the count rule alone still finishes only 2% of them: the numbers pin the answer without being able to reach it, because only connectivity knows the cave is one room and the walls have doors. And proving uniqueness needs almost no search once connectivity propagates: a median of 0 guesses with bridge at 10×10 (mean 1.0), against a median of 3 and a long tail of 25+ for count alone at 6×6 — where the connectivity-free searches already explode.

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 checked two independent ways:

  • Solution counts. A brute force that shares no code with the rule ladder — row-major DFS over free cells, pruned only by the three definitional rules, every leaf scored by a standalone validator — must agree with a propagating search at each of the four rule levels, on every board where the brute force is feasible (400/400 (board, level) pairs).
  • Exhaustive anchors. The clue-free 2×2, 3×3 and 4×4 boards are counted exhaustively: 13, 213, 9,349 valid boards by plain enumeration — and an independent simple-cycle counter on the (n+1)×(n+1) lattice, which knows nothing about polyominoes, returns the same three numbers (A140517).
  • The boundary theorem. One component, zero pinch points, V = E (closed) — on every valid board up to 4×4 (exhaustive, so no generator circularity) and on 1,500 generated configurations.
  • The stamp. Every flip the 3×3 simple-point test accepts is applied to a valid configuration and re-checked by the standalone validator: never a broken board.

All 25 tests: npm test.

Run it

npm install
npm run dev        # local dev server
npm test           # vitest
npm run generate   # regenerate src/puzzles.json (the shipped bank)
npm run stats      # the measurements behind this README

Built with TypeScript + Vite, no runtime dependencies.

License

MIT

Links

About

Cave (Corral) with four rule sets. Strip the numbers and the answers are exactly the hole-free polyominoes — one per simple cycle of the lattice (13/213/9349, OEIS A140517). The generator flips 'simple points' from digital image topology: a 3x3 stamp, no global check, no backtracking. Ambiguity lives in single silent flips. Puzzle #36.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages