Bridges and connectors
import { Aside } from ‘@astrojs/starlight/components’;
Problem
Section titled “Problem”A river splits your board into two halves and you want the procedural generator to lay down two or three bridges at sensible spans (not too close, not over impassable terrain) every time the same seed runs.
Snippet
Section titled “Snippet”import { createSeededGameboardPlan } from 'declarative-hex-worlds/rules';
const plan = createSeededGameboardPlan({ seed: 'forest-with-river-3', shape: { kind: 'rectangle', width: 12, height: 8 }, generators: [ { kind: 'river', source: { q: 0, r: 3 }, sink: { q: 11, r: 5 } }, { kind: 'bridges', maxBridges: 3, minSpacing: 3 }, ],});
// Same seed → same river path → same bridges. Always.What the library handles
Section titled “What the library handles”- River pathing. A* between source + sink with terrain-cost weighting.
- Bridge placement. Seed-aware sampler picks span sites that satisfy
minSpacingand don’t cross unrenderable terrain. - Determinism contract. See the determinism guide.