fix(citygen): robustness found by the extended seed sweep

- arterials merge onto existing roads and keep distance otherwise
- isolated strata components get a drop-in public connector
- blockless districts fall back to the largest clean rectangle
- sliver districts merge into neighbours (district count is a maximum)
- dressing removes blocking features that cut tiles off the street

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Jeffrey Wilcke
2026-10-12 17:30:54 +02:00
parent 9ac713bbe9
commit 0d459e7058
5 changed files with 199 additions and 9 deletions

View File

@@ -62,17 +62,24 @@ fn plan_edges(centers: &[Pos], extra: usize) -> Vec<(Pos, Pos)> {
}
impl ArterialsStage {
/// Routes one arterial. Existing arterial tiles are cheap so roads merge instead of
/// running in parallel; tiles beside an arterial are dear so new roads keep their
/// distance; water is crossable at bridge cost.
fn route(&self, ctx: &GenCtx, a: Pos, b: Pos) -> Option<Vec<Pos>> {
let land = &ctx.scratch.land;
let arterial = &ctx.scratch.arterial;
astar(ctx.size(), a, b, |_, to| {
let size = ctx.size();
astar(size, a, b, |_, to| {
if !land[to] {
Some(40)
} else if arterial[to] {
Some(10)
} else {
Some(11)
return Some(40);
}
if arterial[to] {
return Some(2);
}
let near = Rect::new(to.x - 3, to.y - 3, 7, 7)
.iter()
.any(|q| size.contains(q) && arterial[q]);
Some(if near { 16 } else { 10 })
})
}