Repository navigation
Strategic points from a route network; nations derived from their land - #35
Merged
Merged
Conversation
Over 10 worlds of 2000 x 2000: 92% of strategic points are river crossings (1455 per world, one per 53 river tiles, median 6.7 tiles from the next point), 12 peninsulas, every nation starts with exactly 25 tiles, and nation stats correlate with the land at -0.13 to 0.00 (they are random). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cn5qp59UwGNst3umuaQf6u
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cn5qp59UwGNst3umuaQf6u
A routes section in the world config (cell, hub spacing, per-biome and slope, height, river and sea costs) and buildCostGrid: land cells cost the base plus the mean biome, steepness and height extra of their land tiles plus the widest river in them; water is a sea lane within reach of land and closed beyond it. Mutation-checked. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cn5qp59UwGNst3umuaQf6u
Hubs are picked best-first with a spacing; one multi-source Dijkstra over the cost grid gives each cell its nearest hub, and where two hubs' territories touch the cheapest meeting is the route between them (the natural-neighbour graph in travel cost: it crosses a strait, never an ocean). Traffic is weighted betweenness over the hub graph. Mutation-checked; the survivors left are equivalent or tie-break only. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cn5qp59UwGNst3umuaQf6u
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cn5qp59UwGNst3umuaQf6u
Strategic points are no longer local scans. Hubs (the best places to live) are joined by the cheapest paths over the terrain, and the strategic points are where those routes have to go: a pass where a route crosses a ridge, a ford where it crosses a river (the narrowest tile), a strait where it crosses water between two shores, a land neck where it runs over narrow land between wider land. Each point's value comes from the traffic of the routes through it. Hubs and routes are part of the terrain, the state hash, the validation and the save header. Peninsulas are gone (they were not chokepoints); isthmus replaces them. On 3 worlds of 2000 x 2000: 183 points per world (was 1579, 92% of them river crossings), median distance to the next point 37 tiles (was 6.7), 192 hubs and 473 routes; creation 7.3 s (was 6.5 s). The hash schema and save format versions are bumped, and the goldens regenerated, with the nation work. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cn5qp59UwGNst3umuaQf6u
All nations grow at once from their capitals, each step taking the cheapest tile any of them can reach, so territories follow open ground and stop at mountains, rivers and coasts; between equals on open ground the border is halfway. A nation that has its area stops and the others go on. Mutation-checked. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cn5qp59UwGNst3umuaQf6u
A pure measurement of a territory: food (fertility, rivers, coast, grain, pasture, fisheries), timber, stone, horses, metals, luxuries, resource diversity, coast, river and high-ground tiles, the value of the strategic points inside it, its share of route traffic and how many neighbours it has. Resource amounts are the stock left, so a mined-out seam stops counting. Mutation-checked. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cn5qp59UwGNst3umuaQf6u
…land deriveStats is a pure function of the profile with no chance in it: population from food, military from people, metals, horses, timber, stone and defensible ground, economy from variety, luxuries, ports and trade, diplomacy from neighbours and trade. Government is the best-scoring of eight, personality follows circumstance, each with a small seeded jitter so identical lands are not clones. Mutation-checked. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cn5qp59UwGNst3umuaQf6u
…rs by routes Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cn5qp59UwGNst3umuaQf6u
Nations start on hubs, spread out; their starting territory grows over the cost of the ground (1200 tiles by default, nations.startArea); a profile measures what that land is like, and stats, government and personality follow from it by pure functions. Stats have no randomness; government and personality get a small seeded jitter so identical lands are not clones. Sites near the sea score higher (ports). The nation panel shows the land the stats follow from. The profile is hashed, saved and validated. On 8 worlds of 2000 x 2000: every nation starts with 1200 tiles (was 25), all eight governments occur, population follows food at rank correlation 0.78 (was -0.10) and economy follows luxuries at 0.86 (was -0.06). Goldens, hash and save versions are updated in the next commits. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cn5qp59UwGNst3umuaQf6u
Routes are drawn as lines two tiles wide, brighter by the square root of their share of the busiest route's traffic, under the strategic point markers. Each tile of a route is blended once however the line steps over it. The worker builds the overlay with the routes of the world. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cn5qp59UwGNst3umuaQf6u
…and-nations guard HASH_SCHEMA_VERSION is 3 (hubs, routes and each nation's profile are hashed; vectors recomputed with the independent Python reference), SAVE_FORMAT_VERSION is 4, the web database is version 5. World, terrain and depletion goldens regenerated (the golden worlds now use a 24 tile hub spacing and a 150 tile starting area). tests/determinism/routes-nations.test.ts (three 1000 x 1000 worlds, in a CI shard) fails if the strategic points stop lying on routes, one kind swamps the rest, they crowd together, or nation stats stop following from the land (it fails when population is made to ignore food). Node 22, Chromium 157 and QuickJS all reproduce the 19 pinned values; the full 2000 x 2000 world for seed 1337 hashes to d9dac93160c04dab7721dd564f68f8a2 on Node and Chromium. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cn5qp59UwGNst3umuaQf6u
…large territories ADR 0006 (routes and nations from the land), the terrain and nations references, save format 4, README, roadmap and development notes with the measured numbers. The phone e2e closes the nation panel before it looks at the resource legend (a nation now holds a large territory, so a tap on the map reopens its panel) and hides the tile inspector for the tap on the capital, which in landscape the sheet would cover. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cn5qp59UwGNst3umuaQf6u
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two systems read as noise, and this PR fixes both.
Strategic points were four local scans on a grid. Over 10 worlds of 2000 x 2000 they gave about 1,580 points per world, 92% of them river crossings, a median 6.7 tiles apart, and they connected to nothing. Nations were a biome score for the start and then
rng.float()for everything else (government, personality, all four stats), on a fixed 25-tile square; their stats correlated with their land at -0.13 to 0.00.Now strategic points are the places a route network has to go through, and a nation's territory, stats, government and personality are computed from its land. See
docs/decisions/0006-routes-and-nations-from-the-land.md.Changes
terrain/cost.ts,heap.ts,routes.ts,suitability.ts): a movement-cost grid (biome, steepness, height, river width, coastal sea lanes; open ocean closed); hubs at the best places to live; one multi-source Dijkstra (own deterministic heap) joins neighbouring hubs, and traffic is weighted betweenness. Sites near the sea score higher (ports).terrain/strategic.ts): a pass where a route crosses a ridge, a ford at the narrowest river tile, a strait where a route crosses water between shores, an isthmus where it runs over a land neck. Value 1 to 10 from the route's traffic and how narrow or high the point is. Peninsulas are removed (a headland is not a chokepoint).nations/): capitals on hubs, spread out (capitals.ts); starting territory grown over the cost of the ground, all nations at once, 1,200 tiles by default (territory.ts);measureProfilemeasures food, metals, luxuries, coast, defence, trade and neighbours (profile.ts);deriveStats,deriveGovernment,derivePersonalityare pure functions of the profile (derive.ts). Stats have no randomness; government and personality get a small seeded jitter (at most 0.08 and 0.06).RouteHub,StrategicRoute,NationProfile, hubs and routes inTerrainFields; newroutessection, rebuiltstrategicsection,nations.startArea.Measured over 10 worlds of 2000 x 2000:
Related Issues
Follows #34 (resources) and #32 (terrain retune).
Type of Change
Breaking: every existing world, hash and golden changes (pre-1.0).
HASH_SCHEMA_VERSIONis 3,SAVE_FORMAT_VERSIONis 4 (old saves are refused), the web IndexedDB is version 5 (older saves are dropped), the strategic config was rebuilt, andpeninsulais no longer a strategic point type.Checklist
pnpm build): not run in this sessionpnpm lint)pnpm typecheck)pnpm test: 12 contracts, 146 config, 59 renderer, 13 ui, 843 simulation, 48 web, 37 cli, 9 desktop, 47 tool tests;pnpm test:determinism: 42; Prettier clean)test: hash schema 3, save format 4, regenerated goldens and a routes-and-nations guard)Determinism: Node 22, Chromium 157 and QuickJS (a non-V8 engine) all reproduce all 19 pinned values (including save round trips and the depletion golden). The full 2000 x 2000 world for seed 1337 hashes to
d9dac93160c04dab7721dd564f68f8a2on Node and on Chromium. The pure code (heap, cost grid, routes, site score, route features, capitals, territory, profile, derive, the route overlay) is unit tested on drawn worlds and mutation checked;tests/determinism/routes-nations.test.ts(three 1000 x 1000 worlds) fails when the points stop lying on routes, one kind swamps the rest, or nation stats stop following from the land.Not verified
measureProfileagain; nothing does yet.Generated by Claude Code