Generate tutorial celestial worlds in daemon
This commit is contained in:
parent
d57d933d79
commit
ba3900ae72
5 changed files with 611 additions and 6 deletions
|
|
@ -34,6 +34,16 @@ else if (args.Contains("--tutorial-topology", StringComparer.Ordinal))
|
|||
checks.RunTutorialTopology();
|
||||
Console.WriteLine("Daemon tutorial topology smoke passed.");
|
||||
}
|
||||
else if (args.Contains("--zone-bodies", StringComparer.Ordinal))
|
||||
{
|
||||
checks.RunZoneBodies();
|
||||
Console.WriteLine("Daemon generated zone-body smoke passed.");
|
||||
}
|
||||
else if (args.Contains("--tutorial-world", StringComparer.Ordinal))
|
||||
{
|
||||
checks.RunTutorialWorld();
|
||||
Console.WriteLine("Daemon tutorial world-plan smoke passed.");
|
||||
}
|
||||
else
|
||||
{
|
||||
checks.Run();
|
||||
|
|
@ -68,6 +78,76 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
|
|||
}
|
||||
|
||||
public void RunTutorialTopology() => RunCheck(TutorialTopologyIsDeterministicConnectedAndRoleOwned);
|
||||
public void RunZoneBodies() => RunCheck(GeneratedZoneBodiesPreserveFossilHierarchy);
|
||||
public void RunTutorialWorld() => RunCheck(TutorialWorldMaterializesEveryTopologyZone);
|
||||
|
||||
private static void TutorialWorldMaterializesEveryTopologyZone()
|
||||
{
|
||||
AetheriaDaemonTutorialFactionInput Faction(string shortName) =>
|
||||
new($"faction.{shortName.ToLowerInvariant()}", shortName, shortName, 2)
|
||||
{
|
||||
TrainingNames = Enumerable.Range(0, 512).Select(index =>
|
||||
$"{(char)('a' + index % 26)}{(char)('a' + index / 26 % 26)}{(char)('a' + index / 676 % 26)}{shortName.ToLowerInvariant()}")
|
||||
.ToArray()
|
||||
};
|
||||
var factions = new[]
|
||||
{
|
||||
Faction("Miss"), Faction("Zhe"), Faction("Luc"),
|
||||
Faction("Aero"), Faction("Finch"), Faction("Adras")
|
||||
};
|
||||
var world = AetheriaDaemonTutorialWorldGenerator.Generate(factions, 0xA37E_2026u);
|
||||
|
||||
RequireEqual(world.Topology.Zones.Count, world.Zones.Count,
|
||||
"the daemon tutorial world plan must materialize every topology zone exactly once");
|
||||
Require(world.Topology.Zones.All(zone => world.Zones.ContainsKey(zone.ZoneIndex)),
|
||||
"tutorial topology identities must be the sole keys of generated zone plans");
|
||||
Require(world.Zones.Values.All(zone => zone.Orbits.Length > 0 && zone.Bodies.Length > 0),
|
||||
"no selectable tutorial zone may be published as an empty celestial shell");
|
||||
Require(world.Zones.Values.All(zone =>
|
||||
Math.Abs(zone.Mass - zone.HierarchyMass) <= Math.Max(0.01, zone.Mass * 0.00001)),
|
||||
"every tutorial zone must conserve its authored mass independently");
|
||||
Require(world.Zones.Values.SelectMany(zone => zone.Bodies).Any(body => body.Kind == "asteroid_belt"),
|
||||
"the complete tutorial world must retain fossil asteroid-belt generation");
|
||||
Require(world.Zones.Values.SelectMany(zone => zone.Bodies).Count(body => body.Kind == "sun") >= world.Zones.Count,
|
||||
"every generated tutorial zone must contain at least one stellar primary");
|
||||
}
|
||||
|
||||
private static void GeneratedZoneBodiesPreserveFossilHierarchy()
|
||||
{
|
||||
var zone = new AetheriaDaemonTutorialZoneTopology(
|
||||
7,
|
||||
"Morrowind",
|
||||
0.42f,
|
||||
0.63f,
|
||||
new[] { 3, 8 },
|
||||
new[] { "faction.miss" },
|
||||
"faction.miss");
|
||||
var first = AetheriaDaemonZoneBodyGenerator.Generate(0xA37E_2026u, zone, 1.25f);
|
||||
var second = AetheriaDaemonZoneBodyGenerator.Generate(0xA37E_2026u, zone, 1.25f);
|
||||
|
||||
RequireEqual(first.GenerationSeed, second.GenerationSeed,
|
||||
"daemon zone generation must derive one stable seed from galaxy and zone identity");
|
||||
RequireNear(first.Radius, second.Radius, 0,
|
||||
"fixed zone inputs must reproduce the authored radius curve exactly");
|
||||
RequireNear(first.Mass, first.HierarchyMass, Math.Max(0.01, first.Mass * 0.00001),
|
||||
"planet hierarchy normalization must conserve the generated zone mass");
|
||||
Require(first.Radius >= 1000 && first.Radius <= 10000 && first.Mass >= 10000 && first.Mass <= 500000,
|
||||
"zone radius and mass must remain inside the authored exponential-lerp bounds");
|
||||
Require(first.Orbits.Length >= first.Bodies.Length && first.Orbits.Length > 1,
|
||||
"rosette placeholders may own orbits without bodies, but every generated zone must retain its hierarchy");
|
||||
var orbitKeys = first.Orbits.Select(orbit => orbit.OrbitKey).ToHashSet(StringComparer.Ordinal);
|
||||
Require(first.Orbits.All(orbit => orbit.ParentOrbitKey.Length == 0 || orbitKeys.Contains(orbit.ParentOrbitKey)) &&
|
||||
first.Bodies.All(body => orbitKeys.Contains(body.OrbitKey)),
|
||||
"every generated parent and body orbit reference must resolve inside the daemon plan");
|
||||
Require(first.Bodies.All(body => body.GravityInfluenceRadius > 0 && body.GravityWellDepth > 0 &&
|
||||
body.GravityWaveRadius > 0 && body.GravityWaveDepth > 0),
|
||||
"generated body mass must project the authored positive gravity and wave curves for Ymir and Eve");
|
||||
Require(first.Bodies.Select(body => (body.BodyKey, body.Kind, body.Mass, body.OrbitKey, body.Asteroids.Length))
|
||||
.SequenceEqual(second.Bodies.Select(body => (body.BodyKey, body.Kind, body.Mass, body.OrbitKey, body.Asteroids.Length))),
|
||||
"body kinds, masses, identities, orbits, and asteroid cardinality must be deterministic");
|
||||
Require(first.Bodies.Any(body => body.Kind == "sun") && first.Bodies.Any(body => body.Kind != "sun"),
|
||||
"the fossil solar hierarchy must produce both a stellar primary and subordinate bodies");
|
||||
}
|
||||
|
||||
private static void TutorialTopologyIsDeterministicConnectedAndRoleOwned()
|
||||
{
|
||||
|
|
@ -220,6 +300,8 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
|
|||
[
|
||||
PositiveGravityDepthAttractsAndProjectsAsAWell,
|
||||
TutorialTopologyIsDeterministicConnectedAndRoleOwned,
|
||||
GeneratedZoneBodiesPreserveFossilHierarchy,
|
||||
TutorialWorldMaterializesEveryTopologyZone,
|
||||
VolumeSurfaceKeepsNativeShaderAbiInAssetVariant,
|
||||
YmirMovesProjectileAndReportsStableContact,
|
||||
CompressedTerminusStopsAtAttentionBoundary,
|
||||
|
|
|
|||
486
Aetheria.State.Daemon/AetheriaDaemonZoneBodyGenerator.cs
Normal file
486
Aetheria.State.Daemon/AetheriaDaemonZoneBodyGenerator.cs
Normal file
|
|
@ -0,0 +1,486 @@
|
|||
using Aetheria.State.Documents;
|
||||
|
||||
public sealed record AetheriaDaemonGeneratedZonePlan(
|
||||
uint GenerationSeed,
|
||||
double Radius,
|
||||
double Mass,
|
||||
double HierarchyMass,
|
||||
int EmptyOrbitCount,
|
||||
AetheriaOrbitSnapshot[] Orbits,
|
||||
AetheriaBodySnapshot[] Bodies)
|
||||
{
|
||||
public double GravityTerrainDepth { get; init; } = 64;
|
||||
public double GravityTerrainDepthExponent { get; init; } = 2;
|
||||
public double GravityTerrainBoundaryFog { get; init; }
|
||||
}
|
||||
|
||||
public sealed record AetheriaDaemonTutorialWorldPlan(
|
||||
AetheriaDaemonTutorialTopology Topology,
|
||||
IReadOnlyDictionary<int, AetheriaDaemonGeneratedZonePlan> Zones);
|
||||
|
||||
public static class AetheriaDaemonTutorialWorldGenerator
|
||||
{
|
||||
public static AetheriaDaemonTutorialWorldPlan Generate(
|
||||
IReadOnlyList<AetheriaDaemonTutorialFactionInput> factions,
|
||||
uint seed,
|
||||
AetheriaDaemonTutorialTopologySettings? settings = null)
|
||||
{
|
||||
var topology = AetheriaDaemonTutorialTopologyGenerator.GenerateFossil(factions, seed, settings);
|
||||
var zones = topology.Zones.ToDictionary(
|
||||
zone => zone.ZoneIndex,
|
||||
zone => AetheriaDaemonZoneBodyGenerator.Generate(
|
||||
seed,
|
||||
zone,
|
||||
AetheriaDaemonTutorialTopologyGenerator.TutorialCloudDensity(
|
||||
zone.X,
|
||||
zone.Y,
|
||||
topology.NoisePosition)));
|
||||
return new AetheriaDaemonTutorialWorldPlan(topology, zones);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Daemon-owned port of the fossil ZoneGenerator celestial hierarchy. Entity
|
||||
/// population consumes this plan later; it cannot regenerate bodies or orbits.
|
||||
/// </summary>
|
||||
public static class AetheriaDaemonZoneBodyGenerator
|
||||
{
|
||||
private const int MaximumPlacementSamples = 32;
|
||||
|
||||
public static AetheriaDaemonGeneratedZonePlan Generate(
|
||||
uint galaxySeed,
|
||||
AetheriaDaemonTutorialZoneTopology zone,
|
||||
float cloudDensity)
|
||||
{
|
||||
var density = Saturate(cloudDensity / 2f);
|
||||
var radius = ExponentialLerp(density, 1.5f, 1000, 10000);
|
||||
var mass = ExponentialLerp(density, 1.5f, 10000, 500000);
|
||||
var targetSubzoneCount = ExponentialLerp(density, 1.5f, 0, 8);
|
||||
var zoneSeed = StableZoneSeed(galaxySeed, zone);
|
||||
var random = new CultMath.Random(zoneSeed);
|
||||
var planets = new List<PlanetNode>();
|
||||
|
||||
if (targetSubzoneCount > 1)
|
||||
{
|
||||
var boundary = new Circle(new CultMath.float2(0, 0), radius * 0.9f);
|
||||
var occupied = new List<Circle>();
|
||||
var start = random.NextFloat(radius * 0.25f, radius * 0.5f) * random.NextFloat2Direction();
|
||||
occupied.Add(new Circle(start, -boundary.DistanceTo(start)));
|
||||
|
||||
var samples = 0;
|
||||
while (occupied.Count < targetSubzoneCount && samples < MaximumPlacementSamples)
|
||||
{
|
||||
samples = 0;
|
||||
for (var i = 0; i < MaximumPlacementSamples; i++)
|
||||
{
|
||||
var point = random.NextFloat2(-radius, radius);
|
||||
var tangentRadius = MathF.Min(
|
||||
-boundary.DistanceTo(point),
|
||||
occupied.Min(circle => circle.DistanceTo(point)));
|
||||
if (tangentRadius > 0)
|
||||
{
|
||||
occupied.Add(new Circle(point, tangentRadius));
|
||||
break;
|
||||
}
|
||||
samples++;
|
||||
}
|
||||
}
|
||||
|
||||
var totalArea = occupied.Sum(circle => circle.Area);
|
||||
foreach (var circle in occupied)
|
||||
planets.AddRange(GenerateSystem(
|
||||
ref random,
|
||||
circle.Area / totalArea * mass,
|
||||
circle.Radius,
|
||||
circle.Center));
|
||||
}
|
||||
else
|
||||
{
|
||||
planets.AddRange(GenerateSystem(ref random, mass, radius, new CultMath.float2(0, 0)));
|
||||
}
|
||||
|
||||
var orbitKeys = planets.Select((_, index) => $"tutorial.zone.{zone.ZoneIndex}.orbit.{index}").ToArray();
|
||||
var nodeIndices = planets.Select((node, index) => (node, index)).ToDictionary(value => value.node, value => value.index);
|
||||
var orbits = planets.Select((planet, index) => new AetheriaOrbitSnapshot
|
||||
{
|
||||
OrbitKey = orbitKeys[index],
|
||||
ParentOrbitKey = planet.Parent == null ? "" : orbitKeys[nodeIndices[planet.Parent]],
|
||||
FixedPosition = new AetheriaVector2 { X = planet.FixedPosition.x, Y = planet.FixedPosition.y },
|
||||
Distance = planet.Distance,
|
||||
Phase = planet.Phase
|
||||
}).ToArray();
|
||||
|
||||
var bodies = new List<AetheriaBodySnapshot>();
|
||||
for (var nodeIndex = 0; nodeIndex < planets.Count; nodeIndex++)
|
||||
{
|
||||
var planet = planets[nodeIndex];
|
||||
if (planet.Empty)
|
||||
continue;
|
||||
bodies.Add(ProjectBody(zone.ZoneIndex, bodies.Count, planet, orbits[nodeIndex], ref random));
|
||||
}
|
||||
|
||||
return new AetheriaDaemonGeneratedZonePlan(
|
||||
zoneSeed,
|
||||
radius,
|
||||
mass,
|
||||
planets.Sum(planet => (double)planet.Mass),
|
||||
planets.Count(planet => planet.Empty),
|
||||
orbits,
|
||||
bodies.ToArray());
|
||||
}
|
||||
|
||||
private static PlanetNode[] GenerateSystem(
|
||||
ref CultMath.Random random,
|
||||
float mass,
|
||||
float radius,
|
||||
CultMath.float2 fixedPosition)
|
||||
{
|
||||
var root = new PlanetNode
|
||||
{
|
||||
Mass = mass,
|
||||
ChildDistanceMaximum = radius * 0.75f,
|
||||
ChildDistanceMinimum = PlanetSafetyRadius(mass),
|
||||
FixedPosition = fixedPosition
|
||||
};
|
||||
var rosette = random.NextFloat() < 0.1f;
|
||||
if (rosette)
|
||||
{
|
||||
root.ExpandRosette(ref random, (int)(random.NextFloat(1, 5) + random.NextFloat(1, 5)));
|
||||
root.ExpandSolar(
|
||||
ref random,
|
||||
(int)(random.NextFloat(1, 3) * random.NextFloat(1, 2)),
|
||||
0.6f, 0.8f, 1.25f, 1.75f, 1, 0.1f);
|
||||
var averageChildMass = root.Children.Sum(value => value.Mass) / root.Children.Count;
|
||||
foreach (var planet in root.Children.Where(value => value.Mass > 1000).ToArray())
|
||||
{
|
||||
var scale = planet.Mass / averageChildMass;
|
||||
planet.ExpandSolar(
|
||||
ref random,
|
||||
(int)(random.NextFloat(1, 3 * scale) + random.NextFloat(1, 3 * scale)),
|
||||
0.75f, 2.5f, 1 + scale * 0.25f, 1.05f + scale * 0.5f,
|
||||
random.NextFloat() * random.NextFloat() * 10 + 1,
|
||||
0.5f);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
root.ExpandSolar(
|
||||
ref random,
|
||||
random.NextInt(5, 15),
|
||||
0.75f, 2.5f, 1.1f, 1.25f,
|
||||
random.NextFloat() * random.NextFloat() * 10 + 1,
|
||||
0.25f);
|
||||
}
|
||||
|
||||
var expanded = new HashSet<PlanetNode>();
|
||||
var binaries = new HashSet<PlanetNode>();
|
||||
for (var pass = 0; pass < 5; pass++)
|
||||
{
|
||||
var candidates = root.All()
|
||||
.Where(planet => planet != root &&
|
||||
(!rosette || planet.Parent != root) &&
|
||||
planet.Mass > 100 &&
|
||||
!expanded.Contains(planet))
|
||||
.ToArray();
|
||||
foreach (var planet in candidates)
|
||||
{
|
||||
if (random.NextFloat() >= 0.25f)
|
||||
continue;
|
||||
if (random.NextFloat() < 0.1f)
|
||||
{
|
||||
planet.ExpandRosette(ref random, 2);
|
||||
binaries.UnionWith(planet.Children);
|
||||
}
|
||||
else
|
||||
{
|
||||
planet.ExpandSolar(
|
||||
ref random,
|
||||
planet.Mass < 1000 ? random.NextInt(1, 3) : random.NextInt(2, 6),
|
||||
0.75f, 1.5f, 1.05f, 1.25f, 1, 0.15f);
|
||||
}
|
||||
expanded.Add(planet);
|
||||
}
|
||||
}
|
||||
|
||||
var beltCandidates = root.All()
|
||||
.Where(planet => planet != root &&
|
||||
(!rosette || planet.Parent != root) &&
|
||||
planet.Mass < 500 &&
|
||||
!binaries.Contains(planet) &&
|
||||
planet.Children.Count == 0)
|
||||
.Reverse()
|
||||
.ToArray();
|
||||
foreach (var planet in beltCandidates)
|
||||
{
|
||||
if (random.NextFloat() < 0.25f && planet.Parent!.Children.All(sibling => !sibling.Belt))
|
||||
planet.Belt = true;
|
||||
}
|
||||
|
||||
var all = root.All().ToArray();
|
||||
var totalMass = all.Sum(planet => planet.Mass);
|
||||
foreach (var planet in all)
|
||||
planet.Mass = planet.Mass / totalMass * mass;
|
||||
return all;
|
||||
}
|
||||
|
||||
private static AetheriaBodySnapshot ProjectBody(
|
||||
int zoneIndex,
|
||||
int bodyIndex,
|
||||
PlanetNode planet,
|
||||
AetheriaOrbitSnapshot orbit,
|
||||
ref CultMath.Random random)
|
||||
{
|
||||
var kind = planet.Belt ? "asteroid_belt" :
|
||||
planet.Mass > 5000 ? "sun" :
|
||||
planet.Mass > 1000 ? "gas_giant" :
|
||||
planet.Mass > 100 ? "planet" : "planetoid";
|
||||
var body = new AetheriaBodySnapshot
|
||||
{
|
||||
BodyKey = $"tutorial.zone.{zoneIndex}.body.{bodyIndex}",
|
||||
Kind = kind,
|
||||
Name = $"Z{zoneIndex:D2}-{bodyIndex:D3}",
|
||||
OrbitKey = orbit.OrbitKey,
|
||||
Mass = planet.Mass,
|
||||
Resources = [],
|
||||
BodyRadiusMultiplier = 1,
|
||||
GravityRadiusMultiplier = 1,
|
||||
GravityDepthMultiplier = 1,
|
||||
GravityDepthExponent = 2,
|
||||
GravityInfluenceCenterX = double.NaN,
|
||||
GravityInfluenceCenterZ = double.NaN,
|
||||
GravityInfluenceRadius = 500 * Math.Pow(planet.Mass, 0.25),
|
||||
GravityWellDepth = 30 * Math.Pow(planet.Mass, 0.175),
|
||||
GravityWaveRadius = 500 * Math.Pow(planet.Mass, 0.25),
|
||||
GravityWaveDepth = 0.5 * Math.Pow(planet.Mass, 0.3),
|
||||
GravityWaveSpeed = 0.025,
|
||||
Asteroids = [],
|
||||
GasGiantVisual = new AetheriaGasGiantVisualState(),
|
||||
SunVisual = new AetheriaSunVisualState()
|
||||
};
|
||||
|
||||
if (kind == "asteroid_belt")
|
||||
{
|
||||
var count = Math.Max(0, (int)(MathF.Pow(planet.Mass * planet.Distance, 0.5f) + 11));
|
||||
var asteroids = new AetheriaAsteroidSnapshot[count];
|
||||
for (var asteroidIndex = 0; asteroidIndex < count; asteroidIndex++)
|
||||
{
|
||||
asteroids[asteroidIndex] = new AetheriaAsteroidSnapshot
|
||||
{
|
||||
Distance = planet.Distance + random.NextFloat() * (random.NextFloat() - 0.5f) *
|
||||
(5 * MathF.Pow(planet.Distance, 0.666f) + 50),
|
||||
Phase = random.NextFloat(),
|
||||
Size = random.NextFloat(),
|
||||
RotationSpeed = ExponentialLerp(random.NextFloat(), 2, 0.1f, 0.5f),
|
||||
MiningAccumulators = []
|
||||
};
|
||||
}
|
||||
body.Asteroids = asteroids;
|
||||
}
|
||||
else if (kind is "gas_giant" or "sun")
|
||||
{
|
||||
var colors = new List<AetheriaColor>();
|
||||
if (kind == "sun")
|
||||
{
|
||||
var primary = random.NextFloat();
|
||||
var secondary = Fraction(primary + 1 + 0.33f * (random.NextFloat() > 0.5f ? 1 : -1));
|
||||
colors.Add(Color(Hsv(primary, 0.85f, 0.5f), 0));
|
||||
colors.Add(Color(Hsv(secondary, 0.85f, 1), 1));
|
||||
var fog = Hsv(primary, 0.55f, 1);
|
||||
var light = Hsv(primary, 0.5f, 1);
|
||||
body.SunVisual = new AetheriaSunVisualState
|
||||
{
|
||||
FogTintColor = Vector(fog),
|
||||
LightColor = Vector(light),
|
||||
LightRadiusMultiplier = 1
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
var primary = random.NextFloat();
|
||||
var right = Fraction(primary + 0.25f);
|
||||
var left = Fraction(primary + 0.75f);
|
||||
var bandCount = (int)(ExponentialLerp(random.NextFloat(), 2, 5, 8) + 0.5f);
|
||||
for (var band = 0; band < bandCount; band++)
|
||||
{
|
||||
var time = (float)band / (bandCount - 1);
|
||||
var hue = random.NextFloat() > 0.25f ? primary : random.NextFloat() > 0.5f ? right : left;
|
||||
colors.Add(Color(Hsv(
|
||||
hue,
|
||||
ExponentialLerp(random.NextFloat(), 0.5f, 0, 0.8f),
|
||||
ExponentialLerp(random.NextFloat(), 0.5f, 0, 0.8f)), time));
|
||||
}
|
||||
}
|
||||
body.GasGiantVisual = new AetheriaGasGiantVisualState
|
||||
{
|
||||
FirstOffsetDomainRotationSpeed = kind == "sun" ? 5 : 0,
|
||||
FirstOffsetRotationSpeed = 5,
|
||||
SecondOffsetDomainRotationSpeed = -25,
|
||||
SecondOffsetRotationSpeed = 10,
|
||||
AlbedoRotationSpeed = -3,
|
||||
Colors = colors.ToArray(),
|
||||
MaterialOverrides = []
|
||||
};
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
private static uint StableZoneSeed(uint galaxySeed, AetheriaDaemonTutorialZoneTopology zone)
|
||||
{
|
||||
var hash = 2166136261u ^ galaxySeed;
|
||||
foreach (var value in System.Text.Encoding.UTF8.GetBytes(zone.Name ?? ""))
|
||||
hash = (hash ^ value) * 16777619u;
|
||||
hash = (hash ^ unchecked((uint)BitConverter.SingleToInt32Bits(zone.X))) * 16777619u;
|
||||
hash = (hash ^ unchecked((uint)BitConverter.SingleToInt32Bits(zone.Y))) * 16777619u;
|
||||
hash = (hash ^ unchecked((uint)zone.ZoneIndex)) * 16777619u;
|
||||
return hash == 0 ? 0x6E62_4EB7u : hash;
|
||||
}
|
||||
|
||||
private static float PlanetSafetyRadius(float mass) => 2.5f * MathF.Pow(mass, 0.25f);
|
||||
private static float ExponentialLerp(float value, float exponent, float minimum, float maximum) =>
|
||||
minimum + MathF.Pow(Saturate(value), exponent) * (maximum - minimum);
|
||||
private static float Saturate(float value) => value < 0 ? 0 : value > 1 ? 1 : value;
|
||||
private static float Fraction(float value) => value - MathF.Floor(value);
|
||||
|
||||
private static CultMath.float3 Hsv(float hue, float saturation, float value)
|
||||
{
|
||||
hue = Fraction(hue);
|
||||
var sector = hue * 6;
|
||||
var index = (int)MathF.Floor(sector);
|
||||
var fraction = sector - index;
|
||||
var p = value * (1 - saturation);
|
||||
var q = value * (1 - saturation * fraction);
|
||||
var t = value * (1 - saturation * (1 - fraction));
|
||||
return index switch
|
||||
{
|
||||
0 => new CultMath.float3(value, t, p),
|
||||
1 => new CultMath.float3(q, value, p),
|
||||
2 => new CultMath.float3(p, value, t),
|
||||
3 => new CultMath.float3(p, q, value),
|
||||
4 => new CultMath.float3(t, p, value),
|
||||
_ => new CultMath.float3(value, p, q)
|
||||
};
|
||||
}
|
||||
|
||||
private static AetheriaColor Color(CultMath.float3 value, float time) => new()
|
||||
{
|
||||
X = value.x,
|
||||
Y = value.y,
|
||||
Z = value.z,
|
||||
W = time
|
||||
};
|
||||
|
||||
private static AetheriaVector3 Vector(CultMath.float3 value) => new()
|
||||
{
|
||||
X = value.x,
|
||||
Y = value.y,
|
||||
Z = value.z
|
||||
};
|
||||
|
||||
private sealed record Circle(CultMath.float2 Center, float Radius)
|
||||
{
|
||||
public float Area => MathF.PI * Radius * Radius;
|
||||
public float DistanceTo(CultMath.float2 point) => CultMath.math.length(point - Center) - Radius;
|
||||
}
|
||||
|
||||
private sealed class PlanetNode
|
||||
{
|
||||
public float Distance;
|
||||
public float Phase;
|
||||
public float Mass;
|
||||
public float ChildDistanceMinimum;
|
||||
public float ChildDistanceMaximum;
|
||||
public bool Empty;
|
||||
public bool Belt;
|
||||
public List<PlanetNode> Children { get; } = [];
|
||||
public PlanetNode? Parent;
|
||||
public CultMath.float2 FixedPosition;
|
||||
|
||||
public IEnumerable<PlanetNode> All() => new[] { this }.Concat(Children.SelectMany(child => child.All()));
|
||||
|
||||
public void ExpandRosette(ref CultMath.Random random, int vertices)
|
||||
{
|
||||
Empty = true;
|
||||
var sharedMass = Mass / vertices * 2;
|
||||
var proportion = vertices % 2 == 0 ? random.NextFloat(0.5f, 0.95f) : 0.5f;
|
||||
var distance = (ChildDistanceMinimum + ChildDistanceMaximum) / 2;
|
||||
var p0 = new CultMath.float2(0, distance);
|
||||
var angle = 1f / vertices * MathF.PI * 2;
|
||||
var p1 = new CultMath.float2(MathF.Cos(angle), MathF.Sin(angle)) * distance;
|
||||
var neighborDistance = CultMath.math.length(p0 - p1);
|
||||
var p0ChildDistance = (neighborDistance * proportion - PlanetSafetyRadius(sharedMass * (1 - proportion))) * 0.75f;
|
||||
var p1ChildDistance = (neighborDistance * (1 - proportion) - PlanetSafetyRadius(sharedMass * proportion)) * 0.75f;
|
||||
for (var index = 0; index < vertices; index++)
|
||||
{
|
||||
var child = new PlanetNode
|
||||
{
|
||||
Parent = this,
|
||||
Mass = sharedMass * (index % 2 == 0 ? proportion : 1 - proportion),
|
||||
Distance = distance,
|
||||
Phase = (float)index / vertices,
|
||||
ChildDistanceMaximum = index % 2 == 0 ? p0ChildDistance : p1ChildDistance
|
||||
};
|
||||
child.ChildDistanceMinimum = PlanetSafetyRadius(child.Mass) * 2;
|
||||
Children.Add(child);
|
||||
}
|
||||
ChildDistanceMinimum = distance + p0ChildDistance;
|
||||
}
|
||||
|
||||
public void ExpandSolar(
|
||||
ref CultMath.Random random,
|
||||
int count,
|
||||
float massMultiplierMinimum,
|
||||
float massMultiplierMaximum,
|
||||
float distanceMultiplierMinimum,
|
||||
float distanceMultiplierMaximum,
|
||||
float jupiterJump,
|
||||
float massFraction)
|
||||
{
|
||||
if (count == 0 || ChildDistanceMaximum < ChildDistanceMinimum)
|
||||
return;
|
||||
var masses = new float[count];
|
||||
var distances = new float[count];
|
||||
float massTotal = distances[0] = masses[0] = 1;
|
||||
for (var index = 1; index < count; index++)
|
||||
{
|
||||
massTotal += masses[index] = masses[index - 1] *
|
||||
random.NextFloat(massMultiplierMinimum, massMultiplierMaximum) *
|
||||
(count / 2 == index ? jupiterJump : 1);
|
||||
distances[index] = distances[index - 1] *
|
||||
random.NextFloat(distanceMultiplierMinimum, distanceMultiplierMaximum);
|
||||
}
|
||||
for (var index = 0; index < count; index++)
|
||||
masses[index] *= random.NextFloat(0.1f, 1);
|
||||
for (var index = 0; index < count; index++)
|
||||
masses[index] = masses[index] / massTotal * Mass * massFraction;
|
||||
if (count > 1)
|
||||
{
|
||||
var original = distances.ToArray();
|
||||
for (var index = 0; index < count; index++)
|
||||
distances[index] = ChildDistanceMinimum +
|
||||
(ChildDistanceMaximum - ChildDistanceMinimum) *
|
||||
((original[index] - original[0]) / (original[^1] - original[0])) +
|
||||
PlanetSafetyRadius(masses[index]);
|
||||
}
|
||||
for (var index = 0; index < count; index++)
|
||||
{
|
||||
if (masses[index] <= 1)
|
||||
continue;
|
||||
var child = new PlanetNode
|
||||
{
|
||||
Parent = this,
|
||||
Mass = masses[index],
|
||||
Distance = distances[index],
|
||||
Phase = random.NextFloat()
|
||||
};
|
||||
child.ChildDistanceMinimum = PlanetSafetyRadius(child.Mass) * 2;
|
||||
child.ChildDistanceMaximum = MathF.Min(
|
||||
index == 0 ? child.Distance - ChildDistanceMinimum : child.Distance - distances[index - 1],
|
||||
index < count - 1 ? distances[index + 1] - child.Distance : float.PositiveInfinity);
|
||||
if (float.IsNaN(child.Distance))
|
||||
throw new NotFiniteNumberException("Planet created with NaN distance.");
|
||||
if (child.ChildDistanceMaximum > child.ChildDistanceMinimum)
|
||||
Children.Add(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1135,6 +1135,36 @@ the Terminus proof arena cannot award completion.
|
|||
implementation against Unity Mathematics vectors and carries the same
|
||||
semantics in HLSL.
|
||||
|
||||
### Daemon Generated Zone Body Ownership
|
||||
|
||||
- Owner: the daemon zone-body generator owns each generated zone's radius,
|
||||
mass, subzone packing, celestial hierarchy, orbit graph, body classification,
|
||||
asteroid belts, gravity curves, and gas-giant/sun visual parameters.
|
||||
- Inputs: tutorial topology identity/name/position, galaxy seed, the canonical
|
||||
cloud-density sample, and the authored `ZoneSettings`/`PlanetSettings` values.
|
||||
- Outputs: one deterministic zone plan containing stable orbit/body identities,
|
||||
normalized hierarchy mass, explicit empty rosette orbit count, typed body and
|
||||
asteroid snapshots, positive Ymir gravity magnitudes, and provider visual
|
||||
parameters.
|
||||
- Derived state: Ymir radial fields, Eve celestial rows, field splats, lights,
|
||||
asteroid presentation, and later station/ship placement consume the plan.
|
||||
They cannot regenerate its hierarchy.
|
||||
- Forbidden writers: fossil `ZoneGenerator`/`GeneratorPlanet`, Unity prefabs,
|
||||
scene scripts, render lowerers, and clients cannot author bodies or orbits.
|
||||
- Shared paths: a complete tutorial world plan materializes all 64 topology
|
||||
zones through the same daemon generator. Rosettes, ordinary solar systems,
|
||||
satellite passes, binaries, belt selection, and mass normalization share one
|
||||
CultMath stream per zone.
|
||||
- Cut line: generated zones no longer depend on process-randomized
|
||||
`string.GetHashCode`/`HashCode.Combine`; daemon generation derives a stable
|
||||
FNV-1a seed from galaxy and typed zone identity. This intentionally
|
||||
canonicalizes a nonportable fossil seed while retaining its mechanics.
|
||||
- Verification layer: focused smoke proves deterministic body kinds/masses,
|
||||
connected parent references, mass conservation including empty rosette nodes,
|
||||
positive gravity curves, and stable asteroid cardinality. Whole-world smoke
|
||||
proves every topology zone has bodies/orbits, every zone has a stellar
|
||||
primary, and the tutorial retains asteroid belts.
|
||||
|
||||
### Daemon Pickup Contact Transaction
|
||||
|
||||
- Owner: the daemon simulation owns pickup collection by interpreting typed
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ validation proves contract shape, not wiring, exclusivity, lowering, or parity.
|
|||
| Pilot camera | ARPG follow/dock cameras | Eve view semantics + runtime | camera rig and semantic view id | EveUnity camera rig | daemon dock state selects distinct contracts instead of collapsing both fossil cameras: undocked flight advertises the entity-forward `Third Person Rig` framing (distance 30, screen 0.64/0.19, FOV 60, lens 1-4096) and the shared `aim.presentation` convergence point as its look-at; Aetheria translates the fossil Cinemachine top-origin screen Y of `0.81` to Eve's bottom-origin viewport Y of `0.19`; EveUnity solves native pose while preserving both optical aim and advertised entity framing, without provider types; the retained dock projection remains separate | reproduce the dock camera's separate follow/look-at subjects, blend timeline, noise, and reconnect state |
|
||||
| Render channels | Unity layers/culling masks | provider surface policy + runtime asset variant | semantic channel exclusions | EveUnity native layer mapping | wired, exclusive, and lowered: the pilot surface excludes the semantic `map` channel; the Unity asset variant maps `map` to its authored native layer; EveUnity subtracts that layer from the configured camera mask; portable state contains no Unity layer or mask; provider conversion preserves the source icon shader's unlit lighting model; the released witness proves the pilot camera excludes map glyphs while the map camera retains readable white glyphs without a scene light | preserve the channel proof while world presentation and transport continue to evolve |
|
||||
| Minimap/tactical map | `ZoneRenderer`, map cameras | daemon world facts | explicit map projections | Unity and Electron | facts fragmented; generic lowerers absent | same state in both runtimes |
|
||||
| Celestial world | `ZoneRenderer`, body/asteroid prefab scripts | daemon render projection plus provider assets | ordinary generic Eve entity SoA rows | EveUnity generic entity/prefab lowerer | wired, exclusive, projected, and lowered: daemon orbit and terrain queries emit stable presentation-only identities for suns, planets, gas giants, and live asteroid instances; provider packaging extracts only each advertised visual child and strips fossil scripts/physics; released EveUnity `0.3.51` applies semantic scale around provider-authored local scale and contains no celestial or Aetheria branch. The released warm witness records eleven bodies and eighteen asteroids with provider refs and enabled renderers, including seven celestial instances intersecting the pilot frustum | body material/light readability, close-range composition matching the fossil, asteroid variation, and Electron lowering |
|
||||
| Celestial world | `ZoneRenderer`, `ZoneGenerator`, `GeneratorPlanet`, body/asteroid prefab scripts | daemon render projection plus provider assets | ordinary generic Eve entity SoA rows | EveUnity generic entity/prefab lowerer | wired, exclusive, projected, and lowered for Terminus; generated-world authority now also exists in the daemon. Each tutorial topology zone deterministically evaluates the authored radius/mass/subzone curves, rosette-or-solar hierarchy, five satellite/binary passes, belt selection, mass normalization, stable orbits/bodies, gravity/wave curves, asteroid rows, and sun/gas-giant visual parameters. A whole-world proof materializes all 64 zones with stellar primaries and belts. Provider packaging extracts only each advertised visual child and strips fossil scripts/physics; released EveUnity `0.3.51` applies semantic scale around provider-authored local scale and contains no celestial or Aetheria branch. The released warm Terminus witness records eleven bodies and eighteen asteroids with provider refs and enabled renderers, including seven celestial instances intersecting the pilot frustum | persist generated tutorial zones with entities and witness their generic lowering; body material/light readability, close-range composition matching the fossil, asteroid variation, and Electron lowering |
|
||||
| Fields/fog/gravity | zone renderer and shaders | daemon/plugin semantics | Fields plugin documents | EveUnity fields lowerer | daemon publishes canonical gravity/fog splat layers through `field.volume3d`; Eve Fields `0.2.3` owns portable `PowerPulse` and `AnimatedRadialCosine` semantics; Aetheria emits the fossil global animated simplex/cellular/ambient stack, body-owned radial waves, and separate negative gameplay `gravity.height` and positive visual `fog.surface_height`; the shared camera-relative lattice spans 1536 world units as 256 six-unit Stardust cells, rasterizes gravity at eight texels per cell into 2048 texels, and snaps the viewport by one six-unit cell; daemon entities follow fossil terrain height plus hull grid offset after Ymir XZ motion; released EveUnity `0.3.58` lowers the authored topology, one shared snapped viewport frame for fog and Stardust, provider shader ABI, pre-postprocess URP pass, provider-requested TAA, provider-material temporal coverage inputs, authoritative flow time, the historical positive-Z Unity shader camera transform, and float32 packed-output diagnostics without provider code. The provider bundle runs the actual Stardust compute shader across X, Y, and diagonal one-cell remaps and proves 705 overlapping world cells remain bit-identical after buffer reassignment; an asymmetric GPU fixture proves positive world X samples positive texture X instead of retaining the deleted fossil gravity camera's two-axis reversal; its source gate rejects replacement of temporal dithering with a fixed alpha threshold. A separate gravity-fog gate requires raymarch and temporal reprojection to share the historical positive-Z camera convention. The flight post-process bundle gate verifies serialized ACES, exposure/contrast, bloom, vignette, and film-grain components | restore readable patch structure, gravity waves, surrounding world geometry, and final luminance/composition parity; visual parity remains explicitly open |
|
||||
| HUD/schematic | ARPG HUD and `SchematicDisplay` | Eve composition from daemon facts | semantic status/components | EveUnity UI | provider-authored transparent cockpit is wired, projected, and lowered through generic UI Toolkit panes, metrics, and progress components for hull, shield, capacitor, temperature, cargo, weapon cooldown/groups, selected target, target lock, target shield, and target hull. The daemon now publishes the original spatial schematic semantics as a generic `ship.schematic` subtree for both self and selected target: explicit occupied hull cells with current/maximum armor, catalog-backed rotated equipment footprints, durability, thermal range/performance, online state, wear, and nested weapon ammo/cooldown/charge/reload facts. Refit, damage, and presentation share the same rotation geometry; Unity objects do not derive schematic truth | generic spatial schematic lowering, warning timelines, dynamic action state, and composited live capture |
|
||||
| Hit/lock/warnings | `ActionGameManager` feedback | daemon event facts | transient feedback stream | VFX/UI/audio | bounded deduplicated game-event ledger and Eve `feedback.stream` wired for pickup outcomes, projectile launch/impact, entity damage, alive-to-dead destruction, thermal-risk crossings, accepted dock/undock transitions, authoritative weapon reload chronology, lock start/acquired/lost chronology, and episode-deduplicated `weapon.fire.refused` facts for insufficient energy or missing ammunition; docking facts retain exact actor/parent/bay identity and rejected operations emit none; every lock transition carries authored weapon identity, target, reason, and prior/current progress, while reconnect priming prevents retained events from replaying as new feedback | broader negative transaction fixtures, provider lock/docking audio and effect roles, and broader runtime effect consumption |
|
||||
|
|
|
|||
|
|
@ -140,11 +140,18 @@ initial discovery of the entrance plus its neighbors. The narrative processor
|
|||
was commented out and no source-backed tutorial-completion trigger survived.
|
||||
|
||||
That topology now has a deterministic daemon owner driven by CultMath's
|
||||
Unity-compatible simplex noise. It remains a pre-materialization result until
|
||||
the fossil zone-body/entity generator is migrated; the daemon must not present
|
||||
an empty graph or the handcrafted Terminus proof arena as a completed tutorial.
|
||||
Once materialized, New Game may select it from player settings and Eve may lower
|
||||
its map and entry controls without becoming generation authority.
|
||||
Unity-compatible simplex noise. Every topology zone also has a daemon-owned
|
||||
celestial plan preserving the fossil's radius/mass curves, packed subzones,
|
||||
rosettes, solar systems, satellite and binary passes, asteroid belts, stable
|
||||
orbits, gravity curves, and sun/gas-giant presentation parameters. The old
|
||||
process-dependent string/hash seed has been replaced by a stable typed-zone
|
||||
seed; generated saves must reproduce across daemon processes.
|
||||
|
||||
The world remains pre-session until station, ship, player-entry, and wormhole
|
||||
entities are materialized. The daemon must not present a celestial-only graph
|
||||
or the handcrafted Terminus proof arena as a completed tutorial. Once entity
|
||||
materialization is complete, New Game may select it from player settings and
|
||||
Eve may lower its map and entry controls without becoming generation authority.
|
||||
|
||||
## Current Mechanism
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue