Pin CrossingLinks far-zone ordering and a boss zone at the start of the exit path in hand-built graphs (cut one-exit, finding pure-helper-survivors)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
97aa371872
commit
2822a583ea
1 changed files with 11 additions and 0 deletions
|
|
@ -543,6 +543,17 @@ public sealed class OreGeographyTests : IDisposable
|
||||||
Assert.Empty(Provinces.ExtraExits(pruned, new[] {4, 1}, 7, path));
|
Assert.Empty(Provinces.ExtraExits(pruned, new[] {4, 1}, 7, path));
|
||||||
Assert.Equal(Provinces.Regions(chain, new[] {4, 1}, 7), Provinces.Regions(pruned, new[] {4, 1}, 7));
|
Assert.Equal(Provinces.Regions(chain, new[] {4, 1}, 7), Provinces.Regions(pruned, new[] {4, 1}, 7));
|
||||||
|
|
||||||
|
// Crossing links come ordered by far zone whatever order the adjacency lists them in.
|
||||||
|
var shuffled = diamond.Select(next => next.Reverse().ToArray()).ToArray();
|
||||||
|
Assert.Equal(new[] {4, 3, 1}, shuffled[2]);
|
||||||
|
Assert.Equal(new[] {(2, 3), (2, 4)}, Provinces.CrossingLinks(shuffled, new[] {2}, 6));
|
||||||
|
Assert.Equal(new[] {(2, 3)}, Provinces.ExtraExits(shuffled, new[] {2}, 6, new[] {0, 1, 2, 4, 5, 6}));
|
||||||
|
|
||||||
|
// A boss zone at the start of the exit path keeps the link to its successor too.
|
||||||
|
var atStart = Graph(4, (0, 1), (0, 2), (1, 3), (2, 3));
|
||||||
|
Assert.Equal(new[] {(0, 2)}, Provinces.ExtraExits(atStart, new[] {0}, 3, new[] {0, 1, 3}));
|
||||||
|
Assert.Equal(new[] {(0, 1)}, Provinces.ExtraExits(atStart, new[] {0}, 3, new[] {0, 2, 3}));
|
||||||
|
|
||||||
// A boss zone off the path, last on it, or followed by a zone it has no crossing link to has no exit to keep: it throws, naming the boss zone.
|
// A boss zone off the path, last on it, or followed by a zone it has no crossing link to has no exit to keep: it throws, naming the boss zone.
|
||||||
foreach (var broken in new[] {new[] {0, 1, 5, 6}, new[] {0, 1, 2}, new[] {0, 1, 2, 5, 6}})
|
foreach (var broken in new[] {new[] {0, 1, 5, 6}, new[] {0, 1, 2}, new[] {0, 1, 2, 5, 6}})
|
||||||
Assert.Contains("boss zone 2", Assert.Throws<InvalidOperationException>(() => Provinces.ExtraExits(diamond, new[] {2}, 6, broken)).Message);
|
Assert.Contains("boss zone 2", Assert.Throws<InvalidOperationException>(() => Provinces.ExtraExits(diamond, new[] {2}, 6, broken)).Message);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue