Build it backwards: how Arrow Untangle makes every board solvable with no solver

2026-12-03来源 dev.toEnglish

Arrow Untangle is a small browser puzzle on JumpBud: a grid packed with bent arrows, and each arrow slides out of the board in the direction its head points, with its body following behind. Tap an arrow whose path to the edge is clear and it leaves. Tap one that is blocked and you lose one of three lives.

Two promises sit on the game page: every board is solvable, and there is a fresh 8×8 board every day that everyone gets. Neither needs a server or a solver. The trick is to build each board backwards.

The idea: place arrows in reverse removal order

If you generate arrows at random and then ask "can this be cleared?", you need a search, and you will throw away a lot of boards. Instead, think about the last arrow to leave. When it leaves, the board is otherwise empty, so any position works. The second-to-last arrow only needs a clear exit path past the cells of arrows that will still be there... which, in reverse, are the arrows placed before it.

So the rule while generating is simple: a new arrow's exit ray must not cross any arrow already placed. Arrows placed earlier will be removed later, so the reverse of the placement order is always a valid solution.

const rayClear = (hx, hy, d) => { for (let x = hx + d[0], y = hy + d[1]; inside(x, y); x += d[0], y += d[1]) if (occ[y * size + x] >= 0) return false; return true; }; for (let attempt = 0; attempt < 6000 && filled < target; attempt++) { const hx = Math.floor(rng() * size), hy = Math.floor(rng() * size); if (occ[hy * size + hx] >= 0) continue; const d = DIRS[Math.floor(rng() * 4)]; if (!rayClear(hx, hy, d)) continue; // the whole invariant lives here // ...grow a body of 2..maxLen cells behind the head } 

The target is 90% of the cells (Math.floor(size * size * .9)), with a cap of 6000 attempts so a crowded board just stops growing instead of looping forever.

One subtle bug to avoid: the arrow blocking itself

The body is grown as a random walk backwards from the head, with a 45% bias toward going straight so arrows read cleanly. A random walk can curl around and drop a body cell in front of its own head. The ray check above ran before the body existed, so it would not catch that. The fix is one extra filter on each step:

const inRay = (hx, hy, d, x, y) => d[0] ? (y === hy && Math.sign(x - hx) === d[0]) : (x === hx && Math.sign(y - hy) === d[1]); const opts = DIRS.map(([dx, dy]) => [px + dx, py + dy]).filter(([x, y]) => inside(x, y) && occ[y * size + x] < 0 && !used.has(y * size + x) && !inRay(hx, hy, d, x, y)); 

When the body cannot grow any further, it just stops early; the minimum length is 2 cells, so every arrow still has a visible direction.

Why there are no dead ends

Here is the property I like most. Removing an arrow only frees cells; it never adds an obstacle. So an arrow that is free stays free no matter what you remove next. That means the game has no traps: any order of legal taps finishes the board. You never need to plan ahead to avoid painting yourself into a corner. The challenge is purely spotting a clear path before you tap.

I checked this rather than trusting the argument. Running the generator in Node for all 365 Daily boards of 2026 and clearing each one 50 times by tapping a random free arrow: 18,250 out of 18,250 runs cleared the board.

Seeds: the same daily board for everyone

The randomness comes from mulberry32, a tiny 32-bit PRNG, seeded from the date or the level number:

function levelConfig(n) { if (mode === 'daily') return {size: 8, maxLen: 6, seed: dateKey(date) * 31 + 7}; return { size: Math.min(9, 4 + Math.ceil(n / 3)), maxLen: Math.min(7, 3 + Math.floor(n / 4)), seed: n * 7919 + 13, }; } 

dateKey('2026-12-02') is just 20261202, so the Daily Tangle is identical on every device with no network call. Level boards grow from 5×5 to a 9×9 cap at level 15, and arrows get longer as you go.

What the numbers look like

From the same Node run over the 2026 Daily boards (8×8):

Metric Value
Arrows per board 15.3 on average
Cells covered 83% on average
Arrows free at the start 8.3 on average, never fewer than 2
Chance a random tap is blocked about 46%
"Waves" to clear (remove every free arrow at once, repeat) 3.5 on average, 2 to 7
Generation time 0.17 ms per board (10,000 boards)

Two takeaways. First, generation is so cheap that there is no reason to pre-bake boards or ship a level file. Second, difficulty here is not search depth; it is the roughly coin-flip chance that the arrow you are looking at is blocked, multiplied by three lives. That is why the game shows a short bump animation toward the blocker on a bad tap, and why the hint simply highlights one currently free arrow.

Limits and what I would try next

Because any order works, this generator cannot produce boards that reward long-range planning. If I wanted that, I would need a different rule (for example, arrows that block each other in a cycle unless removed in a narrow order) and a real solver to verify them. For a quick daily, though, "always solvable, never a trap" is the right trade.

If you want to see how a backwards-built board feels, you can play today's Daily Tangle here: Arrow Untangle on JumpBud.

原文:https://www.a8q9.cn/en/article/build-it-backwards-how-arrow-untangle-makes-every-board-solvable-with-no-solver-ac692f.html

相关文章