aboutsummaryrefslogtreecommitdiff
path: root/internal/world/grid.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/world/grid.go')
-rw-r--r--internal/world/grid.go26
1 files changed, 21 insertions, 5 deletions
diff --git a/internal/world/grid.go b/internal/world/grid.go
index 2ea897a..7be8eed 100644
--- a/internal/world/grid.go
+++ b/internal/world/grid.go
@@ -87,12 +87,28 @@ func BuildGrid(seed int, load func(int) (*Room, bool), include func(int) bool, e
continue
}
- g.Coord[target] = want
- g.RoomAt[want] = target
- g.Dist[target] = g.Dist[rid] + 1
- queue = append(queue, target)
- }
+ g.Coord[target] = want
+ g.RoomAt[want] = target
+ g.Dist[target] = g.Dist[rid] + 1
+ queue = append(queue, target)
+ }
}
return g
}
+
+// BuildGridConflicts lays out the rooms reachable from seed exactly like
+// BuildGrid but returns every twist/overlap conflict encountered instead of
+// silently skipping them. Callers pass a load closure that may return *edited
+// copies* of rooms to model a hypothetical edit (e.g. an insert or a remove)
+// without writing anything to disk; a non-empty result means the modeled world
+// cannot be embedded on the grid. include and edgeInclude default to "place
+// and follow everything" (geometry is independent of gating), matching the
+// startup validator's validateRoomGrid.
+func BuildGridConflicts(seed int, load func(int) (*Room, bool)) []GridConflict {
+ var conflicts []GridConflict
+ BuildGrid(seed, load, nil, nil, func(gc GridConflict) {
+ conflicts = append(conflicts, gc)
+ })
+ return conflicts
+}