Place: ring merge decided on the heavy member's final mass; a bodyless node keeps a cusp as the one body it would become; tests follow
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
c3d7d077e6
commit
513d0c4393
4 changed files with 11 additions and 10 deletions
|
|
@ -603,7 +603,8 @@ public static class ZoneGenerator
|
|||
upper *= 1 - 1e-6f;
|
||||
float AtLeast(GeneratorPlanet child, float edge)
|
||||
{
|
||||
var m = WellMass(child);
|
||||
// A bodyless node stands in for one body of its family's mass, which it becomes if its ring cannot stand
|
||||
var m = child.Empty ? Family(child) : WellMass(child);
|
||||
var mInto = WellMass(into);
|
||||
return m <= 0 || mInto <= 0 ? edge : Math.Max(edge, 2 * CuspMargin * Roche(m) * Strength(mInto) / Strength(m));
|
||||
}
|
||||
|
|
@ -656,6 +657,9 @@ public static class ZoneGenerator
|
|||
if (ring.Count == 0) return;
|
||||
var heavy = ring.OrderByDescending(c => c.Mass).First();
|
||||
var ringDistance = Math.Min(.5f * cap, share * reach / (GravityField.Beta * GravityField.Beta * (1 + GravityField.RingReach)));
|
||||
PlaceChildren(node.Children.Where(c => !ring.Contains(c)).ToList(),
|
||||
() => (1 + GravityField.RingReach) * ringDistance * GravityField.Beta, upper, heavy);
|
||||
// The heavy member's mass is final only now (the outer children fold into it).
|
||||
if (ringDistance < RocheMargin * Roche(heavy.Mass))
|
||||
{
|
||||
// The pair cannot keep its heavy member outside its Roche margin inside its node's reach: the node is one body.
|
||||
|
|
@ -669,8 +673,6 @@ public static class ZoneGenerator
|
|||
member.Distance = ringDistance;
|
||||
chordCap[member] = .2f * 2 * ringDistance * sin(PI / ring.Count);
|
||||
}
|
||||
PlaceChildren(node.Children.Where(c => !ring.Contains(c)).ToList(),
|
||||
() => (1 + GravityField.RingReach) * ringDistance * GravityField.Beta, upper, heavy);
|
||||
}
|
||||
|
||||
var queue = new Queue<GeneratorPlanet>();
|
||||
|
|
|
|||
|
|
@ -231,6 +231,8 @@ public sealed class ChildrenWithinReachTests : IClassFixture<ChildrenWithinReach
|
|||
var authored = AuthoredSettings.Load(RunStartTests.FindRepoRoot());
|
||||
var zoneSettings = authored.Read<ZoneGenerationSettings>("ZoneSettings");
|
||||
var planetSettings = authored.Read<PlanetSettings>("PlanetSettings");
|
||||
zoneSettings.RosetteProbability = 0; // a rosette or binary holds a bodyless node
|
||||
zoneSettings.BinaryCreationProbability = 0;
|
||||
const float mass = 300000f;
|
||||
var trees = 0;
|
||||
var folded = 0;
|
||||
|
|
@ -241,7 +243,7 @@ public sealed class ChildrenWithinReachTests : IClassFixture<ChildrenWithinReach
|
|||
var tightTree = ZoneGenerator.GenerateEntities(zoneSettings, planetSettings, ref tight, mass, 1500f, float2.zero, float.PositiveInfinity);
|
||||
var wide = new CultMath.Random(seed);
|
||||
var wideTree = ZoneGenerator.GenerateEntities(zoneSettings, planetSettings, ref wide, mass, 1e7f, float2.zero, float.PositiveInfinity);
|
||||
if (tightTree.Any(p => p.Empty || p.Ring) || wideTree.Any(p => p.Empty || p.Ring)) continue;
|
||||
|
||||
trees++;
|
||||
if (tightTree.Length < wideTree.Length) folded++;
|
||||
Assert.True(Math.Abs(tightTree.Sum(p => p.Mass) - mass) <= 1e-3f * mass, $"seed {seed}: a folded tree's bodies sum to {tightTree.Sum(p => p.Mass)}, not {mass}");
|
||||
|
|
|
|||
|
|
@ -500,11 +500,8 @@ public sealed class RestoredHullsTests
|
|||
|
||||
var pack = ZoneGenerator.GenerateZone(items, zoneSettings, AuthoredPlanetSettings(), galaxy, galaxy.Entrance, isTutorial: true);
|
||||
|
||||
var roots = pack.Planets.Select(p => cache.Get(p).Orbit)
|
||||
.Select(cache.Get)
|
||||
.Select(o => o.Parent.IsSet() ? o.Parent.Key.Value : "(root)")
|
||||
.Distinct().Count();
|
||||
Assert.True(roots > 1, $"this fixture no longer produces a multi-root entrance (only {roots} distinct parent); it no longer tests the fragmented-topology case.");
|
||||
var roots = pack.Planets.Select(p => cache.Get(cache.Get(p).Orbit)).Count(o => !o.Parent.IsSet());
|
||||
Assert.True(roots > 1, $"this fixture no longer produces a multi-root entrance (only {roots} root); it no longer tests the fragmented-topology case.");
|
||||
|
||||
var stations = pack.Entities.OfType<OrbitalEntityPack>()
|
||||
.Where(e => (cache.Get(e.Hull.Data) as HullData)?.HullType == HullType.Station).ToArray();
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ public sealed class StationPlacementTests : IDisposable
|
|||
{
|
||||
var t = k / 64.0 * longest;
|
||||
Assert.True(length(zone.OrbitPositionAt(entity.OrbitData, t) - zone.OrbitPositionAt(body.Orbit.Key, t)) >= margin * .999f,
|
||||
$"seed {built.Seed}: an entity passes within {margin} of an unrelated body at instant {k}");
|
||||
$"seed {built.Seed}: a {TypeOf(built.Items, entity)} on a ring of {orbit.Data.Distance} passes within {margin} of an unrelated body (mass {body.Mass}, ring {bodyOrbit.Data.Distance}, same parent {bodyOrbit.Data.Parent.Key.Equals(orbit.Data.Parent.Key)}) at instant {k}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue