Castle Wall

Draw one closed loop through the centres of the empty cells. It never enters a wall. A wall's number and arrow give the total length of the loop's segments in that direction — equivalently, how many cell borders the loop crosses if you walk out that way. A wall's colour says where the wall itself ends up: white is inside the loop, black is outside, grey says nothing. Click a gap between two cell centres to draw, click again to cross it out.

the board

where you are

inside outside wall only

The number and the colour never talk about the same edges

A Castle Wall clue has two halves and they look like they ought to overlap. Walk east out of the wall at (r,c) along the row's centre line. The segments the arrow counts are the horizontal edges of row r: they lie along the ray, collinear with it, and a ray that runs along a piece of curve does not cross it. Now nudge the ray down by a hair. The only loop edges it can meet are vertical edges spanning rows r and r+1, and by the Jordan curve theorem the parity of that count is exactly the inside/outside bit. So the arrow counts the edges the ray runs along, and the colour is the parity of the edges the ray runs across. Disjoint sets. Neither half can be computed from the other.

That is a claim, so it is measured. For every cycle of a grid, for every cell the loop misses and every one of the four directions, record the number an arrow would print and the colour the cell would get, then take the mutual information between them — pooled per (cell, direction) so that no correlation can sneak in from the cell's position. It comes out at 0.0051 bits on a 5×5 board across all 9,349 of its cycles. The control in the last column takes the same measurement against the parity of the across ray, which is the colour by construction, and gets the colour's whole entropy back.

The naive guess — "the number is odd exactly when the wall is inside" — scores 68.4% on a 5×5 board, which sounds respectable until you notice that always answering "outside" scores 80.9%. Reading the parity of the number is worse than not reading it.

grid(cell, dir) pairssamplesP(inside)guess from number parityalways say "outside"I(colour ; number)worst pairI(colour ; across parity)H(colour)
4 × 4644,46410.0%74.0%90.0%0.0023 bits0.0187 bits0.2333 bits0.2333 bits
5 × 5100281,81219.1%68.4%80.9%0.0051 bits0.0336 bits0.2808 bits0.2808 bits

How many loops a grid has, exactly

An answer to a Castle Wall board is a simple cycle of the grid graph that misses the walls, so before any clue is read the question is how many cycles a grid has. A connectivity-profile sweep answers it: carry a frontier of w+1 plugs, remember which is paired with which, canonicalise the pairing by first appearance. Two things are not in the textbook version — a cell may be skipped, because this loop wanders rather than filling the board, and the inside/outside bit rides along as one extra bit in the key, being the west parity ray evaluated incrementally as the sweep crosses the row.

The square grids have a published answer to check against, OEIS A140517. All 10 of them match. The rectangles have no OEIS entry, so 22 of them are checked against a depth-first enumeration that shares no code with the sweep.

gridcyclesmatches A140517frontier statestime
2 × 21yes71 ms
3 × 313yes411 ms
4 × 4213yes1990 ms
5 × 59,349yes8001 ms
6 × 61,222,363yes3,2365 ms
7 × 7487,150,371yes11,71213 ms
8 × 8603,841,648,931yes42,56241 ms
9 × 92,318,527,339,461,265yes145,962154 ms
10 × 1027,359,264,067,916,806,101yes499,441764 ms
11 × 11988,808,811,046,283,595,068,099yes1,657,8233.2 s

A loop drawn at random is too long to be a puzzle

The walls have to go where the loop is not, so a long loop is a board with few walls. Splitting the same sweep by length says how long a loop is if you pick one uniformly: on an 8×8 board the mean is 47.48 cells out of 64, 74.2% coverage, and it creeps up with the grid. That is the wrong end of the scale. The generator therefore does not sample uniformly; it tilts, giving every edge the loop leaves alone a weight of skip and every edge it takes a weight of take, which slides the density down without leaving the exact arithmetic — the tilted counts are still bigints.

The ratio is sharp. Between 1 and 2 the coverage falls from 74.2% to 22.7%, and every board worth generating lives in that sliver. The shipped boards use 3/2.

gridcyclesmean loop lengthcoveragemost common length
4 × 421310.7667.3%12
5 × 59,34917.4669.9%18
6 × 61,222,36325.7771.6%26
7 × 7487,150,37135.8173.1%36
8 × 8603,841,648,93147.4874.2%48
gridskip / takemean loop lengthcoverage
6 × 61 / 125.7771.6%
6 × 69 / 824.0166.7%
6 × 65 / 422.1961.6%
6 × 64 / 320.8758.0%
6 × 63 / 217.7649.3%
6 × 62 / 17.9322.0%
8 × 81 / 147.4874.2%
8 × 89 / 844.5569.6%
8 × 85 / 441.4364.7%
8 × 84 / 339.2761.4%
8 × 83 / 234.8154.4%
8 × 82 / 114.5422.7%
griduniform coveragetilted samplershipped boardswalls per board
6x671.6%49.8%45.6%6.4
8x874.2%54.9%53.8%11.5
10x1057.3%54.9%16.3

Even a board that says everything it can is unique only about half the time

Before minimising anything, ask what the genre's ceiling is: hand every cell the loop misses a colour and its longest arrow — more than any legal board would ever print — and count the answers. Over every cycle of a 4×4 grid that is 139 of 213; over every cycle of a 5×5 grid, 4,702 of 9,349. The rate is falling as the grid grows and it is already at a half. Half of all loops cannot be pinned down by any set of clues at all — not because the clues are weak but because the cells the loop leaves behind are not enough to carry them.

The tiny grids at the top of the table are degenerate and worth naming as such: a 2×2 board has one cycle and no spare cell to put a wall on, so its "max-information board" is a blank grid that happens to have one answer. The interesting rows start where there is room for walls.

gridcyclesmost walls a loop leavesmax-information boards with one answerrate
2 × 2101100.0%
2 × 332266.7%
3 × 3135969.2%
3 × 44083075.0%
4 × 42131213965.3%
3 × 5108117872.2%
4 × 51,0491655953.3%
3 × 62751417563.6%
5 × 59,349214,70250.3%

Erase the numbers and nothing survives; erase the colours and most small boards do

The two halves are independent, but they are not worth the same. Take the shipped boards and rub out one half at a time. Rubbing out every number leaves 0 of 64 boards with a single answer — the colours alone never carry a board, and the count runs past the 500-answer cap the search stops at. Rubbing out every colour leaves 19 of 24 at 6×6 and 2 of 16 at 10×10, so the colour is nearly free on a small board and load-bearing on a large one.

That is the shape you would expect from the geometry. A number is a count on a ray whose length grows with the grid; a colour is one bit however big the board is. The bigger the board, the more the arrows are already saying, and yet the further apart the answers sit — which is why the colour stops being decorative right when the search starts to hurt.

gridboardswallscolourednumberedcolours erased: still uniquemedian answersnumbers erased: still uniquemedian answerswalls only: median answers
6x62415412312219 / 2410 / 24≥ 500≥ 500
8x82427521320912 / 241.50 / 24≥ 500≥ 500
10x10162612082052 / 1614.50 / 16≥ 500≥ 500

The ladder, measured both ways

Five rungs, weakest first. degree: a wall takes no gaps, every other cell takes two or none. arrow: each number as an interval on its ray, forcing the rest of the ray when the count is met or when nothing may be spared. parity: each colour as four parity constraints — one per direction, all of them the same bit — plus the free even-crossing law, since a closed curve meets any straight line an even number of times and that holds on every row gap and column gap with no clue at all. loop: one loop, so a gap that would close a short circuit while another fragment is alive is unusable, and a fragment that can no longer reach the rest is dead. probe: assume a gap, run the cheap rungs, drop the assumption if the board dies.

Two measurements, the same boards. Going up the ladder, the share of the answer's gaps that propagation alone settles from an empty board. Taking one rung out of the full ladder, what is left. At 6x6 the full ladder settles 100.0% and finishes 22 of 24 boards outright; at 8x8 the full ladder settles 100.0% and finishes 17 of 24 boards outright; at 10x10 the full ladder settles 48.1% and finishes 4 of 16 boards outright.

The leave-one-out table is where the colour earns its keep. At 6x6 taking the parity rung out costs 0.0% — probing puts back everything the colours were saying. By 10x10 it costs 3.1%, and taking arrow out costs 12.5%. The same crossover as the clue-half ablation, from the other side: small boards do not need the colours, large ones do.

The node counts are the ladder read as pruning. A search that knows only degree is hopeless — it runs out of its 400,000-node budget on all 24 boards at 8x8 and all 16 boards at 10x10 — and each rung above it takes an order of magnitude off. A median marked is one where the median board itself ran out of budget, so the true figure is larger.

griddegreearrowparityloopprobe
6x637.5%48.3%52.5%52.5%100.0%
8x834.8%45.5%56.3%58.0%100.0%
10x1031.1%35.8%41.4%41.4%48.1%
gridfull ladder − arrowfull ladder − parityfull ladder − loopfull ladder
6x639.2%100.0%70.8%100.0%
8x839.7%57.6%63.4%100.0%
10x1035.6%45.0%44.7%48.1%
gridmedian nodes, degreemedian nodes, arrowmedian nodes, paritymedian nodes, loopmedian nodes, probe
6x65,7292717111
8x8≥ 400,00127062271
10x10≥ 400,00144,1175,32591718

The dial has a fork in it, and the boards take the safe branch

Minimisation here is not "which cells carry a clue" — the cells are walls either way, and a wall blocks the loop whether or not it says anything. What comes off is how much each wall tells you: full (colour and number) down to colour (the bit alone) or arrow (the number alone, wall left grey), down to wall (a grey blank), down to none, which hands the cell back to the loop. Weakening only ever admits more answers, so the greedy pass has a fixed point and reaching it is the whole minimisation.

The two middle levels are incomparable, which is the genre's own claim restated, so the dial forks. The shipped boards take the chain none → wall → colour → full, the way the genre prints a clue: a wall that keeps its number keeps its colour. Running the same seeds down the full fork instead answers what that costs, and the answer is nothing either way: 6.42 clues a board on the chain against 6.42 on the fork at 6x6, 11.21 clues a board on the chain against 11.29 on the fork at 8x8. The fork does not shrink a single board. What it does is strip the colours — 114 of 6x6's 119 numbered walls turn grey and 209 of 8x8's 220 numbered walls turn grey — because a number that survives on its own always prefers to, and the greedy takes the first level that works. Since the colours are free to keep and cost nothing to state, the chain is the right branch.

Across the 64 shipped boards the dial came to rest at: full 536, wall 146, colour 8.

gridseedsclues on the chainclues on the forkchain levelsfork levels
6x6246.46.4full 119, wall 32, colour 3arrow 114, wall 32, full 5, colour 3
8x82411.211.3wall 45, full 219, colour 5wall 46, arrow 209, full 11, colour 5

The shipped boards

64 boards across 6x6, 8x8, 10x10, every one re-solved from scratch after generation and required to have exactly one answer. The walls split 128 white, 416 black, 146 grey. Black outnumbers white because a wall is outside the loop unless the loop has been drawn around it, and at these coverages most of the board is outside.

The 5×5 inside-field cross-check in stats.json is the sweep checking itself: for every cell, the number of cycles that miss it and enclose it, counted once by enumerating all 9,349 cycles and once by the plug DP's parity bit. They agree on all 25 cells.

gridboardswalls per boardloop lengthcoverage
6x6246.416.445.6%
8x82411.534.453.8%
10x101616.354.954.9%