The showcase prompt, round 3, Fable 5.2
- agent
- Claude Code 2.1.322
- model
- claude-fable-5-2
- harness
- Claude Code
- started
- 2026-11-11 08:04 UTC
- took
- 117 min · 131 turns
user
+0:00I need you to create the most impressive thing you can make: the thing that shows what you do best. People ask me which models I use, and I want to answer by showing them this. It needs to be embeddable in a post, and I'll write the preface. It needs a visceral impact and should grab people quickly, then hold up when they look closer. It doesn't have to be about you or about me. Pick what you're best at and let the work be the proof. Be amazingly clever about this.
agent
+0:50Bashcd ~/run; ls -la; which node npm python3 chromium chromium-browser google-chrome firefox ffmpeg convert magick 2>&1; node -v; python3 -V; ls ~/.cache/ms-playwright 2>/dev/null; python3 -c "import playwright; print('pw ok')" 2>&1; npm ls -g 2>/dev/null | head -20; nproc; free -g | head -2; (glxinfo 2>/dev/null | head -3)
command
cd ~/run; ls -la; which node npm python3 chromium chromium-browser google-chrome firefox ffmpeg convert magick 2>&1; node -v; python3 -V; ls ~/.cache/ms-playwright 2>/dev/null; python3 -c "import playwright; print('pw ok')" 2>&1; npm ls -g 2>/dev/null | head -20; nproc; free -g | head -2; (glxinfo 2>/dev/null | head -3)result, 21 lines
total 8 drwx------ 2 runner runner 4096 Nov 11 08:04 . drwx------ 3 runner runner 4096 Nov 11 08:04 .. /opt/node/bin/node /opt/node/bin/npm /usr/bin/python3 /usr/bin/chromium-browser /usr/bin/ffmpeg /usr/bin/convert v22.21.1 Python 3.10.12 Traceback (most recent call last): File "<string>", line 1, in <module> ModuleNotFoundError: No module named 'playwright' /opt/node/lib ├── corepack@0.34.0 └── npm@10.9.4 10 total used free shared buff/cache available Mem: 49 14 16 0 18 33Bashcd /tmp && mkdir -p probe && cd probe && cat > t.html <<'EOF'error
command
cd /tmp && mkdir -p probe && cd probe && cat > t.html <<'EOF' <!doctype html><body style="margin:0;background:#123"><canvas id=c width=300 height=200></canvas><script> const gl=document.getElementById('c').getContext('webgl2');document.title=gl?('GL2 '+gl.getParameter(gl.VERSION)+' | '+(gl.getExtension('EXT_color_buffer_float')?'cbf':'nocbf')):'nogl'; const d=document.createElement('pre');d.style.color='#fff';d.textContent=document.title+' '+(gl&&gl.getParameter(gl.MAX_TEXTURE_SIZE))+' '+navigator.userAgent;document.body.appendChild(d); </script> EOF timeout 60 chromium-browser --headless=new --no-sandbox --use-gl=angle --use-angle=swiftshader --enable-unsafe-swiftshader --screenshot=/tmp/probe/s.png --window-size=800,400 --virtual-time-budget=2000 file:///tmp/probe/t.html 2>&1 | tail -5; ls -la /tmp/probe; chromium-browser --versionresult, error, 15 lines
Exit code 1 Command '/usr/bin/chromium-browser' requires the chromium snap to be installed. Please install it with: snap install chromium total 4 drwx------ 2 runner runner 60 Nov 11 08:05 . drwxr-xr-x 6 runner runner 120 Nov 11 08:05 .. -rw------- 1 runner runner 491 Nov 11 08:05 t.html Command '/usr/bin/chromium-browser' requires the chromium snap to be installed. Please install it with: snap install chromium
Bashcd /tmp/probe && (timeout 20 curl -sI https://registry.npmjs.org/puppeteer | head -3); (timeout 20 curl -sI https://pypi.org/simple/playwright/ | head -3); pip --version 2>&1 | head -1; ls ~/.cache 2>/dev/null; which xvfb-run Xvfb 2>&1 | head
command
cd /tmp/probe && (timeout 20 curl -sI https://registry.npmjs.org/puppeteer | head -3); (timeout 20 curl -sI https://pypi.org/simple/playwright/ | head -3); pip --version 2>&1 | head -1; ls ~/.cache 2>/dev/null; which xvfb-run Xvfb 2>&1 | head
result, 10 lines
HTTP/2 200 date: Wed, 11 Nov 2026 08:05:37 GMT content-type: application/json HTTP/2 200 server: gunicorn access-control-expose-headers: X-PyPI-Last-Serial pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10) /usr/bin/xvfb-run /usr/bin/Xvfb Shell cwd was reset to ~/run
agent
+1:02Setting up a headless browser so I can actually see and test what I build before handing it over — then I'll commit to the concept and build.
Bashmkdir -p /tmp/tools && cd /tmp/tools && npm init -y >/dev/null 2>&1 && timeout 280 npm i playwright 2>&1 | tail -3 && timeout 280 npx playwright install chromium 2>&1 | tail -3; ls ~/.cache/ms-playwright 2>/dev/nullerror
command
mkdir -p /tmp/tools && cd /tmp/tools && npm init -y >/dev/null 2>&1 && timeout 280 npm i playwright 2>&1 | tail -3 && timeout 280 npx playwright install chromium 2>&1 | tail -3; ls ~/.cache/ms-playwright 2>/dev/null
result, error, 7 lines
Exit code 2 added 2 packages, and audited 3 packages in 3s found 0 vulnerabilities |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ | 90% of 125.9 MiB |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■| 100% of 125.9 MiB Chrome Headless Shell 158.0.8127.18 (playwright chromium-headless-shell v1254) downloaded to /opt/ms-playwright/chromium_headless_shell-1254
Bashls /opt/ms-playwright/ ~/.cache/ms-playwright 2>&1; cd /tmp/tools && cat > probe.js <<'EOF'
command
ls /opt/ms-playwright/ ~/.cache/ms-playwright 2>&1; cd /tmp/tools && cat > probe.js <<'EOF' const { chromium } = require('playwright'); (async () => { const b = await chromium.launch({ args: ['--use-gl=angle','--use-angle=swiftshader','--enable-unsafe-swiftshader','--ignore-gpu-blocklist','--enable-webgl'] }); const p = await b.newPage({ viewport: { width: 800, height: 400 } }); await p.goto('file:///tmp/probe/t.html'); await p.waitForTimeout(500); console.log(await p.title()); await p.screenshot({ path: '/tmp/probe/s.png' }); await b.close(); })().catch(e => { console.error(String(e).slice(0, 1500)); process.exit(1); }); EOF timeout 100 node probe.jsresult, 16 lines
ls: cannot access '~/.cache/ms-playwright': No such file or directory /opt/ms-playwright/: chromium-1200 chromium-1208 chromium-1248 chromium-1254 chromium_headless_shell-1200 chromium_headless_shell-1208 chromium_headless_shell-1248 chromium_headless_shell-1254 ffmpeg-1011 ffmpeg-1013 firefox-1555 webkit-2370 GL2 WebGL 2.0 (OpenGL ES 3.0 Chromium) | cbf Shell cwd was reset to ~/run
Write/tmp/tools/gen.js
input
/tmp/tools/gen.js /*GEN*/ // ─────────────────────────────────────────────────────────────────────────── // THE LABYRINTH (pure functions, no DOM — everything below is computed at load) // ─────────────────────────────────────────────────────────────────────────── function rng32(a) { // mulberry32: tiny, seedable, good enough return function () { a |= 0; a = a + 0x6D2B79F5 | 0; let t = Math.imul(a ^ a >>> 15, 1 | a); t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t; return ((t ^ t >>> 14) >>> 0) / 4294967296; }; } // The handwriting. Five letters, drawn as pen strokes: [width, ...segments]. // Units: x-height = 10, baseline y = 0, y grows downward. Slanted afterwards. const cubic = (a, b, c, d) => t => { const u = 1 - t, k0 = u * u * u, k1 = 3 * u * u * t, k2 = 3 * u * t * t, k3 = t * t * t; return [k0 * a[0] + k1 * b[0] + k2 * c[0] + k3 * d[0], k0 * a[1] + k1 * b[1] + k2 * c[1] + k3 * d[1]]; }; const line = (a, b) => t => [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t]; const arc = (cx, cy, rx, ry, a0, a1) => t => { const a = (a0 + (a1 - a0) * t) * Math.PI / 180; return [cx + rx * Math.cos(a), cy + ry * Math.sin(a)]; }; const PEN = 2.3, HAIR = 1.5; const STROKES = [ // the lead-in: the thread comes in from the door and swoops into the foot of the F [HAIR, cubic([-11, -2.5], [-7.5, -5.5], [-4, 2], [0, -1.5])], // F [PEN, cubic([0, -1.5], [2.5, 1.2], [5.6, 0.6], [6.6, -3]), cubic([6.6, -3], [7.6, -6], [7.6, -13], [8, -20.3])], [PEN, cubic([0.3, -17.3], [0.8, -21.6], [4, -21.8], [7.5, -20.6]), cubic([7.5, -20.6], [10.5, -19.6], [13.5, -19.4], [15.8, -22.6])], [PEN, cubic([3.6, -10.2], [7, -11.6], [11, -9.4], [17.2, -10.3])], // a [PEN, arc(18.6, -5, 4.5, 5, 0, 360)], [PEN, line([23.1, -10], [23.1, -2.6]), cubic([23.1, -2.6], [23.2, 0.4], [26, 0.6], [28.6, -3.5])], // b [PEN, line([28.6, -21], [28.6, -0.4])], [PEN, arc(33.1, -5, 4.5, 5, 0, 360)], [PEN, cubic([36.6, -8.2], [38.2, -9.6], [39.8, -9.8], [41.8, -9.2])], // l [PEN, line([41.8, -21], [41.8, -3]), cubic([41.8, -3], [41.9, 0.4], [44.6, 0.7], [46.6, -2]), line([46.6, -2], [47.6, -4.4])], // e, and the flick that ends at the monster [PEN, line([47.2, -4.4], [56, -6.1]), arc(51.6, -5, 4.7, 5, -14, -322)], [PEN, cubic([55.3, -1.9], [57.6, 0.3], [60.6, -0.4], [63.4, -4.6])], ]; const SLANT = 0.2; // Rasterise the strokes onto a coarse grid (each coarse cell will become 2×2 corridors). function wordMask(CW, CH, scale, ox, oy) { const pts = []; for (const [w, ...segs] of STROKES) for (const f of segs) for (let i = 0; i <= 240; i++) { const [x, y] = f(i / 240); pts.push([(x - y * SLANT) * scale + ox, y * scale + oy, w * scale / 2]); } const m = new Uint8Array(CW * CH); for (let Y = 0; Y < CH; Y++) for (let X = 0; X < CW; X++) { let hit = 0; for (let sy = 0; sy < 3; sy++) for (let sx = 0; sx < 3; sx++) { const px = X + (sx + .5) / 3, py = Y + (sy + .5) / 3; for (const [qx, qy, r] of pts) if ((px - qx) ** 2 + (py - qy) ** 2 < r * r) { hit++; break; } } if (hit >= 4) m[X + Y * CW] = 1; } return m; } /*END GEN*/ if (typeof module !== 'undefined') module.exports = { rng32, wordMask, STROKES };result, 1 line
File created successfully at: /tmp/tools/gen.js (file state is current in your context — no need to Read it back)
Bashcd /tmp/tools && cat > shape.js <<'EOF'
command
cd /tmp/tools && cat > shape.js <<'EOF' const g = require('./gen.js'); const CW = +process.argv[2] || 96, CH = +process.argv[3] || 48, s = +process.argv[4] || 1.25; const ox = +process.argv[5] || 13.5, oy = +process.argv[6] || 37; const m = g.wordMask(CW, CH, s, ox, oy); let n = 0; for (let y = 0; y < CH; y++) { let r = ''; for (let x = 0; x < CW; x++) { r += m[x + y * CW] ? '█' : '·'; n += m[x + y * CW]; } console.log(r); } console.log(n, 'coarse cells', n * 4, 'fine'); EOF node shape.jsresult, 50 lines
································································································ ································································································ ································································································ ································································································ ································································································ ································································································ ································································································ ······································██························································ ·····································███························································ ·····················███████········████··············█···············██························ ····················███████████··██████··············███··············██························ ···················███████████████████···············███·············███························ ··················████····███████████················███·············███························ ·················████······███··█···················███··············███························ ·················███······███·······················███··············███························ ·················███······███·······················███··············███························ ·················██·······███·······················███·············███························· ··························███·······················███·············███························· ·························███·······················███··············███························· ·························███·······················███··············███························· ·························███·······················███··············███························· ·························███·······················███·············███·························· ·····················███████·······················███·············███·························· ···················███████████████████████··██····███··█████·······███········█████············· ···················███████████████████████████····████████████████████······█████████··········· ····················██··███·██████████████████····████████████████████·····███████████·········· ·······················███·······████····█████····██████···██████████·····█████···████·········· ·······················███······████······████····████······███···███····████······████········· ·······················███·····████·······████···████·······███···███···████······█████········· ······················████·····███········███····████·······███···███···███████████████········· ······················███······███········███····███········███···███···██████████████·······██· ······················███······███········███····███········███··███····██████████··········███· ·████················████······███·······████···████·······████··███····████···············████· ███████··············███·······███·······████··█████·······███···███···████·······██·····█████·· █···████····███·····████·······████····█████··███████·····████···███··██████·····█████·██████··· ······███████████·█████·········████·████████████████████████····███████████████████████████···· ········██████████████··········████████████████████████████·····███████·█████████████████······ ··············███████············████████··████·██··███████·······█████····███████···███········ ················███············································································· ································································································ ································································································ ································································································ ································································································ ································································································ ································································································ ································································································ ································································································ ································································································ 849 coarse cells 3396 fine Shell cwd was reset to ~/run
agent
+16:09reasoning
The concept is set as "A Fabled Clue," a 3D labyrinth whose one true path is a golden thread that turns out to be handwriting. The letterforms now rasterize legibly, so I'm building the maze generator around them.
Bashcd /tmp/tools && python3 - <<'EOF'
command
cd /tmp/tools && python3 - <<'EOF' import re s=open('gen.js').read() s=s.replace("[PEN, cubic([3.6, -10.2], [7, -11.6], [11, -9.4], [17.2, -10.3])],","[PEN, cubic([3.4, -11.6], [7, -12.8], [10.5, -10.6], [15.6, -9.4])],") s=s.replace("[PEN, cubic([36.6, -8.2], [38.2, -9.6], [39.8, -9.8], [41.8, -9.2])],","[PEN, cubic([37.2, -6.6], [38.6, -8.6], [40, -9.2], [41.8, -8.8])],") s=s.replace("const PEN = 2.3, HAIR = 1.5;","const PEN = 2.15, HAIR = 1.5;") open('gen.js','w').write(s) EOF node shape.js 104 52 1.36 14 40.5result, 54 lines
········································································································ ········································································································ ········································································································ ········································································································ ········································································································ ········································································································ ········································································································ ········································································································ ·········································█······························································ ········································███····························································· ·······················██████·········█████···············█·················█··························· ·····················███████████····██████···············███···············███·························· ····················█████████████████████················███···············███·························· ···················█████····████████████·················███···············███·························· ··················████······█████████····················███··············████·························· ··················███·······███·························███···············███··························· ··················███·······███·························███···············███··························· ··················███·······███·························███···············███··························· ···························████·························███···············███··························· ···························███··························███··············████··························· ···························███·························███···············███···························· ···························███·························███···············███···························· ··························████·························███···············███···························· ·····················█████████·························███···············███···························· ····················█████████████······················███··············████···························· ····················████████████████·····██····██·····███···███·········███···········██················ ·························█████████████████████·███····███████████·······███········████████············· ·························███····██████████████████····████████████···██████······███████████············ ·························███·······██████··██████·····███████·█████████████·····██████··█████··········· ·························███·······████·····█████·····█████·····███████████····█████······███··········· ························████······████·······████····█████·······█████·███·····███········███··········· ························███·······███········████····████········████··███····████·····███████·········· ························███······████········████····███·········███···███····████████████████·········· ·······················████······███·········███·····███·········███···███····███████████████·······███· ·······················███·······███·········███·····███·········███··████····██████████···········████· █████·················████·······███········████····████········████··███····█████················████·· ██████················████·······███········████···█████········███···███····████········█·······████··· █···████·····███·····████········████······█████··██████·······████···███···█████·······████···█████···· ·····█████··█████···████··········████···████████████████····█████····███·████████····█████████████····· ·······█████████████████··········███████████████████████████████·····████████████████████████████······ ·········████·█████████············█████████·██████·████████████·······██████···█████████·██████········ ···············██████················█████··············██████··········███······██████················· ········································································································ ········································································································ ········································································································ ········································································································ ········································································································ ········································································································ ········································································································ ········································································································ ········································································································ ········································································································ 954 coarse cells 3816 fine Shell cwd was reset to ~/run
Bashcd /tmp/tools && python3 - <<'EOF'
command
cd /tmp/tools && python3 - <<'EOF' s=open('gen.js').read() add = r''' // Build the whole labyrinth from a seed. // 1. Rasterise the word onto a coarse grid; partition the rest into random blobs. // 2. Grow a random spanning tree inside every region. // 3. Double the resolution and walk *around* each tree: that turns every region into a // single closed corridor visiting each of its cells once (a Hamiltonian cycle). // 4. Cut every loop once, then join the regions with doors chosen by random Kruskal. // The result is a perfect maze — one route between any two cells — in which the route // from IN to OUT is forced to pass through every cell of the handwriting and no others. function buildLabyrinth(seed, CW = 104, CH = 52) { const rnd = rng32(seed), ri = n => rnd() * n | 0; const shuffle = a => { for (let i = a.length - 1; i > 0; i--) { const j = ri(i + 1), t = a[i]; a[i] = a[j]; a[j] = t; } return a; }; const DX = [1, 0, -1, 0], DY = [0, 1, 0, -1]; // E S W N const W = CW * 2, H = CH * 2, N = W * H, CN = CW * CH; const word = wordMask(CW, CH, 1.36, 14, 40.5); // 1 ─ regions const reg = new Int32Array(CN).fill(-1); for (let i = 0; i < CN; i++) if (word[i]) reg[i] = 0; let nReg = 1; for (const s of shuffle([...reg.keys()])) { if (reg[s] >= 0) continue; const id = nReg++, want = 2 + ri(4) * ri(9), front = [s]; reg[s] = id; for (let size = 1; size < want && front.length;) { const c = front[ri(front.length)], d = ri(4), x = c % CW + DX[d], y = (c / CW | 0) + DY[d], n = x + y * CW; if (x >= 0 && y >= 0 && x < CW && y < CH && reg[n] < 0) { reg[n] = id; front.push(n); size++; } else if (rnd() < .2) front.splice(front.indexOf(c), 1); } } // 2 ─ a spanning tree per region ("growing tree": mostly depth-first, sometimes not) const tree = new Uint8Array(CN), seen = new Uint8Array(CN); const root = word.findIndex((v, i) => v && i % CW === 0); const grow = s => { const live = [s]; seen[s] = 1; while (live.length) { const k = rnd() < .62 ? live.length - 1 : ri(live.length), c = live[k], x = c % CW, y = c / CW | 0; const opts = []; for (let d = 0; d < 4; d++) { const nx = x + DX[d], ny = y + DY[d], n = nx + ny * CW; if (nx >= 0 && ny >= 0 && nx < CW && ny < CH && !seen[n] && reg[n] === reg[c]) opts.push(d); } if (!opts.length) { live.splice(k, 1); continue; } const d = opts[ri(opts.length)], n = c + DX[d] + DY[d] * CW; tree[c] |= 1 << d; tree[n] |= 1 << (d ^ 2); seen[n] = 1; live.push(n); } }; grow(root); for (let i = 0; i < CN; i++) if (!seen[i]) grow(i); // 3 ─ walk around the trees at double resolution const open = new Uint8Array(N); // bit d set ⇒ passage in direction d const link = (x, y, d) => { open[x + y * W] |= 1 << d; open[x + DX[d] + (y + DY[d]) * W] |= 1 << (d ^ 2); }; const unlink = (x, y, d) => { open[x + y * W] &= ~(1 << d); open[x + DX[d] + (y + DY[d]) * W] &= ~(1 << (d ^ 2)); }; for (let c = 0; c < CN; c++) { const x = 2 * (c % CW), y = 2 * (c / CW | 0), t = tree[c]; if (t & 1) { link(x + 1, y, 0); link(x + 1, y + 1, 0); } else link(x + 1, y, 1); if (t & 2) { link(x, y + 1, 1); link(x + 1, y + 1, 1); } else link(x, y + 1, 0); if (!(t & 4)) link(x, y, 1); if (!(t & 8)) link(x, y, 0); } // 4 ─ cut each loop once; the word's loop is cut at the door, giving IN and OUT const cut = new Uint8Array(nReg); const A = 2 * (root / CW | 0) * W, B = A + W; // two cells on the west wall unlink(0, A / W, 1); cut[0] = 1; for (const c of shuffle([...reg.keys()])) { if (cut[reg[c]]) continue; const x = 2 * (c % CW), y = 2 * (c / CW | 0), d = ri(4); if (tree[c] >> d & 1) continue; unlink(...[[x + 1, y, 1], [x, y + 1, 0], [x, y, 1], [x, y, 0]][d]); cut[reg[c]] = 1; } // doors between regions: random Kruskal over every wall that separates two regions const uf = [...Array(nReg).keys()], find = i => uf[i] === i ? i : (uf[i] = find(uf[i])); const walls = []; for (let y = 0; y < H; y++) for (let x = 0; x < W; x++) for (let d = 0; d < 2; d++) { const nx = x + DX[d], ny = y + DY[d]; if (nx < W && ny < H && reg[(x >> 1) + (y >> 1) * CW] !== reg[(nx >> 1) + (ny >> 1) * CW]) walls.push([x, y, d]); } let doors = 0; for (const [x, y, d] of shuffle(walls)) { const a = find(reg[(x >> 1) + (y >> 1) * CW]), b = find(reg[(x + DX[d] >> 1) + (y + DY[d] >> 1) * CW]); if (a !== b) { uf[a] = b; link(x, y, d); doors++; } } // 5 ─ flood from IN: parents give the unique route to anywhere const parent = new Int32Array(N).fill(-1), order = [A]; parent[A] = A; for (let i = 0; i < order.length; i++) { const c = order[i]; for (let d = 0; d < 4; d++) if (open[c] >> d & 1) { const n = c + DX[d] + DY[d] * W; if (parent[n] < 0) { parent[n] = c; order.push(n); } } } const route = c => { const r = [c]; while (c !== A) r.push(c = parent[c]); return r.reverse(); }; const path = route(B); // 6 ─ the self-check: none of this is taken on trust let passages = 0, inWord = 0; for (let c = 0; c < N; c++) passages += (open[c] & 1) + (open[c] >> 1 & 1); for (const c of path) inWord += word[(c % W >> 1) + (c / W >> 1) * CW]; const wordCells = 4 * word.reduce((a, b) => a + b, 0); const proof = { cells: N, passages, reached: order.length, regions: nReg, doors, pathLength: path.length, wordCells, pathInsideWord: inWord, perfect: order.length === N && passages === N - 1, exact: path.length === wordCells && inWord === wordCells, }; // the monster waits at the far end of the last letter let lair = 0; path.forEach((c, i) => { if (c % W > path[lair] % W) lair = i; }); return { W, H, N, CW, CH, word, reg, open, parent, route, path, A, B, lair, proof, DX, DY }; } /*END GEN*/''' s=s.replace("/*END GEN*/\nif", add+"\nif").replace("module.exports = { rng32, wordMask, STROKES }","module.exports = { rng32, wordMask, STROKES, buildLabyrinth }") open('gen.js','w').write(s) EOF cat > maze.js <<'EOF' const g = require('./gen.js'), fs = require('fs'); const seed = +process.argv[2] || 52; const t0 = Date.now(); const L = g.buildLabyrinth(seed); console.log(JSON.stringify(L.proof), 'ms', Date.now() - t0, 'lair', L.lair, (L.lair / L.path.length).toFixed(3)); // stats: dead ends let dead = 0, junc = 0; for (let c = 0; c < L.N; c++) { const k = [0,1,2,3].filter(d => L.open[c] >> d & 1).length; if (k == 1) dead++; if (k > 2) junc++; } console.log('dead ends', dead, 'junctions', junc); const S = 6, { W, H } = L, w = W * S + 1, h = H * S + 1; function render(file, upto) { const px = Buffer.alloc(w * h * 3); const idx = new Int32Array(L.N).fill(-1); L.path.forEach((c, i) => idx[c] = i); for (let y = 0; y < h; y++) for (let x = 0; x < w; x++) { const cx = Math.min(W - 1, x / S | 0), cy = Math.min(H - 1, y / S | 0), c = cx + cy * W, fx = x % S, fy = y % S; let wall = false; if (x == w - 1 || y == h - 1) wall = true; else if (fx == 0 && fy == 0) wall = true; else if (fx == 0) wall = cx == 0 ? !(c == L.A || c == L.B) : !(L.open[c] >> 2 & 1); else if (fy == 0) wall = cy == 0 ? true : !(L.open[c] >> 3 & 1); const lit = idx[c] >= 0 && idx[c] < upto; const o = (x + y * w) * 3; if (wall) { px[o] = 150; px[o + 1] = 165; px[o + 2] = 190; } else if (lit) { px[o] = 255; px[o + 1] = 190; px[o + 2] = 60; } else { px[o] = 14; px[o + 1] = 16; px[o + 2] = 24; } } fs.writeFileSync('/tmp/probe/m.ppm', Buffer.concat([Buffer.from(`P6 ${w} ${h} 255\n`), px])); require('child_process').execSync(`convert /tmp/probe/m.ppm ${file}`); } render('/tmp/probe/maze_unlit.png', 0); render('/tmp/probe/maze_lit.png', 1e9); render('/tmp/probe/maze_half.png', L.lair); EOF node maze.js 52result, 3 lines
{"cells":21632,"passages":21657,"reached":21632,"regions":1146,"doors":1145,"pathLength":3816,"wordCells":3816,"pathInsideWord":3816,"perfect":false,"exact":true} ms 4385 lair 2889 0.757 dead ends 1779 junctions 1798 Shell cwd was reset to ~/run