diff options
| -rw-r--r-- | public/app.js | 7 | ||||
| -rw-r--r-- | public/index.html | 4 | ||||
| -rw-r--r-- | server.mjs | 8 |
3 files changed, 16 insertions, 3 deletions
diff --git a/public/app.js b/public/app.js index 1c98d84..57827fa 100644 --- a/public/app.js +++ b/public/app.js @@ -274,6 +274,13 @@ function choosePlacement(id, dir) { const p = bestPlacement(tileW(info), tileH(info), from, dir) if (p) scored.push({ id: cid, info, rect: p.rect, cost: p.cost }) } + if (!scored.length) { + for (const [cid, info] of photoInfo) { + if (rectOf.has(cid) || cid === id) continue + const p = bestPlacement(tileW(info), tileH(info), from, dir) + if (p) scored.push({ id: cid, info, rect: p.rect, cost: p.cost + (claimed.has(cid) ? 1e12 : 0) }) + } + } if (!scored.length) return null scored.sort((a, b) => a.cost - b.cost) const best = scored[0] diff --git a/public/index.html b/public/index.html index 2de35c3..d38008c 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=12"> + <link rel="stylesheet" href="/app.css?v=13"> </head> <body> <main id="stage"> @@ -16,6 +16,6 @@ <p>four paths, one per direction. walk them.</p> <button id="start">start</button> </div> - <script src="/app.js?v=12"></script> + <script src="/app.js?v=13"></script> </body> </html> @@ -137,11 +137,17 @@ async function load() { usedNext.add(nextId) const wi = walk.indexOf(nextId) const rot = wi > 0 ? walk.slice(wi).concat(walk.slice(0, wi)) : walk + const li = library.ids.indexOf(pid) + const ext = rot.slice() + for (let k = 1; ext.length < 60 && k < library.ids.length; k++) { + const wid = library.ids[(li + k) % library.ids.length] + if (wid !== pid && !ext.includes(wid)) ext.push(wid) + } list.push({ dir: DIRS[i], path: { type: p.type, name: p.name, count: p.count }, nextId, - walk: rot, + walk: ext, }) } exits.set(pid, list) |
