aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordax <me@dax.ist>2026-08-04 08:49:29 +0000
committerdax <me@dax.ist>2026-08-04 08:49:29 +0000
commit51062d0579eba3c8137298a88963eb6aeb57c2e2 (patch)
treeba7f576a6dd22929473f91ae0122afff79e343b9
parentfe060ee95e000004bcdea9e8788d92cea33eaa80 (diff)
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)
-rw-r--r--public/app.js4
-rw-r--r--public/index.html4
-rw-r--r--server.mjs12
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 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="color-scheme" content="dark">
<title>pathways</title>
- <link rel="stylesheet" href="/app.css?v=9">
+ <link rel="stylesheet" href="/app.css?v=10">
</head>
<body>
<main id="stage">
@@ -16,6 +16,6 @@
<p>four paths, one per direction. walk them.<br><span class="hint">drag or scroll to pan · pinch to zoom · double-click empty space or press 0 to fit</span></p>
<button id="start">start</button>
</div>
- <script src="/app.js?v=9"></script>
+ <script src="/app.js?v=10"></script>
</body>
</html>
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)