chore: align formatting checks with generated geography data

This commit is contained in:
coyotte508 2026-10-05 01:35:46 +02:00
commit 8bdce611bb
10 changed files with 300 additions and 115 deletions

View file

@ -5,3 +5,10 @@ viewer/package.json
engine/package.json engine/package.json
.pnpm-store/ .pnpm-store/
**/dist/ **/dist/
# Generated reports and geographic data preserve the generators' formatting.
ai/strong/handoff/*.json
viewer/scripts/geography/*.json
viewer/src/geography/assets/*.json
viewer/src/geography/names.json
viewer/src/geography/loaders.ts

View file

@ -35,19 +35,19 @@ multi-map support based on feature encoding alone.
## Where everything lives ## Where everything lives
| Material | Location | | Material | Location |
| --- | --- | | ---------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| Canonical source | [boardgamers/powergrid](https://github.com/boardgamers/powergrid), `ai/` and `ai/strong/` | | Canonical source | [boardgamers/powergrid](https://github.com/boardgamers/powergrid), `ai/` and `ai/strong/` |
| Complete experiment ledger | [strong/experiments.json](strong/experiments.json): source/model revisions, job IDs, reports, counterexamples and decisions | | Complete experiment ledger | [strong/experiments.json](strong/experiments.json): source/model revisions, job IDs, reports, counterexamples and decisions |
| Strong-policy background | [strong/README.md](strong/README.md), historical and partly stale | | Strong-policy background | [strong/README.md](strong/README.md), historical and partly stale |
| Baseline background | [README.md](README.md) | | Baseline background | [README.md](README.md) |
| Private checkpoints, ONNX, reports, serving archives | [coyotte508/powergrid-ai-germany-v1](https://huggingface.co/coyotte508/powergrid-ai-germany-v1) (name predates multiplayer work) | | Private checkpoints, ONNX, reports, serving archives | [coyotte508/powergrid-ai-germany-v1](https://huggingface.co/coyotte508/powergrid-ai-germany-v1) (name predates multiplayer work) |
| Private immutable source bundles and data | [coyotte508/powergrid-ai-training-v1](https://huggingface.co/datasets/coyotte508/powergrid-ai-training-v1) | | Private immutable source bundles and data | [coyotte508/powergrid-ai-training-v1](https://huggingface.co/datasets/coyotte508/powergrid-ai-training-v1) |
| Multiplayer final gate | [strong/final-protocol-multiplayer.json](strong/final-protocol-multiplayer.json) | | Multiplayer final gate | [strong/final-protocol-multiplayer.json](strong/final-protocol-multiplayer.json) |
| Earlier 3p gate | [strong/final-protocol.json](strong/final-protocol.json) | | Earlier 3p gate | [strong/final-protocol.json](strong/final-protocol.json) |
| Latest admission comparison protocol | [strong/league-admission-protocol-v1.json](strong/league-admission-protocol-v1.json) | | Latest admission comparison protocol | [strong/league-admission-protocol-v1.json](strong/league-admission-protocol-v1.json) |
| Collected diagnostic summary | [strong/handoff/teacher-reliability-v2-summary.json](strong/handoff/teacher-reliability-v2-summary.json) | | Collected diagnostic summary | [strong/handoff/teacher-reliability-v2-summary.json](strong/handoff/teacher-reliability-v2-summary.json) |
| Sanitized resume manifest | [strong/handoff/status-2026-10-04.json](strong/handoff/status-2026-10-04.json) | | Sanitized resume manifest | [strong/handoff/status-2026-10-04.json](strong/handoff/status-2026-10-04.json) |
Local canonical checkout: `/home/eliheros/code/powergrid`. Source before this Local canonical checkout: `/home/eliheros/code/powergrid`. Source before this
handoff was `face347f258a057c2ed3fb4e4606fce2003ab4c1`; AI research was integrated handoff was `face347f258a057c2ed3fb4e4606fce2003ab4c1`; AI research was integrated
@ -116,12 +116,12 @@ plus frozen A260 at 3p (480). Full rule-level breakdowns and deal-cluster interv
are in each corresponding ledger entry. Aggregate rates cannot override a weak are in each corresponding ledger entry. Aggregate rates cannot override a weak
rule cell. Search is off for these candidates. rule cell. Search is off for these candidates.
| Candidate | Econ 2p | 3p | 4p | 5p | 6p | Frozen A260 3p | | Candidate | Econ 2p | 3p | 4p | 5p | 6p | Frozen A260 3p |
| --- | ---: | ---: | ---: | ---: | ---: | ---: | | ----------------------------------- | ------: | ----: | ----: | ----: | ----: | -------------: |
| H200 update 79 | 63.44 | 60.83 | 59.69 | 77.69 | 73.28 | 33.54 | | H200 update 79 | 63.44 | 60.83 | 59.69 | 77.69 | 73.28 | 33.54 |
| Geographic league update 79 | 52.34 | 59.90 | 54.53 | 71.44 | 65.99 | 33.33 | | Geographic league update 79 | 52.34 | 59.90 | 54.53 | 71.44 | 65.99 | 33.33 |
| Admission “best” update 19 | 52.81 | 56.67 | 57.66 | 79.19 | 74.58 | 39.58 | | Admission “best” update 19 | 52.81 | 56.67 | 57.66 | 79.19 | 74.58 | 39.58 |
| Admission periodic-anchor update 19 | 60.31 | 57.40 | 61.72 | 74.94 | 70.16 | 36.04 | | Admission periodic-anchor update 19 | 60.31 | 57.40 | 61.72 | 74.94 | 70.16 | 36.04 |
None passes the 66.25% economic/2p and 40% A260/3p floors together. Geographic None passes the 66.25% economic/2p and 40% A260/3p floors together. Geographic
update 79 also fails the strict export tolerance on one logit (although all update 79 also fails the strict export tolerance on one logit (although all
@ -132,13 +132,13 @@ external-strength selector; admission comparison had one training seed.
Pinned checkpoints in the private model repo: Pinned checkpoints in the private model repo:
| Candidate | HF revision | File | SHA256 | | Candidate | HF revision | File | SHA256 |
| --- | --- | --- | --- | | ----------------------- | ------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ |
| H200 u79 | `0aeacd5b8e36ece36ba06a77ddfd7b86110d4f3a` | `runs/multiplayer-refine-hard-v1/latest.onnx` | `2f1dd42625ea86404155e63124e55d95d07016027a0ceda4e08164357b554927` | | H200 u79 | `0aeacd5b8e36ece36ba06a77ddfd7b86110d4f3a` | `runs/multiplayer-refine-hard-v1/latest.onnx` | `2f1dd42625ea86404155e63124e55d95d07016027a0ceda4e08164357b554927` |
| Geographic u79 | `035345f5f05bbbb55af5e0f4884d07f9087b1e32` | `runs/multiplayer-refine-geoleague-async-v1/latest.onnx` | `35deffdacefdc3d3638417b1590432b84a86f3fb302958e273f5eeea9ad7ce34` | | Geographic u79 | `035345f5f05bbbb55af5e0f4884d07f9087b1e32` | `runs/multiplayer-refine-geoleague-async-v1/latest.onnx` | `35deffdacefdc3d3638417b1590432b84a86f3fb302958e273f5eeea9ad7ce34` |
| Admission best u19 | `efdb82f2712b8c6648100d7ad99b6941102f7001` | `runs/multiplayer-league-admission-v1-best/latest.onnx` | `691a91ae58d5946a396fe595ffba2f866b5bfba6533ec504da9e6a134c07750e` | | Admission best u19 | `efdb82f2712b8c6648100d7ad99b6941102f7001` | `runs/multiplayer-league-admission-v1-best/latest.onnx` | `691a91ae58d5946a396fe595ffba2f866b5bfba6533ec504da9e6a134c07750e` |
| Periodic-anchor u19 | `efdb82f2712b8c6648100d7ad99b6941102f7001` | `runs/multiplayer-league-admission-v1-periodic-anchor/latest.onnx` | `08ad0042e548e9b871e9f4178626d405637fb55f3f42b0d580b2bd6979ac7f67` | | Periodic-anchor u19 | `efdb82f2712b8c6648100d7ad99b6941102f7001` | `runs/multiplayer-league-admission-v1-periodic-anchor/latest.onnx` | `08ad0042e548e9b871e9f4178626d405637fb55f3f42b0d580b2bd6979ac7f67` |
| Frozen 3p A260 opponent | `b38515c29e57826de05b55b645c29591e4a886bf` | `runs/strong-league-v2-a/best.onnx` | `9b46db558669a0c3085412fe2544359eda55ed9f092dffb67bead6af3c409ecd` | | Frozen 3p A260 opponent | `b38515c29e57826de05b55b645c29591e4a886bf` | `runs/strong-league-v2-a/best.onnx` | `9b46db558669a0c3085412fe2544359eda55ed9f092dffb67bead6af3c409ecd` |
Earlier H200 update 29 (revision Earlier H200 update 29 (revision
`fbdf2bf24c968bff99ab2d7d9ff9a7d97047db2b`, same hard-refinement model path, `fbdf2bf24c968bff99ab2d7d9ff9a7d97047db2b`, same hard-refinement model path,
@ -155,13 +155,13 @@ about the whole policy.
Jobs `teacher-reliability-v2-{2..6}p`, CPU-performance, submitted 1 October: Jobs `teacher-reliability-v2-{2..6}p`, CPU-performance, submitted 1 October:
| Players | Completed job | | Players | Completed job |
| --- | --- | | ------- | ------------------------------------------------------------------------------------------- |
| 2 | [6abe1df0fbc85ba682360bd8](https://huggingface.co/jobs/coyotte508/6abe1df0fbc85ba682360bd8) | | 2 | [6abe1df0fbc85ba682360bd8](https://huggingface.co/jobs/coyotte508/6abe1df0fbc85ba682360bd8) |
| 3 | [6abe1df1404719ba3761721e](https://huggingface.co/jobs/coyotte508/6abe1df1404719ba3761721e) | | 3 | [6abe1df1404719ba3761721e](https://huggingface.co/jobs/coyotte508/6abe1df1404719ba3761721e) |
| 4 | [6abe1df2fbc85ba682360bda](https://huggingface.co/jobs/coyotte508/6abe1df2fbc85ba682360bda) | | 4 | [6abe1df2fbc85ba682360bda](https://huggingface.co/jobs/coyotte508/6abe1df2fbc85ba682360bda) |
| 5 | [6abe1df2fbc85ba682360bdc](https://huggingface.co/jobs/coyotte508/6abe1df2fbc85ba682360bdc) | | 5 | [6abe1df2fbc85ba682360bdc](https://huggingface.co/jobs/coyotte508/6abe1df2fbc85ba682360bdc) |
| 6 | [6abe1df3fbc85ba682360be0](https://huggingface.co/jobs/coyotte508/6abe1df3fbc85ba682360be0) | | 6 | [6abe1df3fbc85ba682360be0](https://huggingface.co/jobs/coyotte508/6abe1df3fbc85ba682360be0) |
Immutable source: dataset revision `d07e072058ee877112d609280980fc806ee8ce28`, Immutable source: dataset revision `d07e072058ee877112d609280980fc806ee8ce28`,
`strong-source-v36.tgz`, SHA256 `strong-source-v36.tgz`, SHA256

View file

@ -28740,15 +28740,8 @@
"fixture_sha256": "855b34ad7f07665dfcb012a673147f0780820a9e7560fda268a9a39478c60ff4", "fixture_sha256": "855b34ad7f07665dfcb012a673147f0780820a9e7560fda268a9a39478c60ff4",
"positions": 60, "positions": 60,
"samples_per_batch": 384, "samples_per_batch": 384,
"batches": [ "batches": ["a", "b"],
"a", "continuations": ["mixed", "economic", "heuristic"],
"b"
],
"continuations": [
"mixed",
"economic",
"heuristic"
],
"search_max_steps": 2400, "search_max_steps": 2400,
"workers_per_job": 24, "workers_per_job": 24,
"jobs": [ "jobs": [

View file

@ -7,8 +7,17 @@ const require = createRequire(import.meta.url);
const engine = require('../../engine/dist/index.js'); const engine = require('../../engine/dist/index.js');
const wrapper = require('../../engine/dist/wrapper.js'); const wrapper = require('../../engine/dist/wrapper.js');
const mapKeys = Object.values(JSON.parse(await readFile(new URL('../src/geography/names.json', import.meta.url)))); const mapKeys = Object.values(JSON.parse(await readFile(new URL('../src/geography/names.json', import.meta.url))));
const geometry = Object.fromEntries(await Promise.all(mapKeys.map(async key => [key, JSON.parse(await readFile(new URL('../src/geography/assets/' + key + '.json', import.meta.url)))]))); const geometry = Object.fromEntries(
const maps = Object.fromEntries(Object.keys(geometry).map(key => [key, require(`../../engine/dist/src/maps/${key}.js`)])); await Promise.all(
mapKeys.map(async (key) => [
key,
JSON.parse(await readFile(new URL('../src/geography/assets/' + key + '.json', import.meta.url))),
])
)
);
const maps = Object.fromEntries(
Object.keys(geometry).map((key) => [key, require(`../../engine/dist/src/maps/${key}.js`)])
);
export function geographicPreviewState(key = 'germany', allRegions = true, variant = 'original', playerCount = 3) { export function geographicPreviewState(key = 'germany', allRegions = true, variant = 'original', playerCount = 3) {
const authored = variant === 'recharged' ? maps[key]?.mapRecharged || maps[key]?.map : maps[key]?.map; const authored = variant === 'recharged' ? maps[key]?.mapRecharged || maps[key]?.map : maps[key]?.map;
@ -29,7 +38,13 @@ export function geographicPreviewState(key = 'germany', allRegions = true, varia
const html = `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Powergrid · Geographic outlines</title><link rel="stylesheet" href="/powergrid-viewer.css"><style> const html = `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Powergrid · Geographic outlines</title><link rel="stylesheet" href="/powergrid-viewer.css"><style>
*{box-sizing:border-box}body{margin:0;background:#171717;color:#e8ece7;font:14px/1.4 system-ui}header{padding:14px 20px;border-bottom:1px solid #3e493e;display:flex;align-items:center;gap:18px;flex-wrap:wrap}header strong{margin-right:auto}header small{font-weight:400;color:#aeb9ad}label{display:flex;align-items:center;gap:7px}select,button{font:inherit;background:#263027;color:inherit;border:1px solid #63715f;border-radius:5px;padding:7px 10px}button{cursor:pointer}main{max-width:none;margin:auto;padding:16px}#map-only{width:100%;height:calc(100vh - 160px);min-height:380px;background:yellowgreen;border-radius:5px}#app{position:absolute;left:-20000px;width:1300px;visibility:hidden}body.full #app{position:static;left:auto;width:auto;visibility:visible}body.full #map-only{display:none}footer{padding:10px 0;color:#b7c2b2;font-size:12px}footer a{color:inherit}body.light{background:#e7ebda;color:#1d2a1d}body.light header{border-color:#a6b297}body.light select,body.light button{background:#f0f2e9;color:#1d2a1d}body.light small,body.light footer{color:#4c6043}#error{color:#ffaba0}svg .geographic-backdrop{pointer-events:none}@media(max-width:600px){header{padding:12px;gap:10px}header strong{width:100%}main{padding:10px}#map-only{height:calc(100vh - 240px)}} *{box-sizing:border-box}body{margin:0;background:#171717;color:#e8ece7;font:14px/1.4 system-ui}header{padding:14px 20px;border-bottom:1px solid #3e493e;display:flex;align-items:center;gap:18px;flex-wrap:wrap}header strong{margin-right:auto}header small{font-weight:400;color:#aeb9ad}label{display:flex;align-items:center;gap:7px}select,button{font:inherit;background:#263027;color:inherit;border:1px solid #63715f;border-radius:5px;padding:7px 10px}button{cursor:pointer}main{max-width:none;margin:auto;padding:16px}#map-only{width:100%;height:calc(100vh - 160px);min-height:380px;background:yellowgreen;border-radius:5px}#app{position:absolute;left:-20000px;width:1300px;visibility:hidden}body.full #app{position:static;left:auto;width:auto;visibility:visible}body.full #map-only{display:none}footer{padding:10px 0;color:#b7c2b2;font-size:12px}footer a{color:inherit}body.light{background:#e7ebda;color:#1d2a1d}body.light header{border-color:#a6b297}body.light select,body.light button{background:#f0f2e9;color:#1d2a1d}body.light small,body.light footer{color:#4c6043}#error{color:#ffaba0}svg .geographic-backdrop{pointer-events:none}@media(max-width:600px){header{padding:12px;gap:10px}header strong{width:100%}main{padding:10px}#map-only{height:calc(100vh - 240px)}}
</style></head><body><header><strong>Geographic outlines <small>Local preview</small></strong><label>Map <select id="map">${Object.entries(geometry).map(([key,map]) => '<option value="'+key+'">'+map.name.replaceAll('&','&amp;')+'</option>').join('')}</select></label><label>Backdrop <select id="style"><option value="terrain">Blue water + green land</option><option value="wash">Soft land + outline</option><option value="line">Outline only</option><option value="none">Off</option></select></label><label>Rules <select id="variant"><option value="original">Original</option><option value="recharged">Recharged</option></select></label><label><input type="checkbox" id="regions" checked> All regions</label><button id="full">Full board</button><button id="theme">Light mode</button></header><main><svg id="map-only" role="img" aria-label="Geographic outline behind the Power Grid network"></svg><div id="app"></div><div id="error" role="alert"></div><footer>Existing cities and links, with a fitted geographic backdrop. Hover a city for its name. <a href="https://www.naturalearthdata.com/about/terms-of-use/">Natural Earth</a> · <a href="https://www.geonames.org/">GeoNames (CC BY 4.0)</a> · <a href="https://data.cityofnewyork.us/d/gthc-hcne">NYC Open Data</a>. Local visual experiment; full-region view is illustrative.</footer></main><script src="/vue.js"></script><script src="/powergrid-viewer.umd.min.js"></script><script> </style></head><body><header><strong>Geographic outlines <small>Local preview</small></strong><label>Map <select id="map">${Object.entries(
geometry
)
.map(([key, map]) => '<option value="' + key + '">' + map.name.replaceAll('&', '&amp;') + '</option>')
.join(
''
)}</select></label><label>Backdrop <select id="style"><option value="terrain">Blue water + green land</option><option value="wash">Soft land + outline</option><option value="line">Outline only</option><option value="none">Off</option></select></label><label>Rules <select id="variant"><option value="original">Original</option><option value="recharged">Recharged</option></select></label><label><input type="checkbox" id="regions" checked> All regions</label><button id="full">Full board</button><button id="theme">Light mode</button></header><main><svg id="map-only" role="img" aria-label="Geographic outline behind the Power Grid network"></svg><div id="app"></div><div id="error" role="alert"></div><footer>Existing cities and links, with a fitted geographic backdrop. Hover a city for its name. <a href="https://www.naturalearthdata.com/about/terms-of-use/">Natural Earth</a> · <a href="https://www.geonames.org/">GeoNames (CC BY 4.0)</a> · <a href="https://data.cityofnewyork.us/d/gthc-hcne">NYC Open Data</a>. Local visual experiment; full-region view is illustrative.</footer></main><script src="/vue.js"></script><script src="/powergrid-viewer.umd.min.js"></script><script>
const params=new URLSearchParams(location.search), key=params.get('map')||'germany';let mode=params.get('style')||'terrain',dark=true,full=params.get('view')==='full',current; const params=new URLSearchParams(location.search), key=params.get('map')||'germany';let mode=params.get('style')||'terrain',dark=true,full=params.get('view')==='full',current;
document.querySelector('#variant').value=params.get('variant')||'original';document.querySelector('#map').value=key;document.querySelector('#style').value=mode;document.querySelector('#regions').checked=params.get('regions')!=='selected'; document.querySelector('#variant').value=params.get('variant')||'original';document.querySelector('#map').value=key;document.querySelector('#style').value=mode;document.querySelector('#regions').checked=params.get('regions')!=='selected';
document.body.classList.toggle('full',full);document.querySelector('#full').textContent=full?'Map only':'Full board'; document.body.classList.toggle('full',full);document.querySelector('#full').textContent=full?'Map only':'Full board';
@ -61,21 +76,126 @@ document.querySelector('#theme').onclick=e=>{dark=!dark;document.body.classList.
// Compact asset review: all authored spaces and connections, without game UI. // Compact asset review: all authored spaces and connections, without game UI.
function gallery(page, fullBoard = false) { function gallery(page, fullBoard = false) {
const cards=Object.entries(geometry).slice(page*6,page*6+6).map(([key, geo])=>{ const cards = Object.entries(geometry)
const map=maps[key].map, [rx,ry]=map.adjustRatio || [1,1]; .slice(page * 6, page * 6 + 6)
const xs=map.cities.map(c=>c.x*rx),ys=map.cities.map(c=>c.y*ry); .map(([key, geo]) => {
const x=Math.min(...xs)-30,y=Math.min(...ys)-30,w=Math.max(...xs)-x+30,h=Math.max(...ys)-y+30; const map = maps[key].map,
const scene=engine.setup(3,{map:map.name,variant:'original'},'gallery').map; [rx, ry] = map.adjustRatio || [1, 1];
const cx=(Math.min(...xs)+Math.max(...xs))/2,cy=(Math.min(...ys)+Math.max(...ys))/2; const xs = map.cities.map((c) => c.x * rx),
const framing=fullBoard?[0,0,...scene.viewBox]:[x,y,w,h]; ys = map.cities.map((c) => c.y * ry);
const transform=fullBoard?'translate('+scene.mapPosition.join(',')+') rotate('+(map.mapRotation||0)+','+cx+','+cy+')':''; const x = Math.min(...xs) - 30,
const point=Object.fromEntries(map.cities.map(c=>[c.name,c])); y = Math.min(...ys) - 30,
const paths=(data,fill,stroke)=>data.map(d=>'<path d="'+d+'" fill="'+fill+'" stroke="'+stroke+'" stroke-width="'+1/Math.max(rx,ry)+'"/>').join(''); w = Math.max(...xs) - x + 30,
const links=map.connections.map(c=>{const [a,b]=c.nodes.map(n=>point[n]);return '<line x1="'+a.x+'" y1="'+a.y+'" x2="'+b.x+'" y2="'+b.y+'" stroke="#647063" stroke-width="'+3/Math.max(rx,ry)+'"/>'}).join(''); h = Math.max(...ys) - y + 30;
const cities=map.cities.map(c=>'<circle cx="'+c.x+'" cy="'+c.y+'" r="'+5/Math.max(rx,ry)+'" fill="'+c.region+'" stroke="#222" stroke-width="'+1/Math.max(rx,ry)+'"><title>'+c.name+'</title></circle>').join(''); const scene = engine.setup(3, { map: map.name, variant: 'original' }, 'gallery').map;
return '<article><a href="/?map='+key+'&style=terrain&view=full">'+geo.name+'</a><svg viewBox="'+framing.join(' ')+'"><g transform="'+transform+'"><g transform="scale('+rx+','+ry+')" fill-rule="evenodd">'+paths(geo.context,'#91b374','none')+paths(geo.land,'#bfd58c','#526b39')+links+cities+'</g></g></svg></article>'; const cx = (Math.min(...xs) + Math.max(...xs)) / 2,
}).join(''); cy = (Math.min(...ys) + Math.max(...ys)) / 2;
return '<!doctype html><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title>All maps · geographic review</title><style>body{margin:16px;background:#171717;color:#eee;font:16px system-ui}nav{margin-bottom:12px}a{color:inherit;padding:8px}main{display:grid;grid-template-columns:repeat(3,1fr);gap:16px}article{min-width:0}svg{display:block;width:100%;height:auto;background:#96bcc5;margin-top:8px}article>a{display:block}</style><nav>'+[0,1,2,3].map(i=>'<a href="/gallery?page='+i+'&view='+(fullBoard?'full':'map')+'">Maps '+(i*6+1)+'–'+(i*6+6)+'</a>').join('')+'</nav><main>'+cards+'</main>'; const framing = fullBoard ? [0, 0, ...scene.viewBox] : [x, y, w, h];
const transform = fullBoard
? 'translate(' +
scene.mapPosition.join(',') +
') rotate(' +
(map.mapRotation || 0) +
',' +
cx +
',' +
cy +
')'
: '';
const point = Object.fromEntries(map.cities.map((c) => [c.name, c]));
const paths = (data, fill, stroke) =>
data
.map(
(d) =>
'<path d="' +
d +
'" fill="' +
fill +
'" stroke="' +
stroke +
'" stroke-width="' +
1 / Math.max(rx, ry) +
'"/>'
)
.join('');
const links = map.connections
.map((c) => {
const [a, b] = c.nodes.map((n) => point[n]);
return (
'<line x1="' +
a.x +
'" y1="' +
a.y +
'" x2="' +
b.x +
'" y2="' +
b.y +
'" stroke="#647063" stroke-width="' +
3 / Math.max(rx, ry) +
'"/>'
);
})
.join('');
const cities = map.cities
.map(
(c) =>
'<circle cx="' +
c.x +
'" cy="' +
c.y +
'" r="' +
5 / Math.max(rx, ry) +
'" fill="' +
c.region +
'" stroke="#222" stroke-width="' +
1 / Math.max(rx, ry) +
'"><title>' +
c.name +
'</title></circle>'
)
.join('');
return (
'<article><a href="/?map=' +
key +
'&style=terrain&view=full">' +
geo.name +
'</a><svg viewBox="' +
framing.join(' ') +
'"><g transform="' +
transform +
'"><g transform="scale(' +
rx +
',' +
ry +
')" fill-rule="evenodd">' +
paths(geo.context, '#91b374', 'none') +
paths(geo.land, '#bfd58c', '#526b39') +
links +
cities +
'</g></g></svg></article>'
);
})
.join('');
return (
'<!doctype html><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title>All maps · geographic review</title><style>body{margin:16px;background:#171717;color:#eee;font:16px system-ui}nav{margin-bottom:12px}a{color:inherit;padding:8px}main{display:grid;grid-template-columns:repeat(3,1fr);gap:16px}article{min-width:0}svg{display:block;width:100%;height:auto;background:#96bcc5;margin-top:8px}article>a{display:block}</style><nav>' +
[0, 1, 2, 3]
.map(
(i) =>
'<a href="/gallery?page=' +
i +
'&view=' +
(fullBoard ? 'full' : 'map') +
'">Maps ' +
(i * 6 + 1) +
'–' +
(i * 6 + 6) +
'</a>'
)
.join('') +
'</nav><main>' +
cards +
'</main>'
);
} }
export function geographicPreviewServer() { export function geographicPreviewServer() {
@ -83,22 +203,52 @@ export function geographicPreviewServer() {
try { try {
const url = new URL(req.url, 'http://localhost'); const url = new URL(req.url, 'http://localhost');
res.setHeader('Cache-Control', 'no-store'); res.setHeader('Cache-Control', 'no-store');
if (url.pathname === '/gallery') { res.setHeader('Content-Type', 'text/html'); return res.end(gallery(Math.max(0, Math.min(3, Number(url.searchParams.get('page')) || 0)),url.searchParams.get('view')==='full')); } if (url.pathname === '/gallery') {
if (url.pathname === '/') { res.setHeader('Content-Type', 'text/html'); return res.end(html); } res.setHeader('Content-Type', 'text/html');
return res.end(
gallery(
Math.max(0, Math.min(3, Number(url.searchParams.get('page')) || 0)),
url.searchParams.get('view') === 'full'
)
);
}
if (url.pathname === '/') {
res.setHeader('Content-Type', 'text/html');
return res.end(html);
}
if (url.pathname === '/state') { if (url.pathname === '/state') {
const key = url.searchParams.get('map') || 'germany'; const key = url.searchParams.get('map') || 'germany';
const state = url.searchParams.get('fixture') === 'live' && process.env.PREVIEW_STATE const state =
? JSON.parse(await readFile(process.env.PREVIEW_STATE, 'utf8')) url.searchParams.get('fixture') === 'live' && process.env.PREVIEW_STATE
: geographicPreviewState(key, url.searchParams.get('regions') !== 'selected', url.searchParams.get('variant') || 'original', Math.min(6, Math.max(2, Number(url.searchParams.get('players')) || 3))); ? JSON.parse(await readFile(process.env.PREVIEW_STATE, 'utf8'))
: geographicPreviewState(
key,
url.searchParams.get('regions') !== 'selected',
url.searchParams.get('variant') || 'original',
Math.min(6, Math.max(2, Number(url.searchParams.get('players')) || 3))
);
res.setHeader('Content-Type', 'application/json'); res.setHeader('Content-Type', 'application/json');
return res.end(JSON.stringify({ state, outline: geometry[key], ratio: state.map.adjustRatio })); return res.end(JSON.stringify({ state, outline: geometry[key], ratio: state.map.adjustRatio }));
} }
if (url.pathname === '/vue.js' || /^\/powergrid-viewer[\w.-]*\.(css|js)$/.test(url.pathname)) { if (url.pathname === '/vue.js' || /^\/powergrid-viewer[\w.-]*\.(css|js)$/.test(url.pathname)) {
res.setHeader('Content-Type', url.pathname.endsWith('.css') ? 'text/css' : 'text/javascript'); res.setHeader('Content-Type', url.pathname.endsWith('.css') ? 'text/css' : 'text/javascript');
return res.end(await readFile(url.pathname === '/vue.js' ? require.resolve('vue/dist/vue.min.js') : fileURLToPath(new URL('../dist' + url.pathname, import.meta.url)))); return res.end(
await readFile(
url.pathname === '/vue.js'
? require.resolve('vue/dist/vue.min.js')
: fileURLToPath(new URL('../dist' + url.pathname, import.meta.url))
)
);
} }
res.writeHead(404); res.end(); res.writeHead(404);
} catch (error) { res.writeHead(422, { 'Content-Type': 'application/json' }); res.end(JSON.stringify({ error: error.message })); } res.end();
} catch (error) {
res.writeHead(422, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ error: error.message }));
}
}); });
} }
if (process.argv[1] === fileURLToPath(import.meta.url)) geographicPreviewServer().listen(Number(process.env.PORT || 5209), '127.0.0.1', () => console.log('Geographic preview: http://127.0.0.1:' + (process.env.PORT || 5209))); if (process.argv[1] === fileURLToPath(import.meta.url))
geographicPreviewServer().listen(Number(process.env.PORT || 5209), '127.0.0.1', () =>
console.log('Geographic preview: http://127.0.0.1:' + (process.env.PORT || 5209))
);

View file

@ -35,16 +35,16 @@ No geography contributes to
layout measurements. Map-only preview keeps its original network clip plus 24 layout measurements. Map-only preview keeps its original network clip plus 24
units of decorative padding. units of decorative padding.
- Desktop retains the authored `map.viewBox`. - Desktop retains the authored `map.viewBox`.
- Portrait keeps measuring the original city/network SVG, so selected regions - Portrait keeps measuring the original city/network SVG, so selected regions
retain the previous framing and zoom behaviour. retain the previous framing and zoom behaviour.
- Map-only preview measures that same network before copying any background; - Map-only preview measures that same network before copying any background;
geography does not expand its viewBox either. geography does not expand its viewBox either.
- The background has no pointer hit testing and does not change city positions, - The background has no pointer hit testing and does not change city positions,
connections, rules, move legality or region selection. connections, rules, move legality or region selection.
- Unknown layouts and randomized city coordinates receive no geographic layer. - Unknown layouts and randomized city coordinates receive no geographic layer.
Recognition checks authored city names and scaled coordinates, allowing region Recognition checks authored city names and scaled coordinates, allowing region
subsets and the Original/Recharged variants. subsets and the Original/Recharged variants.
## Sources and attribution ## Sources and attribution
@ -55,14 +55,14 @@ and UK/Ireland Natural Earth landmark inputs remain in
`natural-earth-source.json`; the initial two-map output `outlines.json` is `natural-earth-source.json`; the initial two-map output `outlines.json` is
historical and is no longer loaded by the preview or viewer. historical and is no longer loaded by the preview or viewer.
- [Natural Earth](https://www.naturalearthdata.com/about/terms-of-use/), public - [Natural Earth](https://www.naturalearthdata.com/about/terms-of-use/), public
domain: 1:50m country boundaries and lakes; 1:10m populated places and province domain: 1:50m country boundaries and lakes; 1:10m populated places and province
boundaries. Git revision `ca96624a56bd078437bca8184e78163e5039ad19`. boundaries. Git revision `ca96624a56bd078437bca8184e78163e5039ad19`.
- [GeoNames](https://www.geonames.org/), - [GeoNames](https://www.geonames.org/),
[CC BY 4.0](https://creativecommons.org/licenses/by/4.0/): city coordinates [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/): city coordinates
from `cities500.zip` and Bremen districts from `DE.zip` (2026-10-04). from `cities500.zip` and Bremen districts from `DE.zip` (2026-10-04).
- [NYC Open Data Borough Boundaries 26b](https://data.cityofnewyork.us/d/gthc-hcne): - [NYC Open Data Borough Boundaries 26b](https://data.cityofnewyork.us/d/gthc-hcne):
Manhattan and neighbouring borough geometries, under NYC Open Data terms. Manhattan and neighbouring borough geometries, under NYC Open Data terms.
These data have been cropped, merged, warped to the schematic game boards, These data have been cropped, merged, warped to the schematic game boards,
buffered and simplified. The browser receives SVG paths only, in a separately buffered and simplified. The browser receives SVG paths only, in a separately
@ -101,16 +101,16 @@ taller portrait layout.
Special schematic fits: Special schematic fits:
- Britain and Ireland are fitted independently. A western Scotland clearance - Britain and Ireland are fitted independently. A western Scotland clearance
envelope preserves a sea gap despite the compressed board layout. envelope preserves a sea gap despite the compressed board layout.
- Manhattan's anonymous M1–M83 spaces cannot be geocoded. Its real coastline is - Manhattan's anonymous M1–M83 spaces cannot be geocoded. Its real coastline is
aligned with the island's long axis and fitted to the grid envelope. The aligned with the island's long axis and fitted to the grid envelope. The
northern edge continues beyond the viewport; it is not an invented coast. northern edge continues beyond the viewport; it is not an invented coast.
- Duplicate Paris/London/Melbourne spaces and expanded Montreal suburbs make - Duplicate Paris/London/Melbourne spaces and expanded Montreal suburbs make
exact geographic correspondence impossible. This is a gameplay backdrop, exact geographic correspondence impossible. This is a gameplay backdrop,
not an accurate geographic projection. not an accurate geographic projection.
- Foreign-country spaces on South Africa and transregional cities on - Foreign-country spaces on South Africa and transregional cities on
Baden-Württemberg intentionally fall outside the lighter active area. Baden-Württemberg intentionally fall outside the lighter active area.
`fit-report.json` records anchor errors, polygon repairs and city centres outside `fit-report.json` records anchor errors, polygon repairs and city centres outside
active land. Outside entries include legitimate neighbouring territories and a active land. Outside entries include legitimate neighbouring territories and a

View file

@ -72,7 +72,10 @@ export function poweringPosition(scenario = 'choice') {
G.powerPlantsDeck = G.powerPlantsDeck.filter((p) => !held.has(p.number)); G.powerPlantsDeck = G.powerPlantsDeck.filter((p) => !held.has(p.number));
G.log.push({ G.log.push({
type: 'event', type: 'event',
event: scenario === 'discard' ? 'Choose which Power Plant to discard.' : 'Round 6: power your cities and collect income.', event:
scenario === 'discard'
? 'Choose which Power Plant to discard.'
: 'Round 6: power your cities and collect income.',
}); });
G.newTurn = true; G.newTurn = true;
return G; return G;

View file

@ -23,7 +23,11 @@ export function previewServer() {
res.writeHead(204).end(); res.writeHead(204).end();
return; return;
} }
const file = files[path] || (/^\/powergrid-viewer\.umd\.min\.geography-[a-z-]+\.js$/.test(path) ? fileURLToPath(new URL('../dist' + path, import.meta.url)) : undefined); const file =
files[path] ||
(/^\/powergrid-viewer\.umd\.min\.geography-[a-z-]+\.js$/.test(path)
? fileURLToPath(new URL('../dist' + path, import.meta.url))
: undefined);
if (path !== '/' && !file) { if (path !== '/' && !file) {
res.writeHead(404).end(); res.writeHead(404).end();
return; return;

View file

@ -1,11 +1,10 @@
<template> <template>
<g v-if="geography && bounds && appearance !== 'none'" data-geography-map pointer-events="none" aria-hidden="true"> <g v-if="geography && bounds && appearance !== 'none'" data-geography-map pointer-events="none" aria-hidden="true">
<metadata> <metadata>
Geographic backdrop adapted from Natural Earth (public domain), Geographic backdrop adapted from Natural Earth (public domain), GeoNames (https://www.geonames.org/, CC BY
GeoNames (https://www.geonames.org/, CC BY 4.0, 4.0, https://creativecommons.org/licenses/by/4.0/) and NYC Open Data
https://creativecommons.org/licenses/by/4.0/) and NYC Open Data (https://data.cityofnewyork.us/d/gthc-hcne). Shapes are fitted to the schematic game network; see
(https://data.cityofnewyork.us/d/gthc-hcne). Shapes are fitted to the viewer/scripts/geography/README.md.
schematic game network; see viewer/scripts/geography/README.md.
</metadata> </metadata>
<defs> <defs>
<clipPath :id="clipId" clipPathUnits="userSpaceOnUse"> <clipPath :id="clipId" clipPathUnits="userSpaceOnUse">
@ -13,13 +12,31 @@
</clipPath> </clipPath>
</defs> </defs>
<g data-geography-content :clip-path="fullBoard ? undefined : `url(#${clipId})`"> <g data-geography-content :clip-path="fullBoard ? undefined : `url(#${clipId})`">
<rect v-if="appearance === 'terrain'" :x="bounds.x" :y="bounds.y" :width="bounds.width" :height="bounds.height" fill="#96bcc5" /> <rect
v-if="appearance === 'terrain'"
:x="bounds.x"
:y="bounds.y"
:width="bounds.width"
:height="bounds.height"
fill="#96bcc5"
/>
<g :transform="`scale(${ratio[0]}, ${ratio[1]})`" fill-rule="evenodd" stroke-linejoin="round"> <g :transform="`scale(${ratio[0]}, ${ratio[1]})`" fill-rule="evenodd" stroke-linejoin="round">
<path v-for="(path, i) in (appearance === 'terrain' ? geography.context : [])" :key="'context' + i" :d="path" fill="#91b374" /> <path
<path v-for="(path, i) in geography.land" :key="'land' + i" :d="path" v-for="(path, i) in appearance === 'terrain' ? geography.context : []"
:key="'context' + i"
:d="path"
fill="#91b374"
/>
<path
v-for="(path, i) in geography.land"
:key="'land' + i"
:d="path"
:fill="appearance === 'line' ? 'none' : appearance === 'terrain' ? '#bfd58c' : '#dce8aa'" :fill="appearance === 'line' ? 'none' : appearance === 'terrain' ? '#bfd58c' : '#dce8aa'"
:fill-opacity="appearance === 'wash' ? 0.48 : 1" :fill-opacity="appearance === 'wash' ? 0.48 : 1"
stroke="#526b39" stroke-opacity="0.65" :stroke-width="1.6 / Math.max(...ratio)" /> stroke="#526b39"
stroke-opacity="0.65"
:stroke-width="1.6 / Math.max(...ratio)"
/>
</g> </g>
</g> </g>
</g> </g>

View file

@ -15,8 +15,13 @@ export function loadGeography(name: string): Promise<void> {
if (!key) return Promise.resolve(); if (!key) return Promise.resolve();
if (!pending[key]) { if (!pending[key]) {
pending[key] = geographyLoaders[key]() pending[key] = geographyLoaders[key]()
.then(module => { byName[name] = module.default as unknown as MapGeography; }) .then((module) => {
.catch(error => { delete pending[key]; throw error; }); byName[name] = module.default as unknown as MapGeography;
})
.catch((error) => {
delete pending[key];
throw error;
});
} }
return pending[key]!; return pending[key]!;
} }
@ -32,8 +37,14 @@ export function geographyForMap(map?: GameMap): MapGeography | undefined {
const geography = byName[map.name]; const geography = byName[map.name];
if (!geography) return; if (!geography) return;
const [rx, ry] = map.adjustRatio || [1, 1]; const [rx, ry] = map.adjustRatio || [1, 1];
if (!map.cities.every((city) => geography.cities.some(([name, x, y]) => if (
name === city.name && Math.abs(city.x - x * rx) < 0.01 && Math.abs(city.y - y * ry) < 0.01 !map.cities.every((city) =>
))) return; geography.cities.some(
([name, x, y]) =>
name === city.name && Math.abs(city.x - x * rx) < 0.01 && Math.abs(city.y - y * ry) < 0.01
)
)
)
return;
return geography; return geography;
} }

View file

@ -1,6 +1,6 @@
import { expect } from 'chai'; import { expect } from 'chai';
import { setup } from 'powergrid-engine'; import { setup } from 'powergrid-engine';
import { maps, mapsRecharged, GameMap } from 'powergrid-engine/src/maps'; import { GameMap, maps, mapsRecharged } from 'powergrid-engine/src/maps';
import { geographyForMap, loadGeographies } from '../../src/geography'; import { geographyForMap, loadGeographies } from '../../src/geography';
const catalog = require('../../src/geography/names.json'); const catalog = require('../../src/geography/names.json');
@ -11,7 +11,7 @@ describe('geographic backgrounds', () => {
expect(Object.keys(catalog)).to.have.length(maps.length); expect(Object.keys(catalog)).to.have.length(maps.length);
for (const authored of [...maps, ...mapsRecharged]) { for (const authored of [...maps, ...mapsRecharged]) {
const [rx, ry] = authored.adjustRatio || [1, 1]; const [rx, ry] = authored.adjustRatio || [1, 1];
const map = { ...authored, cities: authored.cities.map(c => ({ ...c, x: c.x * rx, y: c.y * ry })) }; const map = { ...authored, cities: authored.cities.map((c) => ({ ...c, x: c.x * rx, y: c.y * ry })) };
const before = JSON.stringify(map); const before = JSON.stringify(map);
const geography = geographyForMap(map); const geography = geographyForMap(map);
expect(geography, authored.name).not.to.equal(undefined); expect(geography, authored.name).not.to.equal(undefined);
@ -22,7 +22,7 @@ describe('geographic backgrounds', () => {
}); });
it('recognizes real region subsets for both editions and different player counts', () => { it('recognizes real region subsets for both editions and different player counts', () => {
for (const variant of ['original', 'recharged'] as const) { for (const variant of ['original', 'recharged'] as const) {
for (const authored of (variant === 'original' ? maps : mapsRecharged)) { for (const authored of variant === 'original' ? maps : mapsRecharged) {
for (const count of [3, 4]) { for (const count of [3, 4]) {
const state = setup(count, { map: authored.name as any, variant }, 'geography'); const state = setup(count, { map: authored.name as any, variant }, 'geography');
expect(geographyForMap(state.map), `${authored.name}/${variant}/${count}`).not.to.equal(undefined); expect(geographyForMap(state.map), `${authored.name}/${variant}/${count}`).not.to.equal(undefined);