Gravity: one belt extent rule, read by Zone, the generator's clearance tree and the station tests
AsteroidBelt.Extent(data, rail) is now static over the belt's data and the only spelling: the clearance tree's 'Distance + BeltHalfWidth' and the instance Extent are gone. The swarm host filter loses its dead '!p.Empty' (no bodyless node has a parent). Findings extent-second-spelling and dead-empty-guard (trojan-swarms-residuals). The clearance tree now reads the outermost rock, not the rail plus half-width, so 29 of the 1920 zones of seeds 1-30 place a station or turret differently. TrojanSwarmTests.BaseDigest is repinned for seeds 3-6, which hold such zones; seeds 1 and 2 are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
d52b50f911
commit
73d1cee9de
4 changed files with 22 additions and 16 deletions
|
|
@ -221,7 +221,7 @@ public class Zone
|
|||
foreach (var belt in AsteroidBelts)
|
||||
{
|
||||
var rail = Planets[belt.Key].Orbit.Key;
|
||||
beltExtent[rail] = belt.Value.Extent(Orbits[rail].Data.Distance);
|
||||
beltExtent[rail] = AsteroidBelt.Extent(belt.Value.Data, Orbits[rail].Data.Distance);
|
||||
}
|
||||
var wellNodes = new List<WellNode>();
|
||||
foreach (var orbit in Orbits)
|
||||
|
|
@ -888,8 +888,10 @@ public class AsteroidBelt
|
|||
}
|
||||
|
||||
// What the belt's rail adds to its parent's L_F (WellTree): an annulus reaches its outermost rock, whose period reads the
|
||||
// field there; a swarm riding its rail reaches only the rail, whose period every rock shares.
|
||||
public float Extent(float railDistance) => Data.RidesRail ? railDistance : Math.Max(Radius, railDistance);
|
||||
// field there; a swarm riding its rail reaches only the rail, whose period every rock shares. The one belt extent rule:
|
||||
// Zone, ZoneGenerator's clearance tree and the station tests all read it.
|
||||
public static float Extent(AsteroidBeltData data, float railDistance) =>
|
||||
data.RidesRail ? railDistance : Math.Max(data.Asteroids.Max(a => a.Distance), railDistance);
|
||||
|
||||
// Cut 1 (docs/mining-cut.md): the formula of Zone.cs:269-271 verbatim, `time` in double as `_time` was used.
|
||||
// The only place a chunk pose is computed; no per-tick copy survives it. Cut 2: size is no longer read from
|
||||
|
|
|
|||
|
|
@ -118,6 +118,7 @@ public static class ZoneGenerator
|
|||
}
|
||||
pack.Orbits = planets.Select(planet => cache.RefOf(orbitMap[planet])).ToList();
|
||||
|
||||
var beltOf = new Dictionary<GeneratorPlanet, AsteroidBeltData>();
|
||||
pack.Planets = planets.Where(p=>!p.Empty).Select(planet =>
|
||||
{
|
||||
BodyType bodyType = planet.Belt ? BodyType.Asteroid :
|
||||
|
|
@ -149,6 +150,7 @@ public static class ZoneGenerator
|
|||
planetData.Orbit = cache.RefOf(orbitMap[planet]);
|
||||
if (planetData is AsteroidBeltData beltData)
|
||||
{
|
||||
beltOf[planet] = beltData;
|
||||
beltData.Asteroids =
|
||||
Enumerable.Range(0, (int) zoneSettings.AsteroidCount.Evaluate(beltData.Mass * orbitMap[planet].Distance))
|
||||
.Select(_ => new Asteroid
|
||||
|
|
@ -219,7 +221,7 @@ public static class ZoneGenerator
|
|||
// rocks round both L4 and L5. Drawn from a stream of its own, so no other draw in the zone moves; not a GeneratorPlanet,
|
||||
// so it takes no slot and no station candidacy sees it.
|
||||
var swarmRandom = new Random(seed ^ TrojanStream);
|
||||
foreach (var host in planets.Where(p => p.Parent != null && !p.Parent.Empty && !p.Empty && !p.Belt && p.Distance > 0
|
||||
foreach (var host in planets.Where(p => p.Parent != null && !p.Parent.Empty && !p.Belt && p.Distance > 0
|
||||
&& p.Mass > zoneSettings.PlanetMass && p.Mass <= zoneSettings.SunMass))
|
||||
{
|
||||
if (swarmRandom.NextFloat() >= zoneSettings.TrojanProbability) continue;
|
||||
|
|
@ -239,10 +241,11 @@ public static class ZoneGenerator
|
|||
}
|
||||
|
||||
// The generator's own well tree, for clearance only (the Zone builds its own): what a rail must stay out of is the body's
|
||||
// support, or its Roche margin if more.
|
||||
// support, or its Roche margin if more. A belt's extent is the rule Zone reads (AsteroidBelt.Extent). Swarm rails are
|
||||
// left out: a swarm's extent is its own rail, a copy of its host's, so it raises no L_F and no support.
|
||||
var wellNodes = planets.Select(p => new WellNode(cache.RefOf(orbitMap[p]).Key, p.Parent == null ? default : cache.RefOf(orbitMap[p.Parent]).Key,
|
||||
p.Distance, p.Phase, p.Empty || p.Belt ? 0f : p.Mass,
|
||||
p.Belt ? p.Distance + p.BeltHalfWidth : p.Distance, p.FixedPosition)).ToList();
|
||||
p.Belt ? AsteroidBelt.Extent(beltOf[p], p.Distance) : p.Distance, p.FixedPosition)).ToList();
|
||||
var wells = WellTree.Build(wellNodes, planetSettings, pack.Radius);
|
||||
float Extent(GeneratorPlanet p)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ public sealed class StationPlacementTests : IDisposable
|
|||
var placed = new HashSet<CultRecordKey>();
|
||||
foreach (var body in zone.Planets.Values)
|
||||
for (var key = body.Orbit.Key; placed.Add(key) && zone.Orbits[key].Data.Parent.IsSet();) key = zone.Orbits[key].Data.Parent.Key;
|
||||
var beltExtent = zone.AsteroidBelts.ToDictionary(b => zone.Planets[b.Key].Orbit.Key, b => b.Value.Extent(zone.Orbits[zone.Planets[b.Key].Orbit.Key].Data.Distance));
|
||||
var beltExtent = zone.AsteroidBelts.ToDictionary(b => zone.Planets[b.Key].Orbit.Key, b => AsteroidBelt.Extent(b.Value.Data, zone.Orbits[zone.Planets[b.Key].Orbit.Key].Data.Distance));
|
||||
var nodes = placed.Select(k =>
|
||||
{
|
||||
var d = zone.Orbits[k].Data;
|
||||
|
|
|
|||
|
|
@ -97,16 +97,17 @@ public class TrojanSwarmTests
|
|||
Assert.True(onSwarmHost > 0, "no station or turret sits on a swarm host's rail");
|
||||
}
|
||||
|
||||
// The digests were computed at 67517f40, before this cut, over the zones of each seed with the authored settings: a zone
|
||||
// with no swarm is the base zone, and a zone with swarms is the base zone plus them.
|
||||
// The digests were computed at 67517f40, before cut trojan-swarms, over the zones of each seed with the authored settings;
|
||||
// seeds 3-6 were repinned at cut laned-belts C1, whose one belt extent rule moves stations in them. A zone with no swarm is
|
||||
// the base zone, and a zone with swarms is the base zone plus them.
|
||||
private static readonly Dictionary<uint, string> BaseDigest = new Dictionary<uint, string>
|
||||
{
|
||||
[1] = "02a2bef42b5d4aeaf1e7004d0ab26620ee570ced95115abf98226ab4e0db23eb",
|
||||
[2] = "de231f392e5724ecdce7e746957633bef2724252147ecbb5830db047b635aead",
|
||||
[3] = "5c33fe9f748d6b0b34a7bec923216c7f9bbdfdf8f326c59b77fde9ec96ca2bcb",
|
||||
[4] = "585284386657e4714ad325cb053a78853c5bcaf7eb1a02cbd4826b0e86ad3593",
|
||||
[5] = "4a1aeecad09c61ff7daa43eda40a9c0109dc4b6833439b8400d8c72d939950c8",
|
||||
[6] = "7fd3c5844144b73faf05cd6a53fe92274e4455f38da4aaca4624ea13d96a12c3",
|
||||
[3] = "0377471bf1a73b4e00ee2d18a9e90960fdf7011d35e7c648f103f3538750501f",
|
||||
[4] = "195c6647ff921a12cd5ee71f94610f245e64c15fc1d38bc708846cd04e3ddeb5",
|
||||
[5] = "ae0d57e84456767d35a699941238e7574e815da663b0354e5e1676063910e8a5",
|
||||
[6] = "8ad70edd5d41e942ba9067930e0f148e3da6c054bf1d9d7cdd26be93e12017c6",
|
||||
};
|
||||
|
||||
[Fact]
|
||||
|
|
@ -148,11 +149,11 @@ public class TrojanSwarmTests
|
|||
var belt = MessagePackSerializer.Deserialize<AsteroidBeltData>(old, options);
|
||||
Assert.False(belt.RidesRail);
|
||||
Assert.Equal(3f, belt.Asteroids[0].Distance);
|
||||
Assert.Equal(7f, new AsteroidBelt(belt).Extent(7f));
|
||||
Assert.Equal(3f, new AsteroidBelt(belt).Extent(2f));
|
||||
Assert.Equal(7f, AsteroidBelt.Extent(belt, 7f));
|
||||
Assert.Equal(3f, AsteroidBelt.Extent(belt, 2f));
|
||||
var swarm = MessagePackSerializer.Deserialize<AsteroidBeltData>(MessagePackSerializer.Serialize(
|
||||
new AsteroidBeltData { Asteroids = belt.Asteroids, RidesRail = true }, options), options);
|
||||
Assert.True(swarm.RidesRail);
|
||||
Assert.Equal(2f, new AsteroidBelt(swarm).Extent(2f));
|
||||
Assert.Equal(2f, AsteroidBelt.Extent(swarm, 2f));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue