From 5df996034316b0c03b7f37d538d34ae9fb28223f Mon Sep 17 00:00:00 2001 From: soul Date: Tue, 27 Oct 2026 17:28:08 +0100 Subject: [PATCH] Provinces.ExtraExits: the crossing links to prune so a boss zone keeps the one on the exit path (cut one-exit) Pure. Reads CrossingLinks; nothing calls it yet. Co-Authored-By: Claude Opus 5.5 --- Assets/Scripts/ServerShared/ZoneData.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Assets/Scripts/ServerShared/ZoneData.cs b/Assets/Scripts/ServerShared/ZoneData.cs index f27eabc8b..67419e00a 100644 --- a/Assets/Scripts/ServerShared/ZoneData.cs +++ b/Assets/Scripts/ServerShared/ZoneData.cs @@ -298,6 +298,19 @@ public static class Provinces return links.ToArray(); } + // The crossing links to prune so each boss zone keeps one exit: all of them but the link to the boss zone's successor on + // exitPath (the zones from the entrance to the exit), which is the link the run goes through. A boss zone that is not on + // exitPath, or whose successor is not one of its crossing links, keeps all of its links: it is never left with none. + public static (int Boss, int Far)[] ExtraExits(int[][] adjacency, IReadOnlyCollection bossZones, int exit, int[] exitPath) => + CrossingLinks(adjacency, bossZones, exit).GroupBy(link => link.Boss) + .SelectMany(links => + { + var at = Array.IndexOf(exitPath, links.Key); + var kept = at >= 0 && at + 1 < exitPath.Length ? exitPath[at + 1] : -1; + return links.Any(link => link.Far == kept) ? links.Where(link => link.Far != kept) : Enumerable.Empty<(int Boss, int Far)>(); + }) + .ToArray(); + // Each zone's region, named by the region's least zone index. Cutting every boss zone's crossing links (CrossingLinks) // leaves the regions as the connected components. Every zone, boss zones included, is in exactly one. public static int[] Regions(int[][] adjacency, IReadOnlyCollection bossZones, int exit)