mirror of
https://github.com/prosolis/gogobee.git
synced 2026-07-15 08:32:41 +00:00
Long expeditions D1-a: graph-driven TotalRooms; goblin_warrens 7→16
Length is now sourced from the zone graph's longest entry→boss path, not the dice roll, so "Room X/Y" matches what the player walks. The dice fallback stays for graphless zones. Goblin Warrens grows to the T1 12–14 band (13-node traversal): adds the missing Trap anchor and deepens both fork branches + the post-merge approach. Pattern reference for the remaining zones in D1-b…d.
This commit is contained in:
@@ -360,6 +360,45 @@ func roomTypeToNodeKind(rt RoomType) ZoneNodeKind {
|
||||
return NodeKindExploration
|
||||
}
|
||||
|
||||
// graphLongestPath returns the number of nodes on the longest simple
|
||||
// path from Entry to Boss. Used by generateRoomSequence so the
|
||||
// "Room X/Y" display tracks the actual graph traversal length rather
|
||||
// than a dice-rolled stub. Returns 0 if the graph has no entry/boss.
|
||||
func graphLongestPath(g ZoneGraph) int {
|
||||
if g.Entry == "" || g.Boss == "" {
|
||||
return 0
|
||||
}
|
||||
memo := map[string]int{}
|
||||
var dfs func(node string, onPath map[string]bool) int
|
||||
dfs = func(node string, onPath map[string]bool) int {
|
||||
if node == g.Boss {
|
||||
return 1
|
||||
}
|
||||
if v, ok := memo[node]; ok && !onPath[node] {
|
||||
// memo is safe only when the cached subpath doesn't
|
||||
// revisit a node currently on the active path. With DAG
|
||||
// zones (the norm) this is always safe; the onPath guard
|
||||
// keeps us correct if a future zone authors a cycle.
|
||||
return v
|
||||
}
|
||||
best := 0
|
||||
for _, e := range g.Edges[node] {
|
||||
if onPath[e.To] {
|
||||
continue
|
||||
}
|
||||
onPath[e.To] = true
|
||||
sub := dfs(e.To, onPath)
|
||||
delete(onPath, e.To)
|
||||
if sub > 0 && sub+1 > best {
|
||||
best = sub + 1
|
||||
}
|
||||
}
|
||||
memo[node] = best
|
||||
return best
|
||||
}
|
||||
return dfs(g.Entry, map[string]bool{g.Entry: true})
|
||||
}
|
||||
|
||||
// loadZoneGraph returns the graph for a zone. Registered (hand-authored)
|
||||
// graphs take precedence; otherwise the legacy linear compiler is used.
|
||||
// Returns ok=false only for unknown zone IDs.
|
||||
|
||||
Reference in New Issue
Block a user