From 51062d0579eba3c8137298a88963eb6aeb57c2e2 Mon Sep 17 00:00:00 2001 From: dax Date: Tue, 4 Aug 2026 08:49:29 +0000 Subject: pathways: four directions lead to four distinct photos - dedupe per-photo next ids in exit generation (server), exclude other directions' targets from placement candidates (client) --- public/app.js | 4 +++- public/index.html | 4 ++-- server.mjs | 12 ++++++++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/public/app.js b/public/app.js index e4fa727..98dcaed 100644 --- a/public/app.js +++ b/public/app.js @@ -253,9 +253,11 @@ function choosePlacement(id, dir) { if (!ex) return null const from = tiles.get(id).rect const seen = new Set() + const claimed = new Set() + if (exits) for (const e of exits) if (e.dir !== dir && e.next) claimed.add(e.next.id) const candIds = [] const addCand = (cid) => { - if (cid && !seen.has(cid) && !rectOf.has(cid)) { + if (cid && !claimed.has(cid) && !seen.has(cid) && !rectOf.has(cid)) { seen.add(cid) candIds.push(cid) } diff --git a/public/index.html b/public/index.html index 51e3ef3..1134334 100644 --- a/public/index.html +++ b/public/index.html @@ -5,7 +5,7 @@ pathways - +
@@ -16,6 +16,6 @@

four paths, one per direction. walk them.
drag or scroll to pan · pinch to zoom · double-click empty space or press 0 to fit

- + diff --git a/server.mjs b/server.mjs index 6659426..b73c44e 100644 --- a/server.mjs +++ b/server.mjs @@ -119,6 +119,7 @@ async function load() { const chosen = own.slice(0, 4) while (chosen.length < 4) chosen.push(library) const used = new Map() + const usedNext = new Set() const list = [] for (let i = 0; i < 4; i++) { const p = chosen[i] @@ -129,11 +130,18 @@ async function load() { const start = (idx + 1 + step) % cyc.length const walk = [] for (let k = 0; k < 60 && walk.length < cyc.length; k++) walk.push(cyc[(start + k) % cyc.length]) + let nextId = cyc[start] + for (const wid of walk) { + if (wid !== pid && !usedNext.has(wid)) { nextId = wid; break } + } + usedNext.add(nextId) + const wi = walk.indexOf(nextId) + const rot = wi > 0 ? walk.slice(wi).concat(walk.slice(0, wi)) : walk list.push({ dir: DIRS[i], path: { type: p.type, name: p.name, count: p.count }, - nextId: cyc[start], - walk, + nextId, + walk: rot, }) } exits.set(pid, list) -- cgit v1.3.1