From d23038f53cca7045a7db3535e90d7f59bb32c373 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 17 Oct 2026 18:55:16 +0200 Subject: [PATCH 01/25] Assembly is the maker's: re-land of h1 on 0f5def17 (net diff of ae300c6a..5187a59d) Applies the net diff of eureka/aetheria-release-assembly-from-maker (5187a59d) without its catalog blob and RunStartTests residue, git apply -3, overlaps resolved on master's side. 066fb581's message ('git log --oneline -1') was a heredoc slip; the old branch stays as it is. Drops the Rarity = fixture member from the tests master added since ae300c6a. Faction keys 19-20 here are h1's; the next commit reshapes them to one Assembly at 19. Co-Authored-By: Claude Opus 5.5 --- Assets/Scripts/ServerShared/Corporations.cs | 9 ++ Assets/Scripts/ServerShared/ItemManager.cs | 23 +--- Assets/Scripts/ServerShared/Provenance.cs | 10 +- Assets/Scripts/ServerShared/Settings.cs | 1 - .../AssemblyFromMakerCatalogTests.cs | 35 ++++++ .../AssemblyFromMakerCommandTests.cs | 87 +++++++++++++ .../AssemblyFromMakerTests.cs | 118 ++++++++++++++++++ tests/Aetheria.Shared.Tests/BrownoutTests.cs | 2 +- .../Aetheria.Shared.Tests/CatalogRoleTests.cs | 2 +- .../ConditionRatioTests.cs | 2 +- .../ConsumableSupplyTests.cs | 13 +- .../ConsumablesFirstSetTests.cs | 2 +- .../ContactRevealTests.cs | 2 +- tests/Aetheria.Shared.Tests/ContactTests.cs | 2 +- tests/Aetheria.Shared.Tests/DrawnPoseTests.cs | 2 +- tests/Aetheria.Shared.Tests/EmissionTests.cs | 6 +- .../FireAuthorityTests.cs | 2 +- .../FireControlCut11Tests.cs | 2 +- .../FireControlCut123Tests.cs | 2 +- .../FireControlCut124Tests.cs | 2 +- .../FireControlCut12Tests.cs | 2 +- .../FireControlCut4Tests.cs | 2 +- .../FireControlCut5Tests.cs | 2 +- .../FireControlCut6Tests.cs | 2 +- .../FireControlCut6cTests.cs | 2 +- .../FireControlCut6dTests.cs | 2 +- .../FireControlCut7Tests.cs | 4 +- .../FireControlCut8Tests.cs | 2 +- .../FireControlCut9Tests.cs | 2 +- .../FireControlPerWeaponTests.cs | 2 +- .../Aetheria.Shared.Tests/FireControlTests.cs | 2 +- tests/Aetheria.Shared.Tests/FlightTests.cs | 2 +- .../FloatingBodyTests.cs | 4 +- tests/Aetheria.Shared.Tests/FlowFieldTests.cs | 2 +- .../GravitySubtractTests.cs | 2 +- .../HeatResponseTests.cs | 2 +- .../IffAndCombatTests.cs | 2 +- .../InputCapacitorTests.cs | 2 +- .../InspectionScannerCatalogTests.cs | 2 +- .../LaunchSuppressorCatalogTests.cs | 2 +- tests/Aetheria.Shared.Tests/LayerTests.cs | 2 +- tests/Aetheria.Shared.Tests/LoadoutTests.cs | 12 +- .../Aetheria.Shared.Tests/LockWarningTests.cs | 2 +- tests/Aetheria.Shared.Tests/LootTests.cs | 2 +- tests/Aetheria.Shared.Tests/MineTests.cs | 2 +- .../Aetheria.Shared.Tests/MiningCut1Tests.cs | 2 +- .../Aetheria.Shared.Tests/MiningCut2Tests.cs | 2 +- .../Aetheria.Shared.Tests/MiningCut3Tests.cs | 2 +- tests/Aetheria.Shared.Tests/PaintModeTests.cs | 2 +- tests/Aetheria.Shared.Tests/PickupTests.cs | 2 +- .../PopulatedRadiusTests.cs | 2 +- .../PotentialOwnerTests.cs | 2 +- tests/Aetheria.Shared.Tests/PowerBusTests.cs | 2 +- .../Aetheria.Shared.Tests/PowerCurveTests.cs | 2 +- tests/Aetheria.Shared.Tests/PowerTierTests.cs | 2 +- .../RoleAuthoringTests.cs | 4 +- tests/Aetheria.Shared.Tests/RunSaveTests.cs | 2 +- .../ShieldReserveTests.cs | 2 +- tests/Aetheria.Shared.Tests/SignatureTests.cs | 2 +- .../StatResolverTests.cs | 2 +- .../TargetingSystemTests.cs | 2 +- .../ThrottleLockTests.cs | 2 +- .../Aetheria.Shared.Tests/VapourCloudTests.cs | 2 +- .../ZonePlacedAtBuildTests.cs | 2 +- tests/Aetheria.Shared.Tests/ZoneWorlds.cs | 2 +- tools/AetherDb/AssemblyFromMakerCommand.cs | 70 +++++++++++ tools/AetherDb/Program.cs | 7 +- 67 files changed, 409 insertions(+), 98 deletions(-) create mode 100644 tests/Aetheria.Shared.Tests/AssemblyFromMakerCatalogTests.cs create mode 100644 tests/Aetheria.Shared.Tests/AssemblyFromMakerCommandTests.cs create mode 100644 tests/Aetheria.Shared.Tests/AssemblyFromMakerTests.cs create mode 100644 tools/AetherDb/AssemblyFromMakerCommand.cs diff --git a/Assets/Scripts/ServerShared/Corporations.cs b/Assets/Scripts/ServerShared/Corporations.cs index c1e69fcca..a17263933 100644 --- a/Assets/Scripts/ServerShared/Corporations.cs +++ b/Assets/Scripts/ServerShared/Corporations.cs @@ -63,6 +63,15 @@ public class Faction // The faction's rules of engagement; null fights as FactionDoctrine.Default. [Inspectable, JsonProperty("doctrine"), Key(17)] public FactionDoctrine Doctrine; + + // The maker's final-assembly technology (mean) and quality control (deviation): the distribution every lot of + // theirs draws its own quality from, and the hard ceiling on every one of its roles (quality-lean-assembly-hard-ceiling). + // Key 18 is reserved for Livery and 16 for Relations. + [Inspectable, JsonProperty("assemblyMean"), Key(19)] + public float AssemblyMean = .5f; + + [Inspectable, JsonProperty("assemblyDeviation"), Key(20)] + public float AssemblyDeviation = .15f; } [CultDocument("aetheria.namefile", "1"), Inspectable, MessagePackObject] diff --git a/Assets/Scripts/ServerShared/ItemManager.cs b/Assets/Scripts/ServerShared/ItemManager.cs index 884179e4e..2904c35f1 100644 --- a/Assets/Scripts/ServerShared/ItemManager.cs +++ b/Assets/Scripts/ServerShared/ItemManager.cs @@ -117,31 +117,20 @@ public class ItemManager return (int) (GameplaySettings.QualityPriceModifier.Evaluate(GetLot(item).Quality) * data.Price); } - // The tier roll every mint applies, whether or not the lot fills roles. - public float RollQuality() - { - var quality = Random.NextFloat(); - var tier = GameplaySettings.Tiers[0]; - foreach (var t in GameplaySettings.Tiers) - { - if (t.Rarity > quality) - tier = t; - } - - return tier.Quality; - } - - // Builds one of a manufacturer's branded products: the unit's own workmanship rolled as before, and each of - // the design's roles filled with a part whose quality is drawn from that manufacturer's distribution for it. + // Builds one of a manufacturer's branded products (quality-is-assembly-over-supply-chain): the unit's own quality is its + // final assembly, drawn from the maker's assembly distribution, and each of the design's roles is filled with a part whose + // quality is drawn from the product's distribution for it. A maker the catalog cannot resolve assembles at a new Faction's + // defaults. public int CreateLot(FactionProductData product) { var design = ItemData.Get(product.Design); + var maker = ItemData.Get(product.Manufacturer) ?? new Faction(); var lot = new Lot { Design = ItemData.RefOf(design), Origin = new Attributed { Faction = product.Manufacturer }, Product = ItemData.RefOf(product), - Quality = RollQuality(), + Quality = clamp(Random.NextGaussian(maker.AssemblyMean, maker.AssemblyDeviation), .01f, 1), Roles = new List() }; if (design.Roles != null) diff --git a/Assets/Scripts/ServerShared/Provenance.cs b/Assets/Scripts/ServerShared/Provenance.cs index 80e8e31f0..adf83c308 100644 --- a/Assets/Scripts/ServerShared/Provenance.cs +++ b/Assets/Scripts/ServerShared/Provenance.cs @@ -72,18 +72,20 @@ public class Lot // (console give, presets, extracted), which brand their maker only. [Key(4)] public CultRecordRef Product; - // The quality a stat reads for one of the design's roles. An unnamed role, a design without roles, and a lot - // minted before roles existed all fall back to the lot's own workmanship. + // The quality a stat reads for one of the design's roles: the part's, capped by the lot's own final assembly + // (quality-lean-assembly-hard-ceiling), so a part better than its assembly is worth the assembly. An unnamed role, a + // design without roles, and a lot minted before roles existed all fall back to the lot's own workmanship. public float QualityForRole(string role) { if (string.IsNullOrEmpty(role) || Roles == null) return Quality; foreach (var fill in Roles) - if (fill.Role == role) return fill.Quality; + if (fill.Role == role) return Math.Min(fill.Quality, Quality); return Quality; } } -// One filled slot: the design's role name and how good the part that went into it turned out to be. +// One filled slot: the design's role name and how good the part that went into it turned out to be. Stats read it through +// Lot.QualityForRole, capped by the lot's assembly; the raw value is kept for disassembly (named-components-after-demo). [MessagePackObject] public class RoleFill { diff --git a/Assets/Scripts/ServerShared/Settings.cs b/Assets/Scripts/ServerShared/Settings.cs index 85d1f3d96..1554f48e1 100644 --- a/Assets/Scripts/ServerShared/Settings.cs +++ b/Assets/Scripts/ServerShared/Settings.cs @@ -306,5 +306,4 @@ public class RarityTier public string Name; public float Quality; public float3 Color; - public float Rarity; } \ No newline at end of file diff --git a/tests/Aetheria.Shared.Tests/AssemblyFromMakerCatalogTests.cs b/tests/Aetheria.Shared.Tests/AssemblyFromMakerCatalogTests.cs new file mode 100644 index 000000000..fbd2698e6 --- /dev/null +++ b/tests/Aetheria.Shared.Tests/AssemblyFromMakerCatalogTests.cs @@ -0,0 +1,35 @@ +using System; +using System.Linq; +using System.Reflection; +using MessagePack; +using Xunit; + +// The shipped catalog carries each maker's derived assembly, and the Faction format pins its wire positions +// (aetheria-release, cut assembly-from-maker). +public sealed class AssemblyFromMakerCatalogTests +{ + [Fact] + public void ShippedCatalogCarriesDerivation() + { + using var cache = RestoredHullsTests.OpenCatalog(); + var products = cache.GetAll().Where(p => p.Roles.Count > 0).ToArray(); + var makers = products.Select(p => p.Manufacturer.Key).Distinct().ToArray(); + Assert.NotEmpty(makers); + foreach (var key in makers) + { + var roles = products.Where(p => p.Manufacturer.Key.Equals(key)).SelectMany(p => p.Roles).ToArray(); + var faction = cache.Get(key); + Assert.Equal(Math.Round(roles.Average(r => r.Mean), 2), faction.AssemblyMean, 2); + Assert.Equal(Math.Round(roles.Average(r => r.StandardDeviation), 2), faction.AssemblyDeviation, 2); + } + } + + // 16 is reserved for Relations, 17 is Doctrine, 18 is reserved for Livery. + [Fact] + public void AssemblyFieldsSitAtKeys19And20() + { + int KeyOf(string field) => typeof(Faction).GetField(field).GetCustomAttribute().IntKey.Value; + Assert.Equal(19, KeyOf(nameof(Faction.AssemblyMean))); + Assert.Equal(20, KeyOf(nameof(Faction.AssemblyDeviation))); + } +} diff --git a/tests/Aetheria.Shared.Tests/AssemblyFromMakerCommandTests.cs b/tests/Aetheria.Shared.Tests/AssemblyFromMakerCommandTests.cs new file mode 100644 index 000000000..f54af3a34 --- /dev/null +++ b/tests/Aetheria.Shared.Tests/AssemblyFromMakerCommandTests.cs @@ -0,0 +1,87 @@ +using System; +using System.IO; +using System.Linq; +using GameCult.Caching; +using Xunit; + +// assembly-from-maker (aetheria-release, cut assembly-from-maker): each maker's assembly distribution is derived from the +// roles of the products it manufactures. +public sealed class AssemblyFromMakerCommandTests : IDisposable +{ + private readonly string _root = Path.Combine(Path.GetTempPath(), "aetheria-assembly-cmd-" + Guid.NewGuid().ToString("N")); + private string Catalog => Path.Combine(_root, "Aetheria.cc"); + + public AssemblyFromMakerCommandTests() => Directory.CreateDirectory(_root); + public void Dispose() => Directory.Delete(_root, true); + + private void Seed() + { + using var cache = AetheriaStores.Open(Catalog, catalogWritable: true); + cache.Upsert(new VerseGrammar { Revision = 1 }); + var maker = cache.Upsert(new Faction { Name = "Maker" }); + cache.Upsert(new Faction { Name = "Bystander", AssemblyMean = .9f, AssemblyDeviation = .01f }); + var gear = cache.Upsert(new GearData { Name = "Lamp", Hardpoint = HardpointType.Sensors, Shape = new Shape(), Price = 10 }); + var design = new CultRecordRef(gear.Key); + // Two products, three roles: the mean is over roles (.2, .4, .9 -> .5), the deviation likewise (.1, .1, .4 -> .2). + cache.Upsert(new FactionProductData + { + Name = "A", Design = design, Manufacturer = maker, + Roles = { new ProductRole { Role = "x", Mean = .2f, StandardDeviation = .1f }, new ProductRole { Role = "y", Mean = .4f, StandardDeviation = .1f } } + }); + cache.Upsert(new FactionProductData + { + Name = "B", Design = design, Manufacturer = maker, + Roles = { new ProductRole { Role = "x", Mean = .9f, StandardDeviation = .4f } } + }); + // Figures that need two decimals: (.2 + .27 + .31) / 3 = .26 and (.11 + .17 + .2) / 3 = .16. + var fine = cache.Upsert(new Faction { Name = "Fine" }); + cache.Upsert(new FactionProductData + { + Name = "C", Design = design, Manufacturer = fine, + Roles = + { + new ProductRole { Role = "x", Mean = .2f, StandardDeviation = .11f }, + new ProductRole { Role = "y", Mean = .27f, StandardDeviation = .17f }, + new ProductRole { Role = "z", Mean = .31f, StandardDeviation = .2f } + } + }); + cache.FlushAsync().Wait(); + } + + private string Run(bool apply) + { + using var cache = AetheriaStores.Open(Catalog, catalogWritable: apply); + var output = new StringWriter(); + Assert.Equal(0, AssemblyFromMakerCommand.Run(cache, apply, output)); + cache.FlushAsync().Wait(); + return output.ToString(); + } + + [Fact] + public void DryRunWritesNothingApplyIsIdempotent() + { + Seed(); + var before = File.ReadAllBytes(Catalog); + Assert.Contains("Maker", Run(apply: false)); + Assert.Equal(before, File.ReadAllBytes(Catalog)); + + Run(apply: true); + using (var cache = AetheriaStores.Open(Catalog)) + { + var maker = cache.GetAll().Single(f => f.Name == "Maker"); + Assert.Equal(.5f, maker.AssemblyMean, 3); + Assert.Equal(.2f, maker.AssemblyDeviation, 3); + var fine = cache.GetAll().Single(f => f.Name == "Fine"); + Assert.Equal(.26f, fine.AssemblyMean, 3); + Assert.Equal(.16f, fine.AssemblyDeviation, 3); + // A faction that manufactures nothing is written the field defaults. + var bystander = cache.GetAll().Single(f => f.Name == "Bystander"); + Assert.Equal(.5f, bystander.AssemblyMean, 3); + Assert.Equal(.15f, bystander.AssemblyDeviation, 3); + } + + var written = File.ReadAllBytes(Catalog); + Assert.Contains("No changes", Run(apply: true)); + Assert.Equal(written, File.ReadAllBytes(Catalog)); + } +} diff --git a/tests/Aetheria.Shared.Tests/AssemblyFromMakerTests.cs b/tests/Aetheria.Shared.Tests/AssemblyFromMakerTests.cs new file mode 100644 index 000000000..17df5331f --- /dev/null +++ b/tests/Aetheria.Shared.Tests/AssemblyFromMakerTests.cs @@ -0,0 +1,118 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using GameCult.Caching; +using Xunit; + +// Assembly is the maker's (aetheria-release, cut assembly-from-maker; rulings quality-is-assembly-over-supply-chain, +// quality-lean-assembly-hard-ceiling): a branded lot's own quality is drawn from its manufacturer's assembly distribution, +// and every role a stat reads is min(part, assembly). Lots here come from CreateLot(product), the production mint. +public sealed class AssemblyFromMakerTests : IDisposable +{ + private readonly string _root = Path.Combine(Path.GetTempPath(), "aetheria-assembly-" + Guid.NewGuid().ToString("N")); + private readonly CultCache _cache; + private readonly ItemManager _items; + private readonly CultRecordRef _lens; + + public AssemblyFromMakerTests() + { + Directory.CreateDirectory(_root); + _cache = AetheriaStores.Open(Path.Combine(_root, "Aetheria.cc"), catalogWritable: true); + var gear = _cache.Upsert(new GearData + { + Name = "Lensed", Hardpoint = HardpointType.Sensors, Shape = new Shape(), Price = 10, + Roles = { new ItemRole { Name = "lens" } } + }); + _lens = new CultRecordRef(gear.Key); + _items = new ItemManager(_cache, new ProvenanceLedger(), RunSaveTests.TestSettings(), _ => { }); + } + + public void Dispose() + { + _cache.Dispose(); + Directory.Delete(_root, true); + } + + private FactionProductData Product(string name, Faction maker, float partMean, float partDeviation = 0) + { + var makerRef = maker == null ? default : _cache.Upsert(maker); + _cache.Upsert(new FactionProductData + { + Name = name, Design = _lens, Manufacturer = makerRef, + Roles = { new ProductRole { Role = "lens", Mean = partMean, StandardDeviation = partDeviation } } + }); + return _cache.GetAll().Single(p => p.Name == name); + } + + private float[] Mint(FactionProductData product, int count) => + Enumerable.Range(0, count).Select(_ => _items.Lots[_items.CreateLot(product)].Quality).ToArray(); + + // Two makers, assembly .3 and .8: each lot's own quality follows its manufacturer, not a product-blind roll. + [Fact] + public void LotQualityFollowsMaker() + { + var low = Product("Low", new Faction { Name = "Low Maker", AssemblyMean = .3f, AssemblyDeviation = .02f }, .5f); + var high = Product("High", new Faction { Name = "High Maker", AssemblyMean = .8f, AssemblyDeviation = .02f }, .5f); + var lows = Mint(low, 300); + var highs = Mint(high, 300); + Assert.InRange(lows.Average(), .27f, .33f); + Assert.InRange(highs.Average(), .77f, .83f); + Assert.True(lows.Max() < highs.Min(), "a lot read the other maker's band"); + } + + // Quality control is the maker's too: the same mean, a wide and a tight deviation, and the spread of their lots follows. + [Fact] + public void LotSpreadFollowsMakerDeviation() + { + var wide = Mint(Product("Wide", new Faction { Name = "Wide Maker", AssemblyMean = .5f, AssemblyDeviation = .2f }, .5f), 400); + var tight = Mint(Product("Tight", new Faction { Name = "Tight Maker", AssemblyMean = .5f, AssemblyDeviation = .02f }, .5f), 400); + double Spread(float[] lots) => Math.Sqrt(lots.Select(q => Math.Pow(q - lots.Average(), 2)).Average()); + Assert.InRange(Spread(wide), .15, .25); + Assert.InRange(Spread(tight), .01, .04); + } + + // A maker the catalog cannot resolve assembles at a new Faction's defaults. + [Fact] + public void UnresolvedMakerAssemblesAtDefaults() + { + var orphan = Product("Orphan", null, .5f); + var defaults = new Faction(); + Assert.InRange(Mint(orphan, 400).Average(), defaults.AssemblyMean - .03f, defaults.AssemblyMean + .03f); + } + + // The ceiling at the mint: a part drawn at .9 in an assembly of .4 reads .4; a part at .2 in the same assembly reads .2. + [Fact] + public void RoleCappedByAssembly() + { + var maker = new Faction { Name = "Capped", AssemblyMean = .4f, AssemblyDeviation = 0 }; + var over = _items.Lots[_items.CreateLot(Product("Over", maker, .9f))]; + var under = _items.Lots[_items.CreateLot(Product("Under", maker, .2f))]; + Assert.Equal(.4f, over.Quality, 3); + Assert.Equal(.4f, over.QualityForRole("lens"), 3); + Assert.Equal(.2f, under.QualityForRole("lens"), 3); + // The raw part is kept for disassembly (named-components-after-demo). + Assert.Equal(.9f, over.Roles.Single().Quality, 3); + } + + // The fallbacks still read the assembly: an unnamed role, an unrolled role, and a lot with no roles. + [Fact] + public void FallbacksReadTheAssembly() + { + var lot = new Lot { Quality = .4f, Roles = new List { new RoleFill { Role = "lens", Quality = .9f } } }; + Assert.Equal(.4f, lot.QualityForRole(null), 3); + Assert.Equal(.4f, lot.QualityForRole(""), 3); + Assert.Equal(.4f, lot.QualityForRole("ghost"), 3); + Assert.Equal(.4f, new Lot { Quality = .4f }.QualityForRole("lens"), 3); + } + + // A Quality term on a role with part .9 and assembly .4 evaluates as if quality were .4, on a real minted instance. + [Fact] + public void QualityTermReadsCeiling() + { + var maker = new Faction { Name = "Capped", AssemblyMean = .4f, AssemblyDeviation = 0 }; + var instance = (EquippableItem) _items.CreateInstance(_items.CreateLot(Product("Over", maker, .9f))); + var stat = new PerformanceStat { Min = 0, Max = 1, Terms = { new StatTerm { Source = StatSource.Quality, Exponent = 1, Role = "lens" } } }; + Assert.Equal(.4f, _items.Evaluate(stat, instance), 3); + } +} diff --git a/tests/Aetheria.Shared.Tests/BrownoutTests.cs b/tests/Aetheria.Shared.Tests/BrownoutTests.cs index c901648e7..b48657e33 100644 --- a/tests/Aetheria.Shared.Tests/BrownoutTests.cs +++ b/tests/Aetheria.Shared.Tests/BrownoutTests.cs @@ -52,7 +52,7 @@ public sealed class BrownoutTests : IDisposable private static GameplaySettings Settings() => new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp() }; diff --git a/tests/Aetheria.Shared.Tests/CatalogRoleTests.cs b/tests/Aetheria.Shared.Tests/CatalogRoleTests.cs index 0a452491f..b50e0142d 100644 --- a/tests/Aetheria.Shared.Tests/CatalogRoleTests.cs +++ b/tests/Aetheria.Shared.Tests/CatalogRoleTests.cs @@ -322,7 +322,7 @@ public sealed class CatalogRoleTests private sealed class DisciplineContext : IStatContext { public DisciplineContext(float discipline) => - Lot = new Lot { Quality = .123f, Roles = new List { new RoleFill { Role = "emission-discipline", Quality = discipline } } }; + Lot = new Lot { Quality = 1f, Roles = new List { new RoleFill { Role = "emission-discipline", Quality = discipline } } }; public Lot Lot { get; } public float HeatFactor(float exponent) => 1f; public float DurabilityFactor(float exponent) => 1f; diff --git a/tests/Aetheria.Shared.Tests/ConditionRatioTests.cs b/tests/Aetheria.Shared.Tests/ConditionRatioTests.cs index e294b942f..c3a5ddcde 100644 --- a/tests/Aetheria.Shared.Tests/ConditionRatioTests.cs +++ b/tests/Aetheria.Shared.Tests/ConditionRatioTests.cs @@ -27,7 +27,7 @@ public sealed class ConditionRatioTests : IDisposable private static GameplaySettings Settings() => new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp() }; diff --git a/tests/Aetheria.Shared.Tests/ConsumableSupplyTests.cs b/tests/Aetheria.Shared.Tests/ConsumableSupplyTests.cs index cd968e885..78cbf6f0f 100644 --- a/tests/Aetheria.Shared.Tests/ConsumableSupplyTests.cs +++ b/tests/Aetheria.Shared.Tests/ConsumableSupplyTests.cs @@ -334,14 +334,15 @@ public sealed class ConsumableSupplyTests : IDisposable .Concat(Enumerable.Range(0, 4).Select(_ => rig.Items.Random.NextFloat())).ToArray(); } - // What the plain catalog leaves in both generators' Random, measured on the tree before consumables existed - // (origin/master d4a27def, the same fixture and seeds), plus the one product draw each of the three generated - // ships makes for its tractor beam (loot-2): with that draw taken out the tree leaves the d4a27def values - // 0.85624266, 0.037778974, 0.7931649, 0.3596493, 0.17511952, 0.6642336, 0.31897342, 0.5977364. The gated and - // plain catalogs agreeing is not enough: a step that drew unconditionally would draw in both. This pins the value itself. + // What the plain catalog leaves in both generators' Random: the d4a27def measurement (before consumables existed, the + // same fixture and seeds) plus the one product draw each of the three generated ships makes for its tractor beam + // (loot-2), re-measured when a lot's assembly became a Gaussian draw from its maker (assembly-from-maker), which + // consumes the item stream differently from the tier roll it replaced; the generator's own stream (the first four + // values) is unchanged. The gated and plain catalogs agreeing is not enough: a step that drew unconditionally would + // draw in both. This pins the value itself. var beforeConsumables = new[] { - 0.3596493f, 0.03616327f, 0.8790466f, 0.16682059f, 0.5977364f, 0.08633745f, 0.2869571f, 0.6890472f + 0.3596493f, 0.03616327f, 0.8790466f, 0.16682059f, 0.55950844f, 0.87309176f, 0.7170387f, 0.8490041f }; var plainAfter = AfterGeneration(plain); Assert.Equal(beforeConsumables, plainAfter); diff --git a/tests/Aetheria.Shared.Tests/ConsumablesFirstSetTests.cs b/tests/Aetheria.Shared.Tests/ConsumablesFirstSetTests.cs index d43fb47be..300c2f9b9 100644 --- a/tests/Aetheria.Shared.Tests/ConsumablesFirstSetTests.cs +++ b/tests/Aetheria.Shared.Tests/ConsumablesFirstSetTests.cs @@ -146,7 +146,7 @@ public sealed class ConsumablesFirstSetTests var second = design.Roles[1].Name; var lot = Ship.ItemManager.Lots.Add(new Lot { - Design = Cache.RefOf(design), Origin = new Attributed(), Quality = .5f, + Design = Cache.RefOf(design), Origin = new Attributed(), Quality = 1f, Roles = new List { new RoleFill { Role = first, Quality = propellantOrNozzleQuality }, diff --git a/tests/Aetheria.Shared.Tests/ContactRevealTests.cs b/tests/Aetheria.Shared.Tests/ContactRevealTests.cs index 6ea4af3da..bdca8008f 100644 --- a/tests/Aetheria.Shared.Tests/ContactRevealTests.cs +++ b/tests/Aetheria.Shared.Tests/ContactRevealTests.cs @@ -176,7 +176,7 @@ public sealed partial class ContactRevealTests : IDisposable _items = new ItemManager(_openCache, ledger, new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp(), TargetDetectionInfoThreshold = .1f, TargetGearInfoThreshold = .8f, diff --git a/tests/Aetheria.Shared.Tests/ContactTests.cs b/tests/Aetheria.Shared.Tests/ContactTests.cs index bccd2a90d..adceb4b98 100644 --- a/tests/Aetheria.Shared.Tests/ContactTests.cs +++ b/tests/Aetheria.Shared.Tests/ContactTests.cs @@ -90,7 +90,7 @@ public sealed class ContactTests : IDisposable var settings = new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp(), TargetDetectionInfoThreshold = .1f, TargetGearInfoThreshold = .8f, FiringArc = 170, CommitHorizon = .5f, SchematicCellSize = 2f, ContactRestitution = restitution diff --git a/tests/Aetheria.Shared.Tests/DrawnPoseTests.cs b/tests/Aetheria.Shared.Tests/DrawnPoseTests.cs index acc7f8f72..e2da6ea72 100644 --- a/tests/Aetheria.Shared.Tests/DrawnPoseTests.cs +++ b/tests/Aetheria.Shared.Tests/DrawnPoseTests.cs @@ -86,7 +86,7 @@ public sealed class DrawnPoseTests : IDisposable var items = new ItemManager(cache, ledger, new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp(), ShipLayerHeight = ShipLayerHeight, OrbitalLayerHeight = OrbitalLayerHeight }, _ => { }); diff --git a/tests/Aetheria.Shared.Tests/EmissionTests.cs b/tests/Aetheria.Shared.Tests/EmissionTests.cs index c6e2927b8..831f6f520 100644 --- a/tests/Aetheria.Shared.Tests/EmissionTests.cs +++ b/tests/Aetheria.Shared.Tests/EmissionTests.cs @@ -316,7 +316,7 @@ public sealed partial class ContactRevealTests } // A catalog-style sensor reads its intercept factor through the lot the ship equips it from: the lot's - // emission-discipline fill is the input (the workmanship is a decoy at .123), so a Sensor that read only the quiet or only + // emission-discipline fill is the input (the workmanship, at 1, is a decoy), so a Sensor that read only the quiet or only // the loud end, or the workmanship, reads the wrong number. The expectations are lerp(.5, 2, q^log2(3)): a middling part // reads 1, the Lucent mean (.2) reads about .62 and the Finch mean (.8) about 1.55. [Theory] @@ -325,7 +325,7 @@ public sealed partial class ContactRevealTests [InlineData(.8f, 1.5534f)] public void ASensorReadsItsInterceptFactorFromItsLotsEmissionDiscipline(float discipline, float expected) { - var lot = _items.CreateLot(_openCache.GetByName("Disciplined"), _maker, .123f); + var lot = _items.CreateLot(_openCache.GetByName("Disciplined"), _maker, 1f); _items.Lots[lot].Roles = new List { new RoleFill { Role = "emission-discipline", Quality = discipline } }; _preparedLots["Disciplined"] = lot; var ship = Add(float3(0, 0, 0), new[] { "Disciplined" }); @@ -345,7 +345,7 @@ public sealed partial class ContactRevealTests public void AnEmissionIsHeardWithinRangeOverTheLotsAlpha(bool ping, float distance, bool heard) { var design = ping ? "Disciplined" : "DisciplinedScanner"; - var lot = _items.CreateLot(_openCache.GetByName(design), _maker, .123f); + var lot = _items.CreateLot(_openCache.GetByName(design), _maker, 1f); _items.Lots[lot].Roles = new List { new RoleFill { Role = "emission-discipline", Quality = .2f } }; _preparedLots[design] = lot; var third = Add(float3(-distance, 0, 0), new[] { "Eye" }); diff --git a/tests/Aetheria.Shared.Tests/FireAuthorityTests.cs b/tests/Aetheria.Shared.Tests/FireAuthorityTests.cs index fb919c2ec..8323bd7a9 100644 --- a/tests/Aetheria.Shared.Tests/FireAuthorityTests.cs +++ b/tests/Aetheria.Shared.Tests/FireAuthorityTests.cs @@ -37,7 +37,7 @@ public sealed class FireAuthorityTests : IDisposable private static GameplaySettings TestSettings() => new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp(), TargetDetectionInfoThreshold = .1f, FiringArc = 170, diff --git a/tests/Aetheria.Shared.Tests/FireControlCut11Tests.cs b/tests/Aetheria.Shared.Tests/FireControlCut11Tests.cs index 5dc373390..9e9d74fce 100644 --- a/tests/Aetheria.Shared.Tests/FireControlCut11Tests.cs +++ b/tests/Aetheria.Shared.Tests/FireControlCut11Tests.cs @@ -37,7 +37,7 @@ public sealed class FireControlCut11Tests : IDisposable private static GameplaySettings TestSettings(float schematicCellSize = 1f) => new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp(), TargetDetectionInfoThreshold = .1f, TargetGearInfoThreshold = .8f, diff --git a/tests/Aetheria.Shared.Tests/FireControlCut123Tests.cs b/tests/Aetheria.Shared.Tests/FireControlCut123Tests.cs index 670b96490..7e49ec3c7 100644 --- a/tests/Aetheria.Shared.Tests/FireControlCut123Tests.cs +++ b/tests/Aetheria.Shared.Tests/FireControlCut123Tests.cs @@ -39,7 +39,7 @@ public sealed class FireControlCut123Tests : IDisposable private static GameplaySettings TestSettings() => new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp(), TargetDetectionInfoThreshold = .1f, TargetGearInfoThreshold = .8f, diff --git a/tests/Aetheria.Shared.Tests/FireControlCut124Tests.cs b/tests/Aetheria.Shared.Tests/FireControlCut124Tests.cs index 4bcd5b034..e6d8f5a0e 100644 --- a/tests/Aetheria.Shared.Tests/FireControlCut124Tests.cs +++ b/tests/Aetheria.Shared.Tests/FireControlCut124Tests.cs @@ -41,7 +41,7 @@ public sealed partial class FireControlCut124Tests : IDisposable private static GameplaySettings TestSettings(float commitHorizon = .5f) => new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp(), TargetDetectionInfoThreshold = .1f, TargetGearInfoThreshold = .8f, diff --git a/tests/Aetheria.Shared.Tests/FireControlCut12Tests.cs b/tests/Aetheria.Shared.Tests/FireControlCut12Tests.cs index 1c343c00b..adbcac5ef 100644 --- a/tests/Aetheria.Shared.Tests/FireControlCut12Tests.cs +++ b/tests/Aetheria.Shared.Tests/FireControlCut12Tests.cs @@ -38,7 +38,7 @@ public sealed class FireControlCut12Tests : IDisposable private static GameplaySettings TestSettings() => new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp(), TargetDetectionInfoThreshold = .1f, TargetGearInfoThreshold = .8f, diff --git a/tests/Aetheria.Shared.Tests/FireControlCut4Tests.cs b/tests/Aetheria.Shared.Tests/FireControlCut4Tests.cs index 469ebc75b..08ba48d0d 100644 --- a/tests/Aetheria.Shared.Tests/FireControlCut4Tests.cs +++ b/tests/Aetheria.Shared.Tests/FireControlCut4Tests.cs @@ -39,7 +39,7 @@ public sealed class FireControlCut4Tests : IDisposable private static GameplaySettings TestSettings() => new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp(), TargetDetectionInfoThreshold = .1f, FiringArc = 170, diff --git a/tests/Aetheria.Shared.Tests/FireControlCut5Tests.cs b/tests/Aetheria.Shared.Tests/FireControlCut5Tests.cs index f9d12e330..1727a9829 100644 --- a/tests/Aetheria.Shared.Tests/FireControlCut5Tests.cs +++ b/tests/Aetheria.Shared.Tests/FireControlCut5Tests.cs @@ -37,7 +37,7 @@ public sealed class FireControlCut5Tests : IDisposable private static GameplaySettings TestSettings() => new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp(), TargetDetectionInfoThreshold = .1f, TargetGearInfoThreshold = .8f, diff --git a/tests/Aetheria.Shared.Tests/FireControlCut6Tests.cs b/tests/Aetheria.Shared.Tests/FireControlCut6Tests.cs index 1755cd7e3..03aab2e3f 100644 --- a/tests/Aetheria.Shared.Tests/FireControlCut6Tests.cs +++ b/tests/Aetheria.Shared.Tests/FireControlCut6Tests.cs @@ -37,7 +37,7 @@ public sealed class FireControlCut6Tests : IDisposable private static GameplaySettings TestSettings() => new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp(), TargetDetectionInfoThreshold = .1f, TargetGearInfoThreshold = .8f, diff --git a/tests/Aetheria.Shared.Tests/FireControlCut6cTests.cs b/tests/Aetheria.Shared.Tests/FireControlCut6cTests.cs index e04ee078b..5517c4121 100644 --- a/tests/Aetheria.Shared.Tests/FireControlCut6cTests.cs +++ b/tests/Aetheria.Shared.Tests/FireControlCut6cTests.cs @@ -36,7 +36,7 @@ public sealed class FireControlCut6cTests : IDisposable private static GameplaySettings TestSettings() => new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp(), TargetDetectionInfoThreshold = .1f, TargetGearInfoThreshold = .8f, diff --git a/tests/Aetheria.Shared.Tests/FireControlCut6dTests.cs b/tests/Aetheria.Shared.Tests/FireControlCut6dTests.cs index 828965836..9fdbde4a0 100644 --- a/tests/Aetheria.Shared.Tests/FireControlCut6dTests.cs +++ b/tests/Aetheria.Shared.Tests/FireControlCut6dTests.cs @@ -38,7 +38,7 @@ public sealed class FireControlCut6dTests : IDisposable private static GameplaySettings TestSettings() => new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp(), TargetDetectionInfoThreshold = .1f, TargetGearInfoThreshold = .8f, diff --git a/tests/Aetheria.Shared.Tests/FireControlCut7Tests.cs b/tests/Aetheria.Shared.Tests/FireControlCut7Tests.cs index 01bd840ee..4e0c4a91f 100644 --- a/tests/Aetheria.Shared.Tests/FireControlCut7Tests.cs +++ b/tests/Aetheria.Shared.Tests/FireControlCut7Tests.cs @@ -40,7 +40,7 @@ public sealed class FireControlCut7Tests : IDisposable private static GameplaySettings TestSettings() => new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp(), TargetDetectionInfoThreshold = .1f, TargetGearInfoThreshold = .9f, @@ -210,7 +210,7 @@ public sealed class FireControlCut7Tests : IDisposable var settings = new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp() }; var log = new List(); diff --git a/tests/Aetheria.Shared.Tests/FireControlCut8Tests.cs b/tests/Aetheria.Shared.Tests/FireControlCut8Tests.cs index d5ce6a28b..a0d767ab3 100644 --- a/tests/Aetheria.Shared.Tests/FireControlCut8Tests.cs +++ b/tests/Aetheria.Shared.Tests/FireControlCut8Tests.cs @@ -36,7 +36,7 @@ public sealed class FireControlCut8Tests : IDisposable private static GameplaySettings TestSettings() => new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp(), TargetDetectionInfoThreshold = .1f, TargetGearInfoThreshold = .8f, diff --git a/tests/Aetheria.Shared.Tests/FireControlCut9Tests.cs b/tests/Aetheria.Shared.Tests/FireControlCut9Tests.cs index cc63a9bc4..448cbb333 100644 --- a/tests/Aetheria.Shared.Tests/FireControlCut9Tests.cs +++ b/tests/Aetheria.Shared.Tests/FireControlCut9Tests.cs @@ -39,7 +39,7 @@ public sealed class FireControlCut9Tests : IDisposable private static GameplaySettings TestSettings() => new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp(), TargetDetectionInfoThreshold = .1f, TargetGearInfoThreshold = .8f, diff --git a/tests/Aetheria.Shared.Tests/FireControlPerWeaponTests.cs b/tests/Aetheria.Shared.Tests/FireControlPerWeaponTests.cs index 21cde60cb..2eca55442 100644 --- a/tests/Aetheria.Shared.Tests/FireControlPerWeaponTests.cs +++ b/tests/Aetheria.Shared.Tests/FireControlPerWeaponTests.cs @@ -39,7 +39,7 @@ public sealed class FireControlPerWeaponTests : IDisposable { OrbitalLayerHeight = orbitalLayerHeight, DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp(), TargetDetectionInfoThreshold = .1f, TargetGearInfoThreshold = .8f, diff --git a/tests/Aetheria.Shared.Tests/FireControlTests.cs b/tests/Aetheria.Shared.Tests/FireControlTests.cs index 68ab9a6db..b10a2fa18 100644 --- a/tests/Aetheria.Shared.Tests/FireControlTests.cs +++ b/tests/Aetheria.Shared.Tests/FireControlTests.cs @@ -33,7 +33,7 @@ public sealed class FireControlTests : IDisposable { ShipLayerHeight = shipLayerHeight, DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp(), TargetDetectionInfoThreshold = .5f, FiringArc = 120 diff --git a/tests/Aetheria.Shared.Tests/FlightTests.cs b/tests/Aetheria.Shared.Tests/FlightTests.cs index 263f9a086..cec6652c6 100644 --- a/tests/Aetheria.Shared.Tests/FlightTests.cs +++ b/tests/Aetheria.Shared.Tests/FlightTests.cs @@ -919,7 +919,7 @@ public sealed class FlightTests : IDisposable var slots = MessagePack.MessagePackSerializer.Deserialize(MessagePack.MessagePackSerializer.Serialize(faction, CultDocumentMessagePackSerialization.OptionsFor(typeof(Faction).Assembly))); - Assert.Equal(18, slots.Length); + Assert.Equal(21, slots.Length); Assert.Null(slots[16]); var doctrine = Assert.IsType(slots[17]); Assert.Equal(6f, Convert.ToSingle(doctrine[1])); diff --git a/tests/Aetheria.Shared.Tests/FloatingBodyTests.cs b/tests/Aetheria.Shared.Tests/FloatingBodyTests.cs index 3ca18c4aa..d2ee30870 100644 --- a/tests/Aetheria.Shared.Tests/FloatingBodyTests.cs +++ b/tests/Aetheria.Shared.Tests/FloatingBodyTests.cs @@ -36,7 +36,7 @@ public sealed class FloatingBodyTests : IDisposable var settings = new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp() }; var items = new ItemManager(cache, new ProvenanceLedger(), settings, _ => { }); @@ -180,7 +180,7 @@ public sealed class FloatingBodyTests : IDisposable var settings = new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp() }; var items = new ItemManager(cache, new ProvenanceLedger(), settings, _ => { }); diff --git a/tests/Aetheria.Shared.Tests/FlowFieldTests.cs b/tests/Aetheria.Shared.Tests/FlowFieldTests.cs index c5cb3b793..fefff55f4 100644 --- a/tests/Aetheria.Shared.Tests/FlowFieldTests.cs +++ b/tests/Aetheria.Shared.Tests/FlowFieldTests.cs @@ -25,7 +25,7 @@ public sealed class FlowFieldTests : IDisposable var settings = new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp(), TargetDetectionInfoThreshold = .1f, TargetGearInfoThreshold = .8f, FiringArc = 170, CommitHorizon = .5f, SchematicCellSize = 2f diff --git a/tests/Aetheria.Shared.Tests/GravitySubtractTests.cs b/tests/Aetheria.Shared.Tests/GravitySubtractTests.cs index 2b329ad5d..f21d78f79 100644 --- a/tests/Aetheria.Shared.Tests/GravitySubtractTests.cs +++ b/tests/Aetheria.Shared.Tests/GravitySubtractTests.cs @@ -24,7 +24,7 @@ public sealed class GravitySubtractTests : IDisposable var settings = new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp(), TargetDetectionInfoThreshold = .1f, TargetGearInfoThreshold = .8f, FiringArc = 170, CommitHorizon = .5f, SchematicCellSize = 2f diff --git a/tests/Aetheria.Shared.Tests/HeatResponseTests.cs b/tests/Aetheria.Shared.Tests/HeatResponseTests.cs index 0f21e50d1..9711f91c1 100644 --- a/tests/Aetheria.Shared.Tests/HeatResponseTests.cs +++ b/tests/Aetheria.Shared.Tests/HeatResponseTests.cs @@ -20,7 +20,7 @@ public sealed class HeatResponseTests : IDisposable private GameplaySettings Settings() => new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp() }; diff --git a/tests/Aetheria.Shared.Tests/IffAndCombatTests.cs b/tests/Aetheria.Shared.Tests/IffAndCombatTests.cs index 0de789ff1..b2bd752ba 100644 --- a/tests/Aetheria.Shared.Tests/IffAndCombatTests.cs +++ b/tests/Aetheria.Shared.Tests/IffAndCombatTests.cs @@ -65,7 +65,7 @@ public sealed class IffAndCombatTests : IDisposable private static GameplaySettings TestSettings() => new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp(), TargetDetectionInfoThreshold = .5f }; diff --git a/tests/Aetheria.Shared.Tests/InputCapacitorTests.cs b/tests/Aetheria.Shared.Tests/InputCapacitorTests.cs index 3a7b9e2d5..d7279380e 100644 --- a/tests/Aetheria.Shared.Tests/InputCapacitorTests.cs +++ b/tests/Aetheria.Shared.Tests/InputCapacitorTests.cs @@ -24,7 +24,7 @@ public sealed class InputCapacitorTests : IDisposable private static GameplaySettings Settings() => new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp() }; diff --git a/tests/Aetheria.Shared.Tests/InspectionScannerCatalogTests.cs b/tests/Aetheria.Shared.Tests/InspectionScannerCatalogTests.cs index 43d7fcce4..e9cb862fa 100644 --- a/tests/Aetheria.Shared.Tests/InspectionScannerCatalogTests.cs +++ b/tests/Aetheria.Shared.Tests/InspectionScannerCatalogTests.cs @@ -102,7 +102,7 @@ public sealed class InspectionScannerCatalogTests ledger.Lots[1] = new Lot { Origin = new Attributed(), Quality = .5f }; ledger.Lots[2] = new Lot { - Origin = new Attributed(), Quality = .5f, + Origin = new Attributed(), Quality = 1f, Roles = product.Roles.Select(r => new RoleFill { Role = r.Role, Quality = r.Mean }).ToList(), }; var items = new ItemManager(Cache, ledger, settings, _ => { }); diff --git a/tests/Aetheria.Shared.Tests/LaunchSuppressorCatalogTests.cs b/tests/Aetheria.Shared.Tests/LaunchSuppressorCatalogTests.cs index 096845380..d54f7c983 100644 --- a/tests/Aetheria.Shared.Tests/LaunchSuppressorCatalogTests.cs +++ b/tests/Aetheria.Shared.Tests/LaunchSuppressorCatalogTests.cs @@ -113,7 +113,7 @@ public sealed class LaunchSuppressorCatalogTests for (var i = 1; i <= suppressorLot; i++) ledger.Lots[i] = new Lot { Origin = new Attributed(), Quality = .5f }; ledger.Lots[suppressorLot] = new Lot { - Origin = new Attributed(), Quality = .5f, + Origin = new Attributed(), Quality = 1f, Roles = new List { new RoleFill { Role = "baffles", Quality = baffles }, new RoleFill { Role = "heat sink", Quality = sink } }, }; var items = new ItemManager(Cache, ledger, settings, _ => { }); diff --git a/tests/Aetheria.Shared.Tests/LayerTests.cs b/tests/Aetheria.Shared.Tests/LayerTests.cs index cb1bf4cf9..75d79d947 100644 --- a/tests/Aetheria.Shared.Tests/LayerTests.cs +++ b/tests/Aetheria.Shared.Tests/LayerTests.cs @@ -37,7 +37,7 @@ public sealed class LayerTests : IDisposable private static GameplaySettings Settings() => new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp(), ShipLayerHeight = ShipHeight, OrbitalLayerHeight = OrbitalHeight, FloaterLayerHeight = FloaterHeight }; diff --git a/tests/Aetheria.Shared.Tests/LoadoutTests.cs b/tests/Aetheria.Shared.Tests/LoadoutTests.cs index f1ae47b5d..4efbd0b30 100644 --- a/tests/Aetheria.Shared.Tests/LoadoutTests.cs +++ b/tests/Aetheria.Shared.Tests/LoadoutTests.cs @@ -489,8 +489,8 @@ public sealed class LoadoutTests : IDisposable Assert.Equal(hardpointItems[0].item.Lot, hardpointItems[1].item.Lot); } - // A Lamp lot with Quality .2 and one role fill (lens .9): a stat reading that role gets .9, one reading none - // gets .2, and GetTier reads .2. + // A Lamp lot with Quality .2 and one role fill (lens .15, under the assembly): a stat reading that role gets .15, one + // reading none gets .2, and GetTier reads .2. [Fact] public void StatsReadTheLot() { @@ -500,8 +500,8 @@ public sealed class LoadoutTests : IDisposable // quality", since every lot would resolve to the only tier regardless of its own Quality. settings.Tiers = new[] { - new RarityTier { Name = "Common", Quality = .2f, Rarity = 0, Color = new float3(1, 1, 1) }, - new RarityTier { Name = "Rare", Quality = .5f, Rarity = 1, Color = new float3(1, 1, 1) } + new RarityTier { Name = "Common", Quality = .2f, Color = new float3(1, 1, 1) }, + new RarityTier { Name = "Rare", Quality = .5f, Color = new float3(1, 1, 1) } }; var items = new ItemManager(cache, new ProvenanceLedger(), settings, _ => { }); var lamp = cache.GetByName("Lamp"); @@ -510,7 +510,7 @@ public sealed class LoadoutTests : IDisposable Design = cache.RefOf(lamp), Origin = new Attributed(), Quality = .2f, - Roles = new List { new RoleFill { Role = "lens", Quality = .9f } } + Roles = new List { new RoleFill { Role = "lens", Quality = .15f } } }); var rareLot = items.Lots.Add(new Lot { @@ -524,7 +524,7 @@ public sealed class LoadoutTests : IDisposable var withRole = new PerformanceStat { Min = 0, Max = 1, Terms = { new StatTerm { Source = StatSource.Quality, Exponent = 1, Role = "lens" } } }; var noRole = new PerformanceStat { Min = 0, Max = 1, Terms = { new StatTerm { Source = StatSource.Quality, Exponent = 1 } } }; - Assert.Equal(.9f, items.Evaluate(withRole, instance), 3); + Assert.Equal(.15f, items.Evaluate(withRole, instance), 3); Assert.Equal(.2f, items.Evaluate(noRole, instance), 3); Assert.Equal(.2f, items.GetTier(instance).tier.Quality, 3); Assert.Equal(.5f, items.GetTier(rareInstance).tier.Quality, 3); diff --git a/tests/Aetheria.Shared.Tests/LockWarningTests.cs b/tests/Aetheria.Shared.Tests/LockWarningTests.cs index 18b068e63..1ed414bb6 100644 --- a/tests/Aetheria.Shared.Tests/LockWarningTests.cs +++ b/tests/Aetheria.Shared.Tests/LockWarningTests.cs @@ -43,7 +43,7 @@ public sealed class LockWarningTests : IDisposable _items = new ItemManager(_openCache, ledger, new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp(), TargetDetectionInfoThreshold = .1f, TargetGearInfoThreshold = .8f, diff --git a/tests/Aetheria.Shared.Tests/LootTests.cs b/tests/Aetheria.Shared.Tests/LootTests.cs index 4aef9ff25..f0b52f4ce 100644 --- a/tests/Aetheria.Shared.Tests/LootTests.cs +++ b/tests/Aetheria.Shared.Tests/LootTests.cs @@ -66,7 +66,7 @@ public sealed class LootTests : IDisposable var settings = new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp(), TargetDetectionInfoThreshold = .1f, TargetGearInfoThreshold = .8f, FiringArc = 170, CommitHorizon = .5f, SchematicCellSize = 1f, diff --git a/tests/Aetheria.Shared.Tests/MineTests.cs b/tests/Aetheria.Shared.Tests/MineTests.cs index ddb805206..a2deeb5cf 100644 --- a/tests/Aetheria.Shared.Tests/MineTests.cs +++ b/tests/Aetheria.Shared.Tests/MineTests.cs @@ -72,7 +72,7 @@ public sealed class MineTests : IDisposable var settings = new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp(), TargetDetectionInfoThreshold = .1f, TargetGearInfoThreshold = .8f, FiringArc = 170, CommitHorizon = .5f, SchematicCellSize = 2f, diff --git a/tests/Aetheria.Shared.Tests/MiningCut1Tests.cs b/tests/Aetheria.Shared.Tests/MiningCut1Tests.cs index c3700bd81..aa00d690e 100644 --- a/tests/Aetheria.Shared.Tests/MiningCut1Tests.cs +++ b/tests/Aetheria.Shared.Tests/MiningCut1Tests.cs @@ -27,7 +27,7 @@ public sealed class MiningCut1Tests : IDisposable private static GameplaySettings GameSettings() => new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp() }; diff --git a/tests/Aetheria.Shared.Tests/MiningCut2Tests.cs b/tests/Aetheria.Shared.Tests/MiningCut2Tests.cs index c05fc1f32..b484eed9f 100644 --- a/tests/Aetheria.Shared.Tests/MiningCut2Tests.cs +++ b/tests/Aetheria.Shared.Tests/MiningCut2Tests.cs @@ -31,7 +31,7 @@ public sealed class MiningCut2Tests : IDisposable private static GameplaySettings GameSettings() => new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp() }; diff --git a/tests/Aetheria.Shared.Tests/MiningCut3Tests.cs b/tests/Aetheria.Shared.Tests/MiningCut3Tests.cs index e77d6c89b..e0eefce59 100644 --- a/tests/Aetheria.Shared.Tests/MiningCut3Tests.cs +++ b/tests/Aetheria.Shared.Tests/MiningCut3Tests.cs @@ -37,7 +37,7 @@ public sealed partial class MiningCut3Tests : IDisposable private static GameplaySettings GameSettings() => new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp(), // Settings.asset's own values for the three detection tunables. VisibilityDecay = .5f, diff --git a/tests/Aetheria.Shared.Tests/PaintModeTests.cs b/tests/Aetheria.Shared.Tests/PaintModeTests.cs index 44af2dae0..02fcf71e1 100644 --- a/tests/Aetheria.Shared.Tests/PaintModeTests.cs +++ b/tests/Aetheria.Shared.Tests/PaintModeTests.cs @@ -63,7 +63,7 @@ public sealed class PaintModeTests : IDisposable _items = new ItemManager(_openCache, ledger, new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp(), TargetDetectionInfoThreshold = .1f, TargetGearInfoThreshold = .8f, diff --git a/tests/Aetheria.Shared.Tests/PickupTests.cs b/tests/Aetheria.Shared.Tests/PickupTests.cs index af979eea5..316c8b7b8 100644 --- a/tests/Aetheria.Shared.Tests/PickupTests.cs +++ b/tests/Aetheria.Shared.Tests/PickupTests.cs @@ -71,7 +71,7 @@ public sealed class PickupTests : IDisposable var settings = new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp(), TargetDetectionInfoThreshold = .1f, TargetGearInfoThreshold = .8f, FiringArc = 170, CommitHorizon = .5f, SchematicCellSize = 1f, diff --git a/tests/Aetheria.Shared.Tests/PopulatedRadiusTests.cs b/tests/Aetheria.Shared.Tests/PopulatedRadiusTests.cs index 20d6793a0..a106b217e 100644 --- a/tests/Aetheria.Shared.Tests/PopulatedRadiusTests.cs +++ b/tests/Aetheria.Shared.Tests/PopulatedRadiusTests.cs @@ -64,7 +64,7 @@ public sealed class PopulatedRadiusTests : IDisposable var items = new ItemManager(cache, new ProvenanceLedger(), new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp() }, _ => { }); diff --git a/tests/Aetheria.Shared.Tests/PotentialOwnerTests.cs b/tests/Aetheria.Shared.Tests/PotentialOwnerTests.cs index 6805bc82e..94100844a 100644 --- a/tests/Aetheria.Shared.Tests/PotentialOwnerTests.cs +++ b/tests/Aetheria.Shared.Tests/PotentialOwnerTests.cs @@ -28,7 +28,7 @@ public sealed class PotentialOwnerTests : IDisposable var settings = new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp() }; _items = new ItemManager(_cache, new ProvenanceLedger(), settings, _ => { }); diff --git a/tests/Aetheria.Shared.Tests/PowerBusTests.cs b/tests/Aetheria.Shared.Tests/PowerBusTests.cs index 2ab76f599..f4277b6fd 100644 --- a/tests/Aetheria.Shared.Tests/PowerBusTests.cs +++ b/tests/Aetheria.Shared.Tests/PowerBusTests.cs @@ -27,7 +27,7 @@ public sealed class PowerBusTests : IDisposable private static GameplaySettings Settings() => new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp() }; diff --git a/tests/Aetheria.Shared.Tests/PowerCurveTests.cs b/tests/Aetheria.Shared.Tests/PowerCurveTests.cs index 4a747dcaf..38db0eec6 100644 --- a/tests/Aetheria.Shared.Tests/PowerCurveTests.cs +++ b/tests/Aetheria.Shared.Tests/PowerCurveTests.cs @@ -36,7 +36,7 @@ public sealed class PowerCurveTests : IDisposable private static GameplaySettings Settings() => new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp() }; diff --git a/tests/Aetheria.Shared.Tests/PowerTierTests.cs b/tests/Aetheria.Shared.Tests/PowerTierTests.cs index ecdbd4b2d..fc947ffb1 100644 --- a/tests/Aetheria.Shared.Tests/PowerTierTests.cs +++ b/tests/Aetheria.Shared.Tests/PowerTierTests.cs @@ -27,7 +27,7 @@ public sealed class PowerTierTests : IDisposable private static GameplaySettings Settings() => new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp() }; diff --git a/tests/Aetheria.Shared.Tests/RoleAuthoringTests.cs b/tests/Aetheria.Shared.Tests/RoleAuthoringTests.cs index 0a17e2732..091e74c3b 100644 --- a/tests/Aetheria.Shared.Tests/RoleAuthoringTests.cs +++ b/tests/Aetheria.Shared.Tests/RoleAuthoringTests.cs @@ -20,7 +20,7 @@ public sealed class RoleAuthoringTests : IDisposable private GameplaySettings Settings() => new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp() }; @@ -84,7 +84,7 @@ public sealed class RoleAuthoringTests : IDisposable public void TwoProductsOfOneDesignWithDifferentRoleMeansResolveDifferentValues() { using var cache = AetheriaStores.Open(Catalog, catalogWritable: true); - var makerRef = cache.Upsert(new Faction { Name = "Maker", ShortName = "MKR" }); + var makerRef = cache.Upsert(new Faction { Name = "Maker", ShortName = "MKR", AssemblyMean = 1f, AssemblyDeviation = 0 }); var lensGear = cache.Upsert(new GearData { Name = "Lensed", Hardpoint = HardpointType.Sensors, Shape = new Shape(), Price = 10, diff --git a/tests/Aetheria.Shared.Tests/RunSaveTests.cs b/tests/Aetheria.Shared.Tests/RunSaveTests.cs index d4196b0cb..3bd075724 100644 --- a/tests/Aetheria.Shared.Tests/RunSaveTests.cs +++ b/tests/Aetheria.Shared.Tests/RunSaveTests.cs @@ -693,7 +693,7 @@ public sealed class RunSaveTests : IDisposable internal static GameplaySettings TestSettings() => new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp() }; diff --git a/tests/Aetheria.Shared.Tests/ShieldReserveTests.cs b/tests/Aetheria.Shared.Tests/ShieldReserveTests.cs index d84519034..3bd741e57 100644 --- a/tests/Aetheria.Shared.Tests/ShieldReserveTests.cs +++ b/tests/Aetheria.Shared.Tests/ShieldReserveTests.cs @@ -32,7 +32,7 @@ public sealed class ShieldReserveTests : IDisposable private static GameplaySettings Settings() => new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp() }; diff --git a/tests/Aetheria.Shared.Tests/SignatureTests.cs b/tests/Aetheria.Shared.Tests/SignatureTests.cs index f1289f58a..8468ac8dd 100644 --- a/tests/Aetheria.Shared.Tests/SignatureTests.cs +++ b/tests/Aetheria.Shared.Tests/SignatureTests.cs @@ -45,7 +45,7 @@ public sealed class SignatureTests : IDisposable private GameplaySettings Settings(float visibilityDecay) => new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp(), TargetDetectionInfoThreshold = .1f, TargetGearInfoThreshold = .8f, diff --git a/tests/Aetheria.Shared.Tests/StatResolverTests.cs b/tests/Aetheria.Shared.Tests/StatResolverTests.cs index aefb239c1..4469eb333 100644 --- a/tests/Aetheria.Shared.Tests/StatResolverTests.cs +++ b/tests/Aetheria.Shared.Tests/StatResolverTests.cs @@ -26,7 +26,7 @@ public sealed class StatResolverTests : IDisposable private static GameplaySettings Settings() => new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp() }; diff --git a/tests/Aetheria.Shared.Tests/TargetingSystemTests.cs b/tests/Aetheria.Shared.Tests/TargetingSystemTests.cs index 15fa14568..cd43cd789 100644 --- a/tests/Aetheria.Shared.Tests/TargetingSystemTests.cs +++ b/tests/Aetheria.Shared.Tests/TargetingSystemTests.cs @@ -34,7 +34,7 @@ public sealed class TargetingSystemTests : IDisposable private static GameplaySettings TestSettings() => new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp(), TargetGearInfoThreshold = .9f, UnaidedAccuracy = .1f, diff --git a/tests/Aetheria.Shared.Tests/ThrottleLockTests.cs b/tests/Aetheria.Shared.Tests/ThrottleLockTests.cs index 8511e371a..ca0f76a97 100644 --- a/tests/Aetheria.Shared.Tests/ThrottleLockTests.cs +++ b/tests/Aetheria.Shared.Tests/ThrottleLockTests.cs @@ -24,7 +24,7 @@ public sealed class ThrottleLockTests : IDisposable private static GameplaySettings Settings() => new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp(), TorqueMultiplier = 1f }; diff --git a/tests/Aetheria.Shared.Tests/VapourCloudTests.cs b/tests/Aetheria.Shared.Tests/VapourCloudTests.cs index 4b55ee97e..e4d57a1cf 100644 --- a/tests/Aetheria.Shared.Tests/VapourCloudTests.cs +++ b/tests/Aetheria.Shared.Tests/VapourCloudTests.cs @@ -61,7 +61,7 @@ public sealed class VapourCloudTests : IDisposable var settings = new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp(), TargetDetectionInfoThreshold = Threshold, TargetGearInfoThreshold = .8f, TargetInfoDecay = .5f, VisibilityDecay = 0f, diff --git a/tests/Aetheria.Shared.Tests/ZonePlacedAtBuildTests.cs b/tests/Aetheria.Shared.Tests/ZonePlacedAtBuildTests.cs index f02992ff5..dada889f0 100644 --- a/tests/Aetheria.Shared.Tests/ZonePlacedAtBuildTests.cs +++ b/tests/Aetheria.Shared.Tests/ZonePlacedAtBuildTests.cs @@ -32,7 +32,7 @@ public sealed class ZonePlacedAtBuildTests : IDisposable private static GameplaySettings GameSettings() => new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp() }; diff --git a/tests/Aetheria.Shared.Tests/ZoneWorlds.cs b/tests/Aetheria.Shared.Tests/ZoneWorlds.cs index d1eec2091..f2dd4ba72 100644 --- a/tests/Aetheria.Shared.Tests/ZoneWorlds.cs +++ b/tests/Aetheria.Shared.Tests/ZoneWorlds.cs @@ -27,7 +27,7 @@ internal sealed class ZoneWorlds : IDisposable private static GameplaySettings GameSettings() => new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp() }; diff --git a/tools/AetherDb/AssemblyFromMakerCommand.cs b/tools/AetherDb/AssemblyFromMakerCommand.cs new file mode 100644 index 000000000..d1f354bde --- /dev/null +++ b/tools/AetherDb/AssemblyFromMakerCommand.cs @@ -0,0 +1,70 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using GameCult.Caching; + +// assembly-from-maker [apply] (aetheria-release, cut assembly-from-maker; rulings quality-is-assembly-over-supply-chain, +// quality-lean-assembly-hard-ceiling): derives each maker's final-assembly distribution from the products it sells. A faction +// that manufactures at least one product with roles gets AssemblyMean = the mean of those products' role means and +// AssemblyDeviation = the mean of their standard deviations, rounded to 2 dp; every other faction gets the field defaults. +// The derivation reads the products, so it replays last, after every command that adds products or factions. A faction that +// already holds the derived values is not rewritten, so a rerun writes nothing. Dry run unless apply. +public static class AssemblyFromMakerCommand +{ + // The distribution a maker's roled products imply: the mean over every role of every product, so a product with more + // roles weighs more. Null when there is no role to average. + public static (float Mean, float Deviation)? Derive(IEnumerable products) + { + var roles = products.SelectMany(p => p.Roles ?? new List()).ToArray(); + if (roles.Length == 0) return null; + return ((float) Math.Round(roles.Average(r => r.Mean), 2), (float) Math.Round(roles.Average(r => r.StandardDeviation), 2)); + } + + public static int Run(CultCache cache, bool apply, TextWriter output) + { + var defaults = new Faction(); + var byMaker = cache.GetAll() + .GroupBy(p => p.Manufacturer.Key) + .Select(g => (Maker: g.Key, Derived: Derive(g))) + .Where(m => m.Derived != null) + .ToDictionary(m => m.Maker, m => m.Derived.Value); + + var changed = new List(); + foreach (var faction in cache.GetAll().OrderBy(f => f.Name, StringComparer.Ordinal)) + { + var (mean, deviation) = byMaker.TryGetValue(cache.RefOf(faction).Key, out var derived) + ? derived + : (defaults.AssemblyMean, defaults.AssemblyDeviation); + if (faction.AssemblyMean == mean && faction.AssemblyDeviation == deviation) continue; + output.WriteLine($"{faction.Name}: assembly {faction.AssemblyMean:0.##}±{faction.AssemblyDeviation:0.##} -> {mean:0.##}±{deviation:0.##}"); + faction.AssemblyMean = mean; + faction.AssemblyDeviation = deviation; + changed.Add(faction); + } + + if (changed.Count == 0) + { + output.WriteLine("No changes."); + return 0; + } + + if (!apply) + { + output.WriteLine($"\nDry run. Pass \"apply\" to write {changed.Count} factions."); + return 0; + } + + foreach (var faction in changed) CultRecordRefs.Validate(faction); + cache.Commit(batch => + { + foreach (var faction in changed) batch.Upsert(typeof(Faction), faction, cache.RefOf(faction).Key); + }); + output.WriteLine($"\nWrote {changed.Count} factions in Aetheria.cc"); + return 0; + } +} diff --git a/tools/AetherDb/Program.cs b/tools/AetherDb/Program.cs index 9d4fe5251..79a6d68fa 100644 --- a/tools/AetherDb/Program.cs +++ b/tools/AetherDb/Program.cs @@ -57,9 +57,10 @@ public static class Program case "inspection-scanner": return InspectionScannerCatalog(args.Contains("apply")); case "product-lines": return ProductLinesCommand.Run(args.Skip(1).ToArray()); case "minor-power-factions": return MinorPowerFactionsCommand.Run(args.Skip(1).ToArray()); + case "assembly-from-maker": return AssemblyFromMakerCommand.Run(AetherDb.Open(catalogWritable: args.Contains("apply")).Cache, args.Contains("apply"), Console.Out); case "doctrine-catalog": return DoctrineCatalog.Run(AetherDb.Open(catalogWritable: args.Contains("apply")).Cache, args.Contains("apply"), Console.Out); default: - Console.WriteLine("commands: census, factions, station-fit, hardpoint-fit, loadout [seed], save, settings, settings-dump, dangling [clear ]... [apply], shield-migrate [apply], brownout-migrate [apply], roles-migrate [apply], firing-arc-migrate [apply], range-falloff [apply] [--effective ] [--end ], targeting-catalog [apply], targeting-catalog-6c [apply], targeting-catalog-6d [apply], ship-authoring create|inspect|validate|compose, field-kinds [apply], mine-launcher [apply], smoke-hull [apply], smoke-rounds [apply], roles-backfill [apply], pd-gear [apply], consumables-first-set [apply], launch-suppressor [apply], pirates-faction [apply], verse-grammar [apply], generic-designs [apply], sensor-stat-set [apply], inspection-scanner [apply], minor-power-factions [apply], product-lines weapons|minor-powers|gear [apply], doctrine-catalog [apply]"); + Console.WriteLine("commands: census, factions, station-fit, hardpoint-fit, loadout [seed], save, settings, settings-dump, dangling [clear ]... [apply], shield-migrate [apply], brownout-migrate [apply], roles-migrate [apply], firing-arc-migrate [apply], range-falloff [apply] [--effective ] [--end ], targeting-catalog [apply], targeting-catalog-6c [apply], targeting-catalog-6d [apply], ship-authoring create|inspect|validate|compose, field-kinds [apply], mine-launcher [apply], smoke-hull [apply], smoke-rounds [apply], roles-backfill [apply], pd-gear [apply], consumables-first-set [apply], launch-suppressor [apply], pirates-faction [apply], verse-grammar [apply], generic-designs [apply], sensor-stat-set [apply], inspection-scanner [apply], minor-power-factions [apply], product-lines weapons|minor-powers|gear [apply], doctrine-catalog [apply], assembly-from-maker [apply]"); return 1; } } @@ -557,7 +558,7 @@ public static class Program Console.WriteLine($" zone radius curve {zones.ZoneRadius?.Minimum}-{zones.ZoneRadius?.Maximum} exponent {zones.ZoneRadius?.Exponent}"); Console.WriteLine($" sub zone count {zones.SubZoneCount?.Minimum}-{zones.SubZoneCount?.Maximum} exponent {zones.SubZoneCount?.Exponent}"); Console.WriteLine($"gameplay: weapon groups {gameplay.WeaponGroupCount}, shutdown performance {gameplay.DefaultEntitySettings?.ShutdownPerformance}"); - Console.WriteLine($" tiers: {string.Join(", ", (gameplay.Tiers ?? new RarityTier[0]).Select(t => $"{t.Name} q{t.Quality} r{t.Rarity}"))}"); + Console.WriteLine($" tiers: {string.Join(", ", (gameplay.Tiers ?? new RarityTier[0]).Select(t => $"{t.Name} q{t.Quality}"))}"); Console.WriteLine($" price modifier {gameplay.QualityPriceModifier?.Minimum}-{gameplay.QualityPriceModifier?.Maximum} exponent {gameplay.QualityPriceModifier?.Exponent}"); // Assert counts, not non-null: an empty array reads as populated and would make every number a fixture @@ -792,7 +793,7 @@ public static class Program var settings = new GameplaySettings { DefaultEntitySettings = new EntitySettings(), - Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } }, + Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Color = new float3(1, 1, 1) } }, QualityPriceModifier = new ExponentialLerp() }; From 57952dbfb715390e99964b591e2af5bc5823ef30 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 17 Oct 2026 18:55:53 +0200 Subject: [PATCH 02/25] Settings.asset: drop the five Rarity values; RarityTier is display bands only The type lost its Rarity field with the roll; Unity would otherwise keep serializing orphan values. Co-Authored-By: Claude Opus 5.5 --- Assets/Resources/Settings.asset | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Assets/Resources/Settings.asset b/Assets/Resources/Settings.asset index f92142d6b..f5494b5f8 100644 --- a/Assets/Resources/Settings.asset +++ b/Assets/Resources/Settings.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ab2cdc0732716dcbfa4875e90e598b0dff3f0c8d4f871cc180649a3db2e4cf0c -size 12562 +oid sha256:60d228a373b7d4d2339f08fce971c4c597c9cbc6bbb47de66ec55b456cd0b247 +size 12471 From 30597b0e45630f30471f9d634ae5f7108ab539ad Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 17 Oct 2026 19:03:12 +0200 Subject: [PATCH 03/25] Assembly is an AssemblyDistribution: Faction key 19, optional per product, stated-quality mint Replaces h1's AssemblyMean/AssemblyDeviation floats with one Faction.Assembly (key 19, null = not authored) and adds FactionProductData.Assembly (key 6, null = its maker's). CreateLot(product) draws from product.Assembly, else the maker's, else AssemblyDistribution defaults; CreateLot(product, quality) mints the lot and every fill at a stated quality and draws nothing. assembly-from-maker now seeds part mean + .1 and writes only a null Assembly. The shipped-catalog test is red until the catalog commit. Co-Authored-By: Claude Opus 5.5 --- Assets/Scripts/ServerShared/Corporations.cs | 14 ++--- Assets/Scripts/ServerShared/FactionProduct.cs | 17 ++++++ Assets/Scripts/ServerShared/ItemManager.cs | 19 +++--- .../AssemblyFromMakerCatalogTests.cs | 29 ++++----- .../AssemblyFromMakerCommandTests.cs | 59 ++++++++++++++----- .../AssemblyFromMakerTests.cs | 51 ++++++++++++---- .../RoleAuthoringTests.cs | 2 +- tools/AetherDb/AssemblyFromMakerCommand.cs | 47 ++++++++------- 8 files changed, 160 insertions(+), 78 deletions(-) diff --git a/Assets/Scripts/ServerShared/Corporations.cs b/Assets/Scripts/ServerShared/Corporations.cs index a17263933..2e18d7199 100644 --- a/Assets/Scripts/ServerShared/Corporations.cs +++ b/Assets/Scripts/ServerShared/Corporations.cs @@ -64,14 +64,12 @@ public class Faction [Inspectable, JsonProperty("doctrine"), Key(17)] public FactionDoctrine Doctrine; - // The maker's final-assembly technology (mean) and quality control (deviation): the distribution every lot of - // theirs draws its own quality from, and the hard ceiling on every one of its roles (quality-lean-assembly-hard-ceiling). - // Key 18 is reserved for Livery and 16 for Relations. - [Inspectable, JsonProperty("assemblyMean"), Key(19)] - public float AssemblyMean = .5f; - - [Inspectable, JsonProperty("assemblyDeviation"), Key(20)] - public float AssemblyDeviation = .15f; + // The maker's final assembly: the distribution every lot of theirs draws its own quality from, and the hard ceiling on each + // of its roles (quality-lean-assembly-hard-ceiling). Null is not authored: a lot of theirs assembles at AssemblyDistribution's + // defaults. assembly-from-maker derives it once at the part mean plus a tolerance margin (quality-min-tolerance-binned-assembly); + // tune it in Studio after that. Key 16 is reserved for Relations and 18 for Livery. + [Inspectable, JsonProperty("assembly"), Key(19)] + public AssemblyDistribution Assembly; } [CultDocument("aetheria.namefile", "1"), Inspectable, MessagePackObject] diff --git a/Assets/Scripts/ServerShared/FactionProduct.cs b/Assets/Scripts/ServerShared/FactionProduct.cs index a0770304a..cdaed4f28 100644 --- a/Assets/Scripts/ServerShared/FactionProduct.cs +++ b/Assets/Scripts/ServerShared/FactionProduct.cs @@ -28,6 +28,11 @@ public class FactionProductData [Inspectable, JsonProperty("roles"), Key(5)] public List Roles = new List(); + + // This line's own final test (maker-design-tiers-allowed): a binned or premium line is a better assembly as well as better + // parts. Null assembles as its maker does. + [Inspectable, JsonProperty("assembly"), Key(6)] + public AssemblyDistribution Assembly; } // How good this product's part is in one of its design's roles: a pseudo-gaussian distribution whose mean is @@ -46,3 +51,15 @@ public class ProductRole [Inspectable, JsonProperty("standardDeviation"), Key(2)] public float StandardDeviation = .15f; } + +// How well a maker puts the thing together: the technology and quality control of final assembly. A lot's own quality is drawn +// from it, and it is the ceiling on every role the lot fills. Defaults are a middling maker. +[MessagePackObject, JsonObject(MemberSerialization.OptIn)] +public class AssemblyDistribution +{ + [Inspectable, JsonProperty("mean"), Key(0)] + public float Mean = .5f; + + [Inspectable, JsonProperty("standardDeviation"), Key(1)] + public float StandardDeviation = .15f; +} diff --git a/Assets/Scripts/ServerShared/ItemManager.cs b/Assets/Scripts/ServerShared/ItemManager.cs index 2904c35f1..73e2c9592 100644 --- a/Assets/Scripts/ServerShared/ItemManager.cs +++ b/Assets/Scripts/ServerShared/ItemManager.cs @@ -118,19 +118,24 @@ public class ItemManager } // Builds one of a manufacturer's branded products (quality-is-assembly-over-supply-chain): the unit's own quality is its - // final assembly, drawn from the maker's assembly distribution, and each of the design's roles is filled with a part whose - // quality is drawn from the product's distribution for it. A maker the catalog cannot resolve assembles at a new Faction's - // defaults. - public int CreateLot(FactionProductData product) + // final assembly, drawn from the product's assembly distribution, else its maker's, else AssemblyDistribution's defaults, + // and each of the design's roles is filled with a part whose quality is drawn from the product's distribution for it. + public int CreateLot(FactionProductData product) => Mint(product, null); + + // The same lot at a stated quality: the assembly and every role fill are that quality and nothing is drawn, so a staged + // fit does not ride the item stream (ScenarioStage.Fit). + public int CreateLot(FactionProductData product, float quality) => Mint(product, clamp(quality, .01f, 1)); + + private int Mint(FactionProductData product, float? stated) { var design = ItemData.Get(product.Design); - var maker = ItemData.Get(product.Manufacturer) ?? new Faction(); + var assembly = product.Assembly ?? ItemData.Get(product.Manufacturer)?.Assembly ?? new AssemblyDistribution(); var lot = new Lot { Design = ItemData.RefOf(design), Origin = new Attributed { Faction = product.Manufacturer }, Product = ItemData.RefOf(product), - Quality = clamp(Random.NextGaussian(maker.AssemblyMean, maker.AssemblyDeviation), .01f, 1), + Quality = stated ?? clamp(Random.NextGaussian(assembly.Mean, assembly.StandardDeviation), .01f, 1), Roles = new List() }; if (design.Roles != null) @@ -140,7 +145,7 @@ public class ItemManager lot.Roles.Add(new RoleFill { Role = role.Name, - Quality = clamp(Random.NextGaussian(build.Mean, build.StandardDeviation), .01f, 1) + Quality = stated ?? clamp(Random.NextGaussian(build.Mean, build.StandardDeviation), .01f, 1) }); } diff --git a/tests/Aetheria.Shared.Tests/AssemblyFromMakerCatalogTests.cs b/tests/Aetheria.Shared.Tests/AssemblyFromMakerCatalogTests.cs index fbd2698e6..52746c225 100644 --- a/tests/Aetheria.Shared.Tests/AssemblyFromMakerCatalogTests.cs +++ b/tests/Aetheria.Shared.Tests/AssemblyFromMakerCatalogTests.cs @@ -4,32 +4,33 @@ using System.Reflection; using MessagePack; using Xunit; -// The shipped catalog carries each maker's derived assembly, and the Faction format pins its wire positions +// The shipped catalog carries each maker's seeded assembly, and the Faction format pins its wire positions // (aetheria-release, cut assembly-from-maker). public sealed class AssemblyFromMakerCatalogTests { + // Every maker of a roled product carries an Assembly the command seeded; no product overrides its maker's. [Fact] - public void ShippedCatalogCarriesDerivation() + public void ShippedCatalogCarriesAssembly() { using var cache = RestoredHullsTests.OpenCatalog(); - var products = cache.GetAll().Where(p => p.Roles.Count > 0).ToArray(); - var makers = products.Select(p => p.Manufacturer.Key).Distinct().ToArray(); - Assert.NotEmpty(makers); + var makers = cache.GetAll().Where(p => p.Roles.Count > 0).Select(p => p.Manufacturer.Key).Distinct().ToArray(); + Assert.Equal(15, makers.Length); foreach (var key in makers) { - var roles = products.Where(p => p.Manufacturer.Key.Equals(key)).SelectMany(p => p.Roles).ToArray(); - var faction = cache.Get(key); - Assert.Equal(Math.Round(roles.Average(r => r.Mean), 2), faction.AssemblyMean, 2); - Assert.Equal(Math.Round(roles.Average(r => r.StandardDeviation), 2), faction.AssemblyDeviation, 2); + var assembly = cache.Get(key).Assembly; + Assert.NotNull(assembly); + Assert.InRange(assembly.Mean, .01f, 1f); } + + Assert.All(cache.GetAll(), p => Assert.Null(p.Assembly)); } - // 16 is reserved for Relations, 17 is Doctrine, 18 is reserved for Livery. + // 16 is reserved for Relations, 17 is Doctrine, 18 is reserved for Livery, 20 for the place-names pass. [Fact] - public void AssemblyFieldsSitAtKeys19And20() + public void AssemblyRidesItsWireKeys() { - int KeyOf(string field) => typeof(Faction).GetField(field).GetCustomAttribute().IntKey.Value; - Assert.Equal(19, KeyOf(nameof(Faction.AssemblyMean))); - Assert.Equal(20, KeyOf(nameof(Faction.AssemblyDeviation))); + int KeyOf(Type type) => type.GetField("Assembly").GetCustomAttribute().IntKey.Value; + Assert.Equal(19, KeyOf(typeof(Faction))); + Assert.Equal(6, KeyOf(typeof(FactionProductData))); } } diff --git a/tests/Aetheria.Shared.Tests/AssemblyFromMakerCommandTests.cs b/tests/Aetheria.Shared.Tests/AssemblyFromMakerCommandTests.cs index f54af3a34..504b25120 100644 --- a/tests/Aetheria.Shared.Tests/AssemblyFromMakerCommandTests.cs +++ b/tests/Aetheria.Shared.Tests/AssemblyFromMakerCommandTests.cs @@ -4,8 +4,8 @@ using System.Linq; using GameCult.Caching; using Xunit; -// assembly-from-maker (aetheria-release, cut assembly-from-maker): each maker's assembly distribution is derived from the -// roles of the products it manufactures. +// assembly-from-maker (aetheria-release, cut assembly-from-maker): each maker's unauthored assembly is seeded from the roles +// of the products it manufactures. public sealed class AssemblyFromMakerCommandTests : IDisposable { private readonly string _root = Path.Combine(Path.GetTempPath(), "aetheria-assembly-cmd-" + Guid.NewGuid().ToString("N")); @@ -19,7 +19,7 @@ public sealed class AssemblyFromMakerCommandTests : IDisposable using var cache = AetheriaStores.Open(Catalog, catalogWritable: true); cache.Upsert(new VerseGrammar { Revision = 1 }); var maker = cache.Upsert(new Faction { Name = "Maker" }); - cache.Upsert(new Faction { Name = "Bystander", AssemblyMean = .9f, AssemblyDeviation = .01f }); + cache.Upsert(new Faction { Name = "Bystander" }); var gear = cache.Upsert(new GearData { Name = "Lamp", Hardpoint = HardpointType.Sensors, Shape = new Shape(), Price = 10 }); var design = new CultRecordRef(gear.Key); // Two products, three roles: the mean is over roles (.2, .4, .9 -> .5), the deviation likewise (.1, .1, .4 -> .2). @@ -45,6 +45,19 @@ public sealed class AssemblyFromMakerCommandTests : IDisposable new ProductRole { Role = "z", Mean = .31f, StandardDeviation = .2f } } }); + // A maker whose parts are near the top: the margin is capped at 1. And one whose assembly was already authored in Studio. + var top = cache.Upsert(new Faction { Name = "Top" }); + cache.Upsert(new FactionProductData + { + Name = "D", Design = design, Manufacturer = top, + Roles = { new ProductRole { Role = "x", Mean = .95f, StandardDeviation = .05f } } + }); + var tuned = cache.Upsert(new Faction { Name = "Tuned", Assembly = new AssemblyDistribution { Mean = .42f, StandardDeviation = .07f } }); + cache.Upsert(new FactionProductData + { + Name = "E", Design = design, Manufacturer = tuned, + Roles = { new ProductRole { Role = "x", Mean = .1f, StandardDeviation = .3f } } + }); cache.FlushAsync().Wait(); } @@ -57,8 +70,31 @@ public sealed class AssemblyFromMakerCommandTests : IDisposable return output.ToString(); } + private Faction Maker(string name) + { + using var cache = AetheriaStores.Open(Catalog); + return cache.GetAll().Single(f => f.Name == name); + } + + // The assembly is the part mean plus the tolerance margin and the deviation the parts' mean; the margin is capped at 1; a + // faction that makes no roled product stays unauthored. [Fact] - public void DryRunWritesNothingApplyIsIdempotent() + public void DerivesPartMeanPlusMargin() + { + Seed(); + Run(apply: true); + Assert.Equal(.6f, Maker("Maker").Assembly.Mean, 3); + Assert.Equal(.2f, Maker("Maker").Assembly.StandardDeviation, 3); + Assert.Equal(.36f, Maker("Fine").Assembly.Mean, 3); + Assert.Equal(.16f, Maker("Fine").Assembly.StandardDeviation, 3); + Assert.Equal(1f, Maker("Top").Assembly.Mean, 3); + Assert.Equal(.05f, Maker("Top").Assembly.StandardDeviation, 3); + Assert.Null(Maker("Bystander").Assembly); + } + + // A value tuned in Studio survives every replay, a dry run writes nothing, and a second apply has nothing to do. + [Fact] + public void AuthoredAssemblyIsKept() { Seed(); var before = File.ReadAllBytes(Catalog); @@ -66,19 +102,10 @@ public sealed class AssemblyFromMakerCommandTests : IDisposable Assert.Equal(before, File.ReadAllBytes(Catalog)); Run(apply: true); + Assert.Equal(.42f, Maker("Tuned").Assembly.Mean, 3); + Assert.Equal(.07f, Maker("Tuned").Assembly.StandardDeviation, 3); using (var cache = AetheriaStores.Open(Catalog)) - { - var maker = cache.GetAll().Single(f => f.Name == "Maker"); - Assert.Equal(.5f, maker.AssemblyMean, 3); - Assert.Equal(.2f, maker.AssemblyDeviation, 3); - var fine = cache.GetAll().Single(f => f.Name == "Fine"); - Assert.Equal(.26f, fine.AssemblyMean, 3); - Assert.Equal(.16f, fine.AssemblyDeviation, 3); - // A faction that manufactures nothing is written the field defaults. - var bystander = cache.GetAll().Single(f => f.Name == "Bystander"); - Assert.Equal(.5f, bystander.AssemblyMean, 3); - Assert.Equal(.15f, bystander.AssemblyDeviation, 3); - } + Assert.All(cache.GetAll(), p => Assert.Null(p.Assembly)); var written = File.ReadAllBytes(Catalog); Assert.Contains("No changes", Run(apply: true)); diff --git a/tests/Aetheria.Shared.Tests/AssemblyFromMakerTests.cs b/tests/Aetheria.Shared.Tests/AssemblyFromMakerTests.cs index 17df5331f..ae997dcb8 100644 --- a/tests/Aetheria.Shared.Tests/AssemblyFromMakerTests.cs +++ b/tests/Aetheria.Shared.Tests/AssemblyFromMakerTests.cs @@ -45,6 +45,8 @@ public sealed class AssemblyFromMakerTests : IDisposable return _cache.GetAll().Single(p => p.Name == name); } + private static AssemblyDistribution A(float mean, float deviation) => new AssemblyDistribution { Mean = mean, StandardDeviation = deviation }; + private float[] Mint(FactionProductData product, int count) => Enumerable.Range(0, count).Select(_ => _items.Lots[_items.CreateLot(product)].Quality).ToArray(); @@ -52,8 +54,8 @@ public sealed class AssemblyFromMakerTests : IDisposable [Fact] public void LotQualityFollowsMaker() { - var low = Product("Low", new Faction { Name = "Low Maker", AssemblyMean = .3f, AssemblyDeviation = .02f }, .5f); - var high = Product("High", new Faction { Name = "High Maker", AssemblyMean = .8f, AssemblyDeviation = .02f }, .5f); + var low = Product("Low", new Faction { Name = "Low Maker", Assembly = A(.3f, .02f) }, .5f); + var high = Product("High", new Faction { Name = "High Maker", Assembly = A(.8f, .02f) }, .5f); var lows = Mint(low, 300); var highs = Mint(high, 300); Assert.InRange(lows.Average(), .27f, .33f); @@ -65,27 +67,54 @@ public sealed class AssemblyFromMakerTests : IDisposable [Fact] public void LotSpreadFollowsMakerDeviation() { - var wide = Mint(Product("Wide", new Faction { Name = "Wide Maker", AssemblyMean = .5f, AssemblyDeviation = .2f }, .5f), 400); - var tight = Mint(Product("Tight", new Faction { Name = "Tight Maker", AssemblyMean = .5f, AssemblyDeviation = .02f }, .5f), 400); + var wide = Mint(Product("Wide", new Faction { Name = "Wide Maker", Assembly = A(.5f, .2f) }, .5f), 400); + var tight = Mint(Product("Tight", new Faction { Name = "Tight Maker", Assembly = A(.5f, .02f) }, .5f), 400); double Spread(float[] lots) => Math.Sqrt(lots.Select(q => Math.Pow(q - lots.Average(), 2)).Average()); Assert.InRange(Spread(wide), .15, .25); Assert.InRange(Spread(tight), .01, .04); } - // A maker the catalog cannot resolve assembles at a new Faction's defaults. + // A maker the catalog cannot resolve, and a maker whose Assembly is not authored, assemble at AssemblyDistribution's defaults. [Fact] - public void UnresolvedMakerAssemblesAtDefaults() + public void UnauthoredAssemblyAssemblesAtDefaults() { - var orphan = Product("Orphan", null, .5f); - var defaults = new Faction(); - Assert.InRange(Mint(orphan, 400).Average(), defaults.AssemblyMean - .03f, defaults.AssemblyMean + .03f); + var defaults = new AssemblyDistribution(); + Assert.InRange(Mint(Product("Orphan", null, .5f), 400).Average(), defaults.Mean - .03f, defaults.Mean + .03f); + Assert.InRange(Mint(Product("Blank", new Faction { Name = "Blank Maker" }, .5f), 400).Average(), defaults.Mean - .03f, defaults.Mean + .03f); + } + + // A line's own final test (maker-design-tiers-allowed): a product carrying an Assembly mints at it, and a sibling product + // of the same maker without one reads the maker's. + [Fact] + public void ProductAssemblyOverridesMaker() + { + var maker = new Faction { Name = "Binner", Assembly = A(.3f, .02f) }; + var plain = Product("Plain", maker, .5f); + var premium = Product("Premium", maker, .5f); + premium.Assembly = A(.85f, .02f); + Assert.InRange(Mint(premium, 300).Average(), .82f, .88f); + Assert.InRange(Mint(plain, 300).Average(), .27f, .33f); + } + + // A stated quality is every lot's and every fill's, clamped, and draws nothing from the item stream. + [Fact] + public void StatedQualityDrawsNothing() + { + var product = Product("Staged", new Faction { Name = "Staged Maker", Assembly = A(.3f, .2f) }, .5f, .2f); + var before = _items.Random; + var lot = _items.Lots[_items.CreateLot(product, .6f)]; + Assert.Equal(.6f, lot.Quality, 3); + Assert.Equal(.6f, lot.Roles.Single().Quality, 3); + Assert.Equal(before.NextFloat(), _items.Random.NextFloat()); + Assert.Equal(1f, _items.Lots[_items.CreateLot(product, 7f)].Quality, 3); + Assert.Equal(.01f, _items.Lots[_items.CreateLot(product, -1f)].Roles.Single().Quality, 3); } // The ceiling at the mint: a part drawn at .9 in an assembly of .4 reads .4; a part at .2 in the same assembly reads .2. [Fact] public void RoleCappedByAssembly() { - var maker = new Faction { Name = "Capped", AssemblyMean = .4f, AssemblyDeviation = 0 }; + var maker = new Faction { Name = "Capped", Assembly = A(.4f, 0) }; var over = _items.Lots[_items.CreateLot(Product("Over", maker, .9f))]; var under = _items.Lots[_items.CreateLot(Product("Under", maker, .2f))]; Assert.Equal(.4f, over.Quality, 3); @@ -110,7 +139,7 @@ public sealed class AssemblyFromMakerTests : IDisposable [Fact] public void QualityTermReadsCeiling() { - var maker = new Faction { Name = "Capped", AssemblyMean = .4f, AssemblyDeviation = 0 }; + var maker = new Faction { Name = "Capped", Assembly = A(.4f, 0) }; var instance = (EquippableItem) _items.CreateInstance(_items.CreateLot(Product("Over", maker, .9f))); var stat = new PerformanceStat { Min = 0, Max = 1, Terms = { new StatTerm { Source = StatSource.Quality, Exponent = 1, Role = "lens" } } }; Assert.Equal(.4f, _items.Evaluate(stat, instance), 3); diff --git a/tests/Aetheria.Shared.Tests/RoleAuthoringTests.cs b/tests/Aetheria.Shared.Tests/RoleAuthoringTests.cs index 091e74c3b..2a61cbf86 100644 --- a/tests/Aetheria.Shared.Tests/RoleAuthoringTests.cs +++ b/tests/Aetheria.Shared.Tests/RoleAuthoringTests.cs @@ -84,7 +84,7 @@ public sealed class RoleAuthoringTests : IDisposable public void TwoProductsOfOneDesignWithDifferentRoleMeansResolveDifferentValues() { using var cache = AetheriaStores.Open(Catalog, catalogWritable: true); - var makerRef = cache.Upsert(new Faction { Name = "Maker", ShortName = "MKR", AssemblyMean = 1f, AssemblyDeviation = 0 }); + var makerRef = cache.Upsert(new Faction { Name = "Maker", ShortName = "MKR", Assembly = new AssemblyDistribution { Mean = 1f, StandardDeviation = 0 } }); var lensGear = cache.Upsert(new GearData { Name = "Lensed", Hardpoint = HardpointType.Sensors, Shape = new Shape(), Price = 10, diff --git a/tools/AetherDb/AssemblyFromMakerCommand.cs b/tools/AetherDb/AssemblyFromMakerCommand.cs index d1f354bde..d1badb62f 100644 --- a/tools/AetherDb/AssemblyFromMakerCommand.cs +++ b/tools/AetherDb/AssemblyFromMakerCommand.cs @@ -8,42 +8,45 @@ using System.IO; using System.Linq; using GameCult.Caching; -// assembly-from-maker [apply] (aetheria-release, cut assembly-from-maker; rulings quality-is-assembly-over-supply-chain, -// quality-lean-assembly-hard-ceiling): derives each maker's final-assembly distribution from the products it sells. A faction -// that manufactures at least one product with roles gets AssemblyMean = the mean of those products' role means and -// AssemblyDeviation = the mean of their standard deviations, rounded to 2 dp; every other faction gets the field defaults. -// The derivation reads the products, so it replays last, after every command that adds products or factions. A faction that -// already holds the derived values is not rewritten, so a rerun writes nothing. Dry run unless apply. +// assembly-from-maker [apply] (aetheria-release, cut assembly-from-maker; rulings quality-lean-assembly-hard-ceiling, +// quality-min-tolerance-binned-assembly): seeds each maker's final assembly from the products it sells. A faction with no +// Assembly that manufactures at least one product with roles gets Mean = the mean of those products' role means plus Margin +// (a maker assembles a little above its parts, capped at 1) and StandardDeviation = the mean of their standard deviations, +// both rounded to 2 dp. It writes only an Assembly that is null, so a value tuned in Studio survives every replay, and it +// never writes a product's Assembly. The derivation reads the products, so it replays last, after every command that adds +// products or factions. Dry run unless apply. public static class AssemblyFromMakerCommand { - // The distribution a maker's roled products imply: the mean over every role of every product, so a product with more - // roles weighs more. Null when there is no role to average. - public static (float Mean, float Deviation)? Derive(IEnumerable products) + // How far above its part mean a maker's final assembly sits: the tolerance margin of the ceiling. + public const float Margin = .1f; + + // The assembly a maker's roled products imply: the mean over every role of every product, so a product with more roles + // weighs more. Null when there is no role to average. + public static AssemblyDistribution Derive(IEnumerable products) { var roles = products.SelectMany(p => p.Roles ?? new List()).ToArray(); if (roles.Length == 0) return null; - return ((float) Math.Round(roles.Average(r => r.Mean), 2), (float) Math.Round(roles.Average(r => r.StandardDeviation), 2)); + return new AssemblyDistribution + { + Mean = (float) Math.Round(Math.Min(1, roles.Average(r => r.Mean) + Margin), 2), + StandardDeviation = (float) Math.Round(roles.Average(r => r.StandardDeviation), 2) + }; } public static int Run(CultCache cache, bool apply, TextWriter output) { - var defaults = new Faction(); var byMaker = cache.GetAll() .GroupBy(p => p.Manufacturer.Key) .Select(g => (Maker: g.Key, Derived: Derive(g))) .Where(m => m.Derived != null) - .ToDictionary(m => m.Maker, m => m.Derived.Value); + .ToDictionary(m => m.Maker, m => m.Derived); var changed = new List(); foreach (var faction in cache.GetAll().OrderBy(f => f.Name, StringComparer.Ordinal)) { - var (mean, deviation) = byMaker.TryGetValue(cache.RefOf(faction).Key, out var derived) - ? derived - : (defaults.AssemblyMean, defaults.AssemblyDeviation); - if (faction.AssemblyMean == mean && faction.AssemblyDeviation == deviation) continue; - output.WriteLine($"{faction.Name}: assembly {faction.AssemblyMean:0.##}±{faction.AssemblyDeviation:0.##} -> {mean:0.##}±{deviation:0.##}"); - faction.AssemblyMean = mean; - faction.AssemblyDeviation = deviation; + if (faction.Assembly != null || !byMaker.TryGetValue(cache.RefOf(faction).Key, out var derived)) continue; + output.WriteLine($"{faction.Name}: assembly -> {derived.Mean:0.##}±{derived.StandardDeviation:0.##}"); + faction.Assembly = derived; changed.Add(faction); } @@ -55,7 +58,8 @@ public static class AssemblyFromMakerCommand if (!apply) { - output.WriteLine($"\nDry run. Pass \"apply\" to write {changed.Count} factions."); + output.WriteLine($" +Dry run. Pass \"apply\" to write {changed.Count} factions."); return 0; } @@ -64,7 +68,8 @@ public static class AssemblyFromMakerCommand { foreach (var faction in changed) batch.Upsert(typeof(Faction), faction, cache.RefOf(faction).Key); }); - output.WriteLine($"\nWrote {changed.Count} factions in Aetheria.cc"); + output.WriteLine($" +Wrote {changed.Count} factions in Aetheria.cc"); return 0; } } From 7b2a6d064df59c1c8c20da2580a2f2d7db3fd16f Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 17 Oct 2026 19:03:20 +0200 Subject: [PATCH 04/25] Staged fits: a scenario states the quality of a fit its checks rest on ScenarioStage.Fit(hull, quality, slots) mints every lot of the fit at the stated quality through Loadouts.Materialize/Resolve, so Crossing's fighter and EvasionTermTests' hand-fitted Longinus and Djinni do not ride the item stream. No seed changes. Co-Authored-By: Claude Opus 5.5 --- Assets/Scripts/ServerShared/Loadout.cs | 17 ++++++----- Assets/Scripts/ServerShared/ScenarioStage.cs | 22 +++++++++++--- .../ServerShared/Scenarios/Crossing.cs | 4 ++- .../Aetheria.Shared.Tests/EvasionTermTests.cs | 9 ++++-- tests/Aetheria.Shared.Tests/ScenarioTests.cs | 29 +++++++++++++++++++ 5 files changed, 65 insertions(+), 16 deletions(-) diff --git a/Assets/Scripts/ServerShared/Loadout.cs b/Assets/Scripts/ServerShared/Loadout.cs index 7effbfe76..bf8a2ac47 100644 --- a/Assets/Scripts/ServerShared/Loadout.cs +++ b/Assets/Scripts/ServerShared/Loadout.cs @@ -108,18 +108,19 @@ public static class Loadouts // picks the entity: a ship hull builds a Ship, a turret hull an OrbitalEntity with no orbit, which stays where it is // put; a station hull is refused. The entity always gets exactly WeaponGroupCount groups; a loadout with fewer is // padded with empty groups. A failed materialization leaves any minted lots in the live ledger; they are not roots, - // so the next commit drops them. + // so the next commit drops them. A stated quality mints every lot of the fit at it, drawing nothing (a scenario states + // one for a fit its checks rest on). public static Entity Materialize(ItemManager itemManager, Zone liveZone, Loadout loadout, - Func choose, List failures) + Func choose, List failures, float? quality = null) { var cache = itemManager.ItemData; var reported = failures.Count; - var hullBuild = Resolve(itemManager, loadout.Hull, loadout.HullProduct, choose, "hull", failures); + var hullBuild = Resolve(itemManager, loadout.Hull, loadout.HullProduct, choose, "hull", failures, quality); var hullData = cache.Get(loadout.Hull); if (hullData is { HullType: HullType.Station }) failures.Add($"hull: {hullData.Name} is a station hull; a preset builds a ship or a turret"); - var slotBuilds = loadout.Slots.Select(slot => Resolve(itemManager, slot.Design, slot.Product, choose, Cell(slot), failures)).ToArray(); + var slotBuilds = loadout.Slots.Select(slot => Resolve(itemManager, slot.Design, slot.Product, choose, Cell(slot), failures, quality)).ToArray(); var groups = loadout.WeaponGroups ?? new int[0][]; var groupCount = itemManager.GameplaySettings.WeaponGroupCount; if (groups.Length > groupCount) failures.Add($"weapon groups: {groups.Length} groups, at most {groupCount}"); @@ -168,11 +169,11 @@ public static class Loadouts // How one design is built, or null with the failure listed; nothing is minted until the returned builder runs. A // pinned product is built as named, whatever choose says; it must be a product of the design. A design with no // product at all is outside the economy (docs/scenarios-cut.md, Q3: generation, stock and sale all go through - // products) and is built unbranded, with no maker, at UnbrandedQuality. Otherwise choose names the product, and + // products) and is built unbranded, with no maker, at UnbrandedQuality (a stated quality replaces it). Otherwise choose names the product, and // null (nothing available) or a product of another design is a failure. public static Func Resolve(ItemManager itemManager, CultRecordRef design, CultRecordRef product, Func choose, string where, - List failures) where T : CraftedItemData + List failures, float? quality = null) where T : CraftedItemData { var cache = itemManager.ItemData; var data = cache.Get(design); @@ -195,7 +196,7 @@ public static class Loadouts else { if (!cache.GetAll().Any(p => p.Design.Key.Equals(design.Key))) - return () => itemManager.CreateInstance(itemManager.CreateLot(data, default, UnbrandedQuality)); + return () => itemManager.CreateInstance(itemManager.CreateLot(data, default, quality ?? UnbrandedQuality)); made = choose(data); if (made == null) { @@ -209,7 +210,7 @@ public static class Loadouts failures.Add($"{where}: product {made.Name} is not a product of {data.Name}"); return null; } - return () => itemManager.CreateInstance(made); + return () => itemManager.CreateInstance(quality is { } q ? itemManager.CreateLot(made, q) : itemManager.CreateLot(made)); } private static string Cell(LoadoutSlot slot) => $"slot {slot.Position.x},{slot.Position.y}"; diff --git a/Assets/Scripts/ServerShared/ScenarioStage.cs b/Assets/Scripts/ServerShared/ScenarioStage.cs index b32a4993c..77e5bf1e3 100644 --- a/Assets/Scripts/ServerShared/ScenarioStage.cs +++ b/Assets/Scripts/ServerShared/ScenarioStage.cs @@ -52,7 +52,15 @@ public sealed class ScenarioStage // A hull fitted slot by slot: each slot a design or a product, the hull cell it goes in, and its rotation. A name is // a design (open: the stage chooses its product) or a product (pinned: that brand). - public ScenarioFit Fit(string hull, params (string design, int2 cell, ItemRotation rotation)[] slots) + public ScenarioFit Fit(string hull, params (string design, int2 cell, ItemRotation rotation)[] slots) => + FitAt(hull, null, slots); + + // The same fit with every lot it mints (hull, slots, unbranded) at the stated quality, drawing nothing. A fit a scenario's + // checks rest on states its quality, so the check does not ride the item stream. + public ScenarioFit Fit(string hull, float quality, params (string design, int2 cell, ItemRotation rotation)[] slots) => + FitAt(hull, quality, slots); + + private ScenarioFit FitAt(string hull, float? quality, (string design, int2 cell, ItemRotation rotation)[] slots) { var where = $"fit {hull}"; var (hullData, hullProduct) = NamedOrProduct(hull, where); @@ -69,7 +77,7 @@ public sealed class ScenarioStage Product = product == null ? default : _items.ItemData.RefOf(product) }); } - return hullData != null && loadout.Slots.Count == slots.Length ? new ScenarioFit(loadout) : null; + return hullData != null && loadout.Slots.Count == slots.Length ? new ScenarioFit(loadout, quality) : null; } // A hull with nothing fitted. @@ -154,7 +162,7 @@ public sealed class ScenarioStage else { var failures = new List(); - entity = Loadouts.Materialize(_items, Arena, fit.Loadout, _choose, failures); + entity = Loadouts.Materialize(_items, Arena, fit.Loadout, _choose, failures, fit.Quality); _failures.AddRange(failures.Select(failure => $"{where} ({fit.Loadout.Name}): {failure}")); if (entity == null) return null; } @@ -190,7 +198,13 @@ public sealed class ScenarioFit { internal readonly Loadout Loadout; internal readonly EntityPack Pack; + internal readonly float? Quality; + + internal ScenarioFit(Loadout loadout, float? quality = null) + { + Loadout = loadout; + Quality = quality; + } - internal ScenarioFit(Loadout loadout) => Loadout = loadout; internal ScenarioFit(EntityPack pack) => Pack = pack; } diff --git a/Assets/Scripts/ServerShared/Scenarios/Crossing.cs b/Assets/Scripts/ServerShared/Scenarios/Crossing.cs index c90859439..516aac5be 100644 --- a/Assets/Scripts/ServerShared/Scenarios/Crossing.cs +++ b/Assets/Scripts/ServerShared/Scenarios/Crossing.cs @@ -22,6 +22,8 @@ public sealed class Crossing : Scenario // The waiting Djinni sits inside the Lightning Projector's arc at 80% of its Range. public static readonly CultMath.float2 Origin = float2(724, 124); public static readonly CultMath.float2 CrosserAt = Origin + float2(-128, 45), CrosserFacing = float2(1, 0), CrosserVelocity = float2(50, 0); + // The fighter is staged at this quality, so its gear and the range below do not ride the item stream. + public const float StagedQuality = .6f; public const float ProjectorRange = 1216f; // the Lightning Projector's Range in metres, 1216.4 as the fit stands settled at rest public static readonly CultMath.float2 Waiting = Origin + float2(0, ProjectorRange * .8f); @@ -29,7 +31,7 @@ public sealed class Crossing : Scenario public override void Stage(ScenarioStage stage) { - var fighter = stage.Fit("Longinus", + var fighter = stage.Fit("Longinus", StagedQuality, ("Cockpit 2x2", int2(2, 6), None), ("Large Drive", int2(1, 0), Reversed), ("Large Drive", int2(3, 0), Reversed), diff --git a/tests/Aetheria.Shared.Tests/EvasionTermTests.cs b/tests/Aetheria.Shared.Tests/EvasionTermTests.cs index ffd99d16e..80f0a145f 100644 --- a/tests/Aetheria.Shared.Tests/EvasionTermTests.cs +++ b/tests/Aetheria.Shared.Tests/EvasionTermTests.cs @@ -22,6 +22,9 @@ public sealed partial class RunStartTests { private const float EvDt = 1f / 60f; + // The quality the hand-fitted ships are staged at, so their measured constants do not ride the item stream. + private const float EvStagedQuality = .6f; + // The Longinus's drive train, fitted by name: its cockpit and power and the generated Longinus's thrusters (two Large Drive // forward, two Rugged Drive on the flanks). private static readonly (string design, int2 cell, ItemRotation rotation)[] EvLonginusDrive = @@ -32,7 +35,7 @@ public sealed partial class RunStartTests }; // The Duel's guns on a Longinus: the drive train above, its Targeting Computer, and the Duel's guns, launchers and sensor. - private static ScenarioFit EvLonginus(ScenarioStage stage, string gun = "Cell Blaster", string second = null) => stage.Fit("Longinus", + private static ScenarioFit EvLonginus(ScenarioStage stage, string gun = "Cell Blaster", string second = null) => stage.Fit("Longinus", EvStagedQuality, EvLonginusDrive.Concat(new (string design, int2 cell, ItemRotation rotation)[] { ("Guided Missile Launcher", int2(0, 5), ItemRotation.None), ("Guided Missile Launcher", int2(5, 5), ItemRotation.None), (gun, int2(1, 8), ItemRotation.None), @@ -70,7 +73,7 @@ public sealed partial class RunStartTests { stage.Player(stage.Bare("Djinni"), float2(-50000, -50000)); djinni = stage.Place(EvDjinni(stage), float2(-10000, -30000), facing: float2(0, 1)) as Ship; - longinus = stage.Place(stage.Fit("Longinus", EvLonginusDrive), float2(-30000, -30000), facing: float2(0, 1)) as Ship; + longinus = stage.Place(stage.Fit("Longinus", EvStagedQuality, EvLonginusDrive), float2(-30000, -30000), facing: float2(0, 1)) as Ship; }); var (_, arena, _, failures) = Launch(scenario, Inputs(() => GalaxySeed)); Assert.True(failures.Count == 0, string.Join("; ", failures)); @@ -621,7 +624,7 @@ public sealed partial class RunStartTests // The target's fit, written out: the Djinni's own hardpoints filled with the Rugged Drive it is generated with, its // reactor, cockpit and radiators. What the evasion tests price is this ship's strafing, not whatever the generator // rolls for it from the galaxy. - private static ScenarioFit EvDjinni(ScenarioStage stage) => stage.Fit("Djinni", + private static ScenarioFit EvDjinni(ScenarioStage stage) => stage.Fit("Djinni", EvStagedQuality, ("Cockpit 2x2", int2(6, 3), ItemRotation.None), ("Compact Reactor", int2(6, 11), ItemRotation.None), ("Rugged Drive", int2(6, 0), ItemRotation.Reversed), ("Rugged Drive", int2(5, 1), ItemRotation.Reversed), ("Rugged Drive", int2(7, 1), ItemRotation.Reversed), ("Rugged Drive", int2(4, 4), ItemRotation.CounterClockwise), ("Rugged Drive", int2(4, 11), ItemRotation.CounterClockwise), diff --git a/tests/Aetheria.Shared.Tests/ScenarioTests.cs b/tests/Aetheria.Shared.Tests/ScenarioTests.cs index 8e435d2f0..20a918438 100644 --- a/tests/Aetheria.Shared.Tests/ScenarioTests.cs +++ b/tests/Aetheria.Shared.Tests/ScenarioTests.cs @@ -291,6 +291,35 @@ public sealed partial class RunStartTests Assert.Contains("No Such Gun", Assert.Single(failures)); } + // A fit that states its quality mints every lot it builds at it, assembly and role fills alike; the same fit without one + // draws them from the item stream, so some lot comes out otherwise. A scenario's checks rest on the first. + [Fact] + public void StagedFitMintsAtItsQuality() + { + (string design, int2 cell, ItemRotation rotation)[] slots = + { + ("Cockpit 2x2", int2(2, 6), ItemRotation.None), ("Compact Reactor", int2(2, 4), ItemRotation.None), + ("Large Drive", int2(1, 0), ItemRotation.Reversed), ("Radiator", int2(2, 2), ItemRotation.CounterClockwise) + }; + var staged = Stage(Arena(true), new Scripted(true, stage => + { + stage.Player(stage.Bare("Djinni"), float2(0, 0)); + stage.Place(stage.Fit("Longinus", .6f, slots), float2(300, 0)); + stage.Place(stage.Fit("Longinus", slots), float2(-300, 0)); + })); + IEnumerable Lots(Entity entity) => + EntitySerializer.Items(EntitySerializer.Pack(entity)).OfType().Select(_items.GetLot); + var stated = Lots(staged.Entities[0]).ToArray(); + var drawn = Lots(staged.Entities[1]).ToArray(); + Assert.True(stated.Length > slots.Length); + Assert.All(stated, lot => + { + Assert.Equal(.6f, lot.Quality, 3); + Assert.All(lot.Roles ?? new List(), fill => Assert.Equal(.6f, fill.Quality, 3)); + }); + Assert.Contains(drawn, lot => Math.Abs(lot.Quality - .6f) > .001f); + } + // A stance holds both ways between an entity and the player. A piloted entity has exactly one agent; an unpiloted // one has none, and nothing steers it. (It is not frozen: the zone's gravity still moves it, as it moves any ship, // so the rule is observed on its steering inputs.) From 5b49a2bbf611259cd316e6b4a65e845a03863d6e Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 17 Oct 2026 19:07:12 +0200 Subject: [PATCH 05/25] AssemblyFromMakerCommand: restore the \n escapes in its two WriteLine strings The previous commit (30597b0e) wrote real line breaks inside two interpolated strings, so tools/AetherDb did not compile at it. Aetheria.Shared and the test project do not reference the tool. Co-Authored-By: Claude Opus 5.5 --- tools/AetherDb/AssemblyFromMakerCommand.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/AetherDb/AssemblyFromMakerCommand.cs b/tools/AetherDb/AssemblyFromMakerCommand.cs index d1badb62f..23f2cf1e2 100644 --- a/tools/AetherDb/AssemblyFromMakerCommand.cs +++ b/tools/AetherDb/AssemblyFromMakerCommand.cs @@ -58,8 +58,7 @@ public static class AssemblyFromMakerCommand if (!apply) { - output.WriteLine($" -Dry run. Pass \"apply\" to write {changed.Count} factions."); + output.WriteLine($"\nDry run. Pass \"apply\" to write {changed.Count} factions."); return 0; } @@ -68,8 +67,7 @@ Dry run. Pass \"apply\" to write {changed.Count} factions."); { foreach (var faction in changed) batch.Upsert(typeof(Faction), faction, cache.RefOf(faction).Key); }); - output.WriteLine($" -Wrote {changed.Count} factions in Aetheria.cc"); + output.WriteLine($"\nWrote {changed.Count} factions in Aetheria.cc"); return 0; } } From 0367f9d1fd1a6a46a74d1294cf77f73252bf714c Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 17 Oct 2026 19:57:39 +0200 Subject: [PATCH 06/25] Fused Rounds stages its shooter; FlightTests counts the Faction wire slots at 20 FusedRounds.StagedQuality (.6) states the shooter's quality so the Cluster Cannon's damage in TheDirectWeaponKillsTheFragileHullWhileASmokeRoundIsStillInTheAir does not ride the item stream. The Faction wire now has 20 slots (Assembly at 19); the Doctrine-at-17 rule is unchanged. LockOn is not staged here: see the question raised on the spec. Co-Authored-By: Claude Opus 5.5 --- Assets/Scripts/ServerShared/Scenarios/FusedRounds.cs | 5 ++++- tests/Aetheria.Shared.Tests/FlightTests.cs | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/ServerShared/Scenarios/FusedRounds.cs b/Assets/Scripts/ServerShared/Scenarios/FusedRounds.cs index db2e18b65..b2d70c98e 100644 --- a/Assets/Scripts/ServerShared/Scenarios/FusedRounds.cs +++ b/Assets/Scripts/ServerShared/Scenarios/FusedRounds.cs @@ -22,11 +22,14 @@ public sealed class FusedRounds : Scenario public static readonly CultMath.float2 Mid = float2(-200, 600), Ahead = float2(0, 300), Fragile = float2(80, 240), Close = float2(6.4f, 4f), Stern = float2(0, -400); + // The shooter is staged at this quality, so the damage its Cluster Cannon deals does not ride the item stream. + public const float StagedQuality = .6f; + public override Galaxy Generate(GalaxyStage stage) => stage.Prelude(DemoTerminus.Cast); public override void Stage(ScenarioStage stage) { - var shooter = stage.Fit("Smoke Test Hull", + var shooter = stage.Fit("Smoke Test Hull", StagedQuality, ("Cockpit 2x2", int2(4, 6), None), ("Large Drive", int2(3, 0), Reversed), ("Large Drive", int2(5, 0), Reversed), diff --git a/tests/Aetheria.Shared.Tests/FlightTests.cs b/tests/Aetheria.Shared.Tests/FlightTests.cs index cec6652c6..ba0a4dd82 100644 --- a/tests/Aetheria.Shared.Tests/FlightTests.cs +++ b/tests/Aetheria.Shared.Tests/FlightTests.cs @@ -919,7 +919,7 @@ public sealed class FlightTests : IDisposable var slots = MessagePack.MessagePackSerializer.Deserialize(MessagePack.MessagePackSerializer.Serialize(faction, CultDocumentMessagePackSerialization.OptionsFor(typeof(Faction).Assembly))); - Assert.Equal(21, slots.Length); + Assert.Equal(20, slots.Length); // 19 is Assembly Assert.Null(slots[16]); var doctrine = Assert.IsType(slots[17]); Assert.Equal(6f, Convert.ToSingle(doctrine[1])); From 198bf147d2372a69547675879fa421daf028523f Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 17 Oct 2026 19:57:54 +0200 Subject: [PATCH 07/25] Catalog: assembly-from-maker apply (15 factions) AetherDb assembly-from-maker apply on master's 0f5def17 catalog, after every product and faction apply: 15 makers of roled products get Assembly = part mean + .1 (capped at 1) and the mean part deviation. Ewan Hart Inc has no roled product and stays unauthored. A second apply reports No changes. Co-Authored-By: Claude Opus 5.5 --- GameData/Aetheria.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GameData/Aetheria.cc b/GameData/Aetheria.cc index a53215eec..f0b68fb9e 100644 --- a/GameData/Aetheria.cc +++ b/GameData/Aetheria.cc @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a4ff0effc5b80bbd4edea4c9f3855555d622e6939edfb720d08c4603b61ebee9 -size 12760370 +oid sha256:2b18ff7f115236eda17252a4a3b01bd2490e684b1722f375b0750e3a70a958d4 +size 12761080 From 2891b9a807fb731c96c620681c0697d4963444f2 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 17 Oct 2026 20:18:09 +0200 Subject: [PATCH 08/25] Tests: the drawn assembly clamp, Resolve at a stated quality, and the staged hull Hand mutants of the previous head survived in three places: the clamp on a drawn assembly, Loadouts.Resolve ignoring a stated quality for a product or an unbranded design, and Materialize not passing it to the hull. Each now has a test through the production path. Co-Authored-By: Claude Opus 5.5 --- .../AssemblyFromMakerTests.cs | 27 +++++++++++++++++++ tests/Aetheria.Shared.Tests/ScenarioTests.cs | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/tests/Aetheria.Shared.Tests/AssemblyFromMakerTests.cs b/tests/Aetheria.Shared.Tests/AssemblyFromMakerTests.cs index ae997dcb8..90f3fae04 100644 --- a/tests/Aetheria.Shared.Tests/AssemblyFromMakerTests.cs +++ b/tests/Aetheria.Shared.Tests/AssemblyFromMakerTests.cs @@ -110,6 +110,33 @@ public sealed class AssemblyFromMakerTests : IDisposable Assert.Equal(.01f, _items.Lots[_items.CreateLot(product, -1f)].Roles.Single().Quality, 3); } + // A drawn assembly stays a quality: a maker authored past either end mints lots at .01 or 1. + [Fact] + public void DrawnAssemblyIsClamped() + { + Assert.All(Mint(Product("Over", new Faction { Name = "Over Maker", Assembly = A(1.5f, 0) }, .5f), 20), q => Assert.Equal(1f, q, 3)); + Assert.All(Mint(Product("Under", new Faction { Name = "Under Maker", Assembly = A(-.5f, 0) }, .5f), 20), q => Assert.Equal(.01f, q, 3)); + } + + // A staged fit's slot is built by Loadouts.Resolve: a product at the stated quality, a design no maker sells at the stated + // quality instead of UnbrandedQuality, and both at their own draws without one. + [Fact] + public void ResolveMintsAtTheStatedQuality() + { + var failures = new List(); + Lot Built(CultRecordRef product, float? quality) => + _items.GetLot(Loadouts.Resolve(_items, _lens, product, _ => null, "lens", failures, quality)()); + var unbranded = Built(default, .6f); + Assert.Equal(.6f, unbranded.Quality, 3); + Assert.Equal(Loadouts.UnbrandedQuality, Built(default, null).Quality, 3); + + var made = Product("Made", new Faction { Name = "Made Maker", Assembly = A(.3f, .2f) }, .5f, .2f); + var branded = Built(_cache.RefOf(made), .6f); + Assert.Equal(.6f, branded.Quality, 3); + Assert.Equal(.6f, branded.Roles.Single().Quality, 3); + Assert.Empty(failures); + } + // The ceiling at the mint: a part drawn at .9 in an assembly of .4 reads .4; a part at .2 in the same assembly reads .2. [Fact] public void RoleCappedByAssembly() diff --git a/tests/Aetheria.Shared.Tests/ScenarioTests.cs b/tests/Aetheria.Shared.Tests/ScenarioTests.cs index 20a918438..9e5903eff 100644 --- a/tests/Aetheria.Shared.Tests/ScenarioTests.cs +++ b/tests/Aetheria.Shared.Tests/ScenarioTests.cs @@ -308,7 +308,7 @@ public sealed partial class RunStartTests stage.Place(stage.Fit("Longinus", slots), float2(-300, 0)); })); IEnumerable Lots(Entity entity) => - EntitySerializer.Items(EntitySerializer.Pack(entity)).OfType().Select(_items.GetLot); + EntitySerializer.Items(EntitySerializer.Pack(entity)).OfType().Select(_items.GetLot).Prepend(_items.GetLot(entity.Hull)); var stated = Lots(staged.Entities[0]).ToArray(); var drawn = Lots(staged.Entities[1]).ToArray(); Assert.True(stated.Length > slots.Length); From 72d7e25df01ed63e6086231bbad3d14881877ddd Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 17 Oct 2026 20:46:37 +0200 Subject: [PATCH 09/25] AI draws from its own dice: the range-sample offset and the patrol circuit leave ItemManager.Random Combat.SampleDps and Zone.CreateAgent's patrol circuit drew from the item stream, so minting items moved how a pilot fights and where it patrols. Both now draw SimulationDice.For(CombatSeed, stream, Agent.Id); Agent.Id is the zone-scoped ordinal Zone.NextAgentId gives a pilot at admission (ruling ai-sample-offset-off-item-stream). Co-Authored-By: Claude Opus 5.5 --- Assets/Scripts/ServerShared/Agents/Agent.cs | 3 +++ .../ServerShared/Agents/States/Combat.cs | 5 ++++- Assets/Scripts/ServerShared/SimulationDice.cs | 4 ++++ Assets/Scripts/ServerShared/Zone.cs | 10 +++++++-- .../FireControlPerWeaponTests.cs | 21 +++++++++++++++++++ 5 files changed, 40 insertions(+), 3 deletions(-) diff --git a/Assets/Scripts/ServerShared/Agents/Agent.cs b/Assets/Scripts/ServerShared/Agents/Agent.cs index c906ce33b..7aa7cfc54 100644 --- a/Assets/Scripts/ServerShared/Agents/Agent.cs +++ b/Assets/Scripts/ServerShared/Agents/Agent.cs @@ -23,6 +23,9 @@ public class Agent private VelocityLimit _velocityLimit; public AgentTask Task { get; set; } + // Zone-scoped, from 1: the ordinal of this pilot's own dice, set by Zone.CreateAgent as it admits the pilot (0 for + // an agent built outside a zone's admission). + public uint Id { get; init; } public Ship Ship { get; } public ItemManager ItemManager { get; } public GameplaySettings Settings { get; } diff --git a/Assets/Scripts/ServerShared/Agents/States/Combat.cs b/Assets/Scripts/ServerShared/Agents/States/Combat.cs index 8ed210567..499f631b0 100644 --- a/Assets/Scripts/ServerShared/Agents/States/Combat.cs +++ b/Assets/Scripts/ServerShared/Agents/States/Combat.cs @@ -173,7 +173,10 @@ public class CombatState : BaseState maxRange = weapon.Range; } - var offset = _agent.ItemManager.Random.NextFloat((maxRange - minRange) / DPS_SAMPLE_COUNT); + // The pilot's own dice, a pure function of the zone seed and its id: the same offset at every resample, and + // nothing that mints an item can move it. + var offset = SimulationDice.For(_agent.Ship.Zone.CombatSeed, SimulationDice.CombatSampleStream, _agent.Id) + .NextFloat((maxRange - minRange) / DPS_SAMPLE_COUNT); var optimumDPS = 0f; for (int i = 0; i < DPS_SAMPLE_COUNT; i++) { diff --git a/Assets/Scripts/ServerShared/SimulationDice.cs b/Assets/Scripts/ServerShared/SimulationDice.cs index 94d8f8946..ce646d670 100644 --- a/Assets/Scripts/ServerShared/SimulationDice.cs +++ b/Assets/Scripts/ServerShared/SimulationDice.cs @@ -10,6 +10,10 @@ public static class SimulationDice { public const uint LootStream = 1; public const uint MineStream = 2; + // A pilot's own decisions, ordinal Agent.Id: its preferred engagement range and its patrol circuit. AI behaviour + // never rides ItemManager.Random, so minting items cannot change how a pilot fights. + public const uint CombatSampleStream = 3; + public const uint PatrolStream = 4; // 9.1 (docs/fire-control-cut.md): fmix32, MurmurHash3's 32-bit finalizer -- xor-shift, multiply, // xor-shift, multiply, xor-shift. Diffuses a structured seed (a zone seed XORed with a small, diff --git a/Assets/Scripts/ServerShared/Zone.cs b/Assets/Scripts/ServerShared/Zone.cs index bb8e9adfe..4fc40fc53 100644 --- a/Assets/Scripts/ServerShared/Zone.cs +++ b/Assets/Scripts/ServerShared/Zone.cs @@ -133,6 +133,10 @@ public class Zone // The death ordinal of the loot dice: the nth death in this zone rolls on SimulationDice.For(CombatSeed, LootStream, n). private uint _deaths; + // The zone-scoped agent ordinal, from 1, never reused: the key of a pilot's own dice. + private uint _lastAgentId; + public uint NextAgentId() => ++_lastAgentId; + // One death subscription per member entity: Admit creates it together with the membership, Remove disposes it // together with the membership, and nothing else touches either. private readonly Dictionary _deathWatches = new Dictionary(); @@ -301,9 +305,11 @@ public class Zone var key = ship.Faction ?? Unaffiliated; if (!_flights.TryGetValue(key, out var flight)) _flights[key] = flight = new Flight(ship.Faction?.Doctrine, _itemManager.GameplaySettings); - var agent = new Minion(ship, flight.Combatant); + var id = NextAgentId(); + var agent = new Minion(ship, flight.Combatant) { Id = id }; var task = new PatrolOrbitsTask(); - task.Circuit = Orbits.OrderBy(_ => _itemManager.Random.NextFloat()).Take(4).Select(x => x.Key).ToArray(); + var dice = SimulationDice.For(CombatSeed, SimulationDice.PatrolStream, id); + task.Circuit = Orbits.OrderBy(_ => dice.NextFloat()).Take(4).Select(x => x.Key).ToArray(); flight.Join(agent, task); return agent; } diff --git a/tests/Aetheria.Shared.Tests/FireControlPerWeaponTests.cs b/tests/Aetheria.Shared.Tests/FireControlPerWeaponTests.cs index 2eca55442..72cec2284 100644 --- a/tests/Aetheria.Shared.Tests/FireControlPerWeaponTests.cs +++ b/tests/Aetheria.Shared.Tests/FireControlPerWeaponTests.cs @@ -780,6 +780,27 @@ public sealed class FireControlPerWeaponTests : IDisposable Assert.True(Optimum(1f) - Optimum(0f) > 100f); } + // The range-sample offset is the pilot's own draw (zone seed, its id), never the item stream's: the same pilot + // samples the same optimum however many items were minted before it spawned, and two pilots sample their own. + // Kills: the offset drawn from ItemManager.Random; the agent id dropped from the draw. + [Fact] + public void AnAgentsSampleOffsetIsItsOwnAndNotTheItemStreams() + { + var r = Build(range: 400f, decoy: true); + float Optimum(uint id, int itemsMintedFirst) + { + for (var i = 0; i < itemsMintedFirst; i++) r.Shooter.ItemManager.Random.NextFloat(); + var combat = new CombatState(new Minion(r.Shooter, new RoleDoctrine { RangeExponent = 1f, MinHitProbability = .2f }) { Id = id }); + combat.Update(0f); + return combat.OptimumRange; + } + + Assert.Equal(Optimum(3, 0), Optimum(3, 0)); + Assert.Equal(Optimum(3, 0), Optimum(3, 17)); + Assert.True(Enumerable.Range(1, 8).Select(i => Optimum((uint) i, 0)).Distinct().Count() > 1, + "pilots with different ids sample different offsets"); + } + // A round refused on a Range that fell between the trigger and the round is still free: the burst is paid // (SingleAmmoBurst) at its first round that is not refused, judged with the Range that round flies with. // The trigger saw a stale Range of 100; the round's Range is 29.5, under the arming distance. The refusal From e894bde146e46c2bce4c6891e15dd9f6baa56258 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 17 Oct 2026 20:47:09 +0200 Subject: [PATCH 10/25] Agent.Id is a plain setter: netstandard2.1 has no init accessors Co-Authored-By: Claude Opus 5.5 --- Assets/Scripts/ServerShared/Agents/Agent.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/Scripts/ServerShared/Agents/Agent.cs b/Assets/Scripts/ServerShared/Agents/Agent.cs index 7aa7cfc54..238df3ce7 100644 --- a/Assets/Scripts/ServerShared/Agents/Agent.cs +++ b/Assets/Scripts/ServerShared/Agents/Agent.cs @@ -25,7 +25,7 @@ public class Agent public AgentTask Task { get; set; } // Zone-scoped, from 1: the ordinal of this pilot's own dice, set by Zone.CreateAgent as it admits the pilot (0 for // an agent built outside a zone's admission). - public uint Id { get; init; } + public uint Id { get; set; } public Ship Ship { get; } public ItemManager ItemManager { get; } public GameplaySettings Settings { get; } From 5a16a2751c1c4774681667d376d092f650000653 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 17 Oct 2026 20:55:50 +0200 Subject: [PATCH 11/25] Crossing: ProjectorRange re-measured at the staged fit, 997 m (was 1216 at 0f5def17) Co-Authored-By: Claude Opus 5.5 --- Assets/Scripts/ServerShared/Scenarios/Crossing.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Assets/Scripts/ServerShared/Scenarios/Crossing.cs b/Assets/Scripts/ServerShared/Scenarios/Crossing.cs index 516aac5be..053de4f98 100644 --- a/Assets/Scripts/ServerShared/Scenarios/Crossing.cs +++ b/Assets/Scripts/ServerShared/Scenarios/Crossing.cs @@ -24,7 +24,10 @@ public sealed class Crossing : Scenario public static readonly CultMath.float2 CrosserAt = Origin + float2(-128, 45), CrosserFacing = float2(1, 0), CrosserVelocity = float2(50, 0); // The fighter is staged at this quality, so its gear and the range below do not ride the item stream. public const float StagedQuality = .6f; - public const float ProjectorRange = 1216f; // the Lightning Projector's Range in metres, 1216.4 as the fit stands settled at rest + // The Lightning Projector's Range in metres at the staged fit: 996.99 after the three seconds the test settles for + // (EvSettle); it falls toward 864 m as the projector heats. The fit as it stood at 0f5def17 (unstaged, its draws on the + // item stream) measured 1216.4. + public const float ProjectorRange = 997f; public static readonly CultMath.float2 Waiting = Origin + float2(0, ProjectorRange * .8f); public override Galaxy Generate(GalaxyStage stage) => stage.Prelude(DemoTerminus.Cast); From 27be39284f6c456eeccdb0d3e79b8cabd3d110a5 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 17 Oct 2026 20:56:28 +0200 Subject: [PATCH 12/25] Tests: the zone gives each admitted pilot its own id Co-Authored-By: Claude Opus 5.5 --- tests/Aetheria.Shared.Tests/ConsumableAiTests.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/Aetheria.Shared.Tests/ConsumableAiTests.cs b/tests/Aetheria.Shared.Tests/ConsumableAiTests.cs index f86dc1e07..de982bf86 100644 --- a/tests/Aetheria.Shared.Tests/ConsumableAiTests.cs +++ b/tests/Aetheria.Shared.Tests/ConsumableAiTests.cs @@ -323,6 +323,22 @@ public sealed class ConsumableAiTests : IDisposable Assert.Equal(overdrives, s.Active(s.Overdrive)); } + // The zone gives each pilot it admits its own ordinal, from 1 and never reused: the key of its own dice + // (SimulationDice.CombatSampleStream). Kills: Zone.CreateAgent not setting Agent.Id. + [Fact] + public void TheZoneGivesEachAdmittedPilotItsOwnId() + { + var s = Build(carryOverdrive: true); + var first = s.Zone.Agents.Single().Id; + Assert.True(first > 0, "an admitted pilot has an id"); + + Assert.True(s.Zone.Remove(s.Agent)); + s.Agent.Deactivate(); + s.Zone.Admit(s.Agent, piloted: true); + + Assert.True(s.Zone.Agents.Last(a => ReferenceEquals(a.Ship, s.Agent)).Id > first, "a re-admitted pilot is a new id"); + } + // The production path for the optimum: a ship the zone admits as piloted derives it from its gun's live stats // before it needs it, and re-derives it when its loadout changes. The gun's effective range is 500 and the // heavy gun's is 800, so the optimum moves with the weapons it has now. From bbfd816851fab29070f09e63f64fc971ae834a8e Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 17 Oct 2026 21:28:35 +0200 Subject: [PATCH 13/25] LockOn states its hostile's patrol order and fit quality; dice streams, patrol circuit and projector range pinned ScenarioStage.Patrol(entity, near) states a piloted entity's patrol order (the orbit nearest a point) and RunStart applies it over the drawn circuit. LockOn stages its fit at .6 and the hostile on the orbit by the player. Tests: every SimulationDice stream draws independently of every other (they already did: the stream is mixed into the hash), the pilot's sample offset is on its own stream's grid, a patrol circuit does not move with items minted first, Crossing.ProjectorRange is read against the live range. Co-Authored-By: Claude Opus 5.5 --- Assets/Scripts/ServerShared/RunStart.cs | 3 +++ Assets/Scripts/ServerShared/ScenarioStage.cs | 14 +++++++++++ .../Scripts/ServerShared/Scenarios/LockOn.cs | 9 +++++-- .../CrossingScenarioTests.cs | 1 + .../FireControlPerWeaponTests.cs | 12 +++++++++ .../FloatingBodyTests.cs | 23 +++++++++++++++++ tests/Aetheria.Shared.Tests/ScenarioTests.cs | 25 +++++++++++++++++++ 7 files changed, 85 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/ServerShared/RunStart.cs b/Assets/Scripts/ServerShared/RunStart.cs index b330ad944..c9c287a3c 100644 --- a/Assets/Scripts/ServerShared/RunStart.cs +++ b/Assets/Scripts/ServerShared/RunStart.cs @@ -54,6 +54,9 @@ public static class RunStart placed.Entity.SetIff(player, hostile); player.SetIff(placed.Entity, hostile); arena.Admit(placed.Entity, placed.Piloted); + // A stated patrol order replaces the circuit the zone drew for the pilot it just admitted. + if (placed.Circuit != null) + ((PatrolOrbitsTask) arena.Agents.Last(agent => ReferenceEquals(agent.Ship, placed.Entity)).Task).Circuit = placed.Circuit; } return new Staged { Player = player, Credits = stage.Credits, Entities = stage.Placed.Select(placed => placed.Entity).ToList() }; } diff --git a/Assets/Scripts/ServerShared/ScenarioStage.cs b/Assets/Scripts/ServerShared/ScenarioStage.cs index 77e5bf1e3..d89e4c7af 100644 --- a/Assets/Scripts/ServerShared/ScenarioStage.cs +++ b/Assets/Scripts/ServerShared/ScenarioStage.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; using CultMath; +using GameCult.Caching; using static CultMath.math; using float2 = CultMath.float2; using float3 = CultMath.float3; @@ -48,6 +49,7 @@ public sealed class ScenarioStage public Entity Entity; public ScenarioStance Stance; public bool Piloted; + public CultRecordKey[] Circuit; } // A hull fitted slot by slot: each slot a design or a product, the hull cell it goes in, and its rotation. A name is @@ -134,6 +136,18 @@ public sealed class ScenarioStage return entity; } + // The patrol order a piloted entity starts on: the one orbit that sits nearest `near` when the stage opens. A check + // that rests on where a pilot goes states it here, so the pilot's circuit is not a draw. An entity that is not + // piloted or not placed is a failure. + public void Patrol(Entity entity, float2 near) + { + var placement = _placed.FirstOrDefault(p => ReferenceEquals(p.Entity, entity)); + if (placement == null || !placement.Piloted) { _failures.Add($"patrol: {entity?.Name ?? "no entity"} is not a placed, piloted ship"); return; } + var orbit = Arena.Orbits.Keys.OrderBy(key => lengthsq(Arena.GetOrbitPosition(key) - near)).Cast().FirstOrDefault(); + if (orbit == null) { _failures.Add("patrol: the arena has no orbit to patrol"); return; } + placement.Circuit = new[] { orbit.Value }; + } + // Items in the entity's first cargo bay, one per name. A name is an equippable or consumable design (open: the stage // chooses its product) or a product of one (pinned); a name that is neither is a failure. public void Cargo(Entity entity, params string[] names) diff --git a/Assets/Scripts/ServerShared/Scenarios/LockOn.cs b/Assets/Scripts/ServerShared/Scenarios/LockOn.cs index 87fc14103..370c2cd80 100644 --- a/Assets/Scripts/ServerShared/Scenarios/LockOn.cs +++ b/Assets/Scripts/ServerShared/Scenarios/LockOn.cs @@ -18,11 +18,15 @@ public sealed class LockOn : Scenario // within a second. public static readonly CultMath.float2 HostileAt = float2(-2000, 3450); + // The fit's lots are minted at this quality, and the hostile's patrol order is stated, so the lock follows from the + // staged situation and not from item draws or the pilot's drawn circuit (ruling scenario-stages-hostile-task). + const float StagedQuality = .6f; + public override Galaxy Generate(GalaxyStage stage) => stage.Prelude(DemoTerminus.Cast); public override void Stage(ScenarioStage stage) { - var fighter = stage.Fit("Longinus", + var fighter = stage.Fit("Longinus", StagedQuality, ("Cockpit 2x2", int2(2, 6), None), ("Large Drive", int2(1, 0), Reversed), ("Large Drive", int2(3, 0), Reversed), @@ -41,6 +45,7 @@ public sealed class LockOn : Scenario ("Store-All Plus", int2(2, 8), None)); // Cargo Bay stage.Player(fighter, float2(0, 0), facing: float2(0, 1)); - stage.Place(fighter, HostileAt, facing: normalize(-HostileAt), stance: ScenarioStance.Hostile, piloted: true); + var hostile = stage.Place(fighter, HostileAt, facing: normalize(-HostileAt), stance: ScenarioStance.Hostile, piloted: true); + stage.Patrol(hostile, float2(0, 0)); // it patrols the orbit by the player, which brings it into lock range } } diff --git a/tests/Aetheria.Shared.Tests/CrossingScenarioTests.cs b/tests/Aetheria.Shared.Tests/CrossingScenarioTests.cs index a55cf3e93..a21aa7f19 100644 --- a/tests/Aetheria.Shared.Tests/CrossingScenarioTests.cs +++ b/tests/Aetheria.Shared.Tests/CrossingScenarioTests.cs @@ -55,6 +55,7 @@ public sealed partial class RunStartTests var toWaiting = waiting.Position - player.Position; EvSettle(player); // a weapon's Range is read once the ship's stats have settled; the geometry above is as staged var range = projector.Behaviors.OfType().Single().Range; + Assert.InRange(range, Crossing.ProjectorRange - 1f, Crossing.ProjectorRange + 1f); // the constant the waiting place is 80% of Assert.True(FireControl.InArc(projector, toWaiting), "the waiting Djinni is inside the Lightning Projector's arc"); Assert.True(length(toWaiting) <= range, "the waiting Djinni is inside the Lightning Projector's Range"); Assert.True(length(toWaiting) > .75f * range, "the waiting Djinni is beyond three quarters of the Lightning Projector's Range"); diff --git a/tests/Aetheria.Shared.Tests/FireControlPerWeaponTests.cs b/tests/Aetheria.Shared.Tests/FireControlPerWeaponTests.cs index 72cec2284..90e142b3c 100644 --- a/tests/Aetheria.Shared.Tests/FireControlPerWeaponTests.cs +++ b/tests/Aetheria.Shared.Tests/FireControlPerWeaponTests.cs @@ -799,6 +799,18 @@ public sealed class FireControlPerWeaponTests : IDisposable Assert.Equal(Optimum(3, 0), Optimum(3, 17)); Assert.True(Enumerable.Range(1, 8).Select(i => Optimum((uint) i, 0)).Distinct().Count() > 1, "pilots with different ids sample different offsets"); + + // Whose dice: each sampled range is the pilot's offset plus a whole step of the sample grid, so the optimum + // minus the offset from CombatSampleStream lands on the grid for every id; an offset from another stream + // (the loot dice, say) leaves a remainder. Kills: the offset drawn from another stream. + var min = r.Shooter.Weapons.Min(w => w.MinRange); + var step = (r.Shooter.Weapons.Max(w => w.Range) - min) / 32f; // Combat.DPS_SAMPLE_COUNT + foreach (var id in Enumerable.Range(1, 16).Select(i => (uint) i)) + { + var offset = SimulationDice.For(r.Zone.CombatSeed, SimulationDice.CombatSampleStream, id).NextFloat(step); + var cells = (Optimum(id, 0) - offset - min) / step; + Assert.True(MathF.Abs(cells - MathF.Round(cells)) < .01f, $"id {id}: optimum is {cells} steps from the pilot's own offset"); + } } // A round refused on a Range that fell between the trigger and the round is still free: the burst is paid diff --git a/tests/Aetheria.Shared.Tests/FloatingBodyTests.cs b/tests/Aetheria.Shared.Tests/FloatingBodyTests.cs index d2ee30870..ac4f763c1 100644 --- a/tests/Aetheria.Shared.Tests/FloatingBodyTests.cs +++ b/tests/Aetheria.Shared.Tests/FloatingBodyTests.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; using CultMath; using GameCult.Caching; using Xunit; @@ -138,6 +139,28 @@ public sealed class FloatingBodyTests : IDisposable Assert.Equal(1u, zero.state); } + // The stream is mixed into the seed, not added beside it: over many ordinals no two streams give the same first + // draw, and none of them tracks another's. + [Fact] + public void EveryStreamDrawsIndependentlyOfEveryOther() + { + uint[] streams = { SimulationDice.LootStream, SimulationDice.MineStream, SimulationDice.CombatSampleStream, SimulationDice.PatrolStream }; + const int count = 512; + var draws = streams.Select(s => Enumerable.Range(1, count).Select(n => SimulationDice.For(1234u, s, (uint) n).NextFloat()).ToArray()).ToArray(); + for (var a = 0; a < streams.Length; a++) + for (var b = a + 1; b < streams.Length; b++) + { + Assert.Equal(0, Enumerable.Range(0, count).Count(i => draws[a][i] == draws[b][i])); + var meanA = draws[a].Average(); + var meanB = draws[b].Average(); + var covariance = Enumerable.Range(0, count).Sum(i => (draws[a][i] - meanA) * (draws[b][i] - meanB)) / count; + var correlation = covariance / (StandardDeviation(draws[a], meanA) * StandardDeviation(draws[b], meanB)); + Assert.InRange(correlation, -.15f, .15f); // 512 independent draws: sigma ~ .044 + } + } + + private static float StandardDeviation(float[] xs, float mean) => MathF.Sqrt(xs.Sum(x => (x - mean) * (x - mean)) / xs.Length); + [Fact] public void NeighbouringZonesAndOrdinalsNeverShareADraw() { diff --git a/tests/Aetheria.Shared.Tests/ScenarioTests.cs b/tests/Aetheria.Shared.Tests/ScenarioTests.cs index 9e5903eff..60b205765 100644 --- a/tests/Aetheria.Shared.Tests/ScenarioTests.cs +++ b/tests/Aetheria.Shared.Tests/ScenarioTests.cs @@ -291,6 +291,31 @@ public sealed partial class RunStartTests Assert.Contains("No Such Gun", Assert.Single(failures)); } + // A pilot's patrol circuit is its own draw (zone seed, agent id), not the item stream's: two arenas that differ only + // in items minted before the pilot is admitted give it the same circuit. Kills: the circuit drawn from ItemManager.Random. + [Fact] + public void APilotsPatrolCircuitDoesNotRideTheItemStream() + { + Zone Arena(int itemsMintedFirst) + { + var (_, arena, _, failures) = Launch(new Scripted(false, stage => + { + stage.Player(stage.Bare("Djinni"), float2(0, 0)); + for (var i = 0; i < itemsMintedFirst; i++) stage.Place(stage.Generated("Longinus"), float2(900 + 40 * i, 0)); + stage.Place(stage.Generated("Longinus"), float2(300, 0), stance: ScenarioStance.Hostile, piloted: true); + })); + Assert.True(failures.Count == 0, string.Join("; ", failures)); + return arena; + } + CultRecordKey[] Circuit(Zone arena) => ((PatrolOrbitsTask) Assert.Single(arena.Agents).Task).Circuit; + + var plain = Arena(0); + var disturbed = Arena(3); + Assert.True(plain.Orbits.Count > 4, "the zone has orbits to choose a circuit among"); + Assert.Equal(4, Circuit(plain).Length); + Assert.Equal(Circuit(plain), Circuit(disturbed)); + } + // A fit that states its quality mints every lot it builds at it, assembly and role fills alike; the same fit without one // draws them from the item stream, so some lot comes out otherwise. A scenario's checks rest on the first. [Fact] From f7c933c08ec0e945b04319a6ff27231c38c4f9ad Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 17 Oct 2026 21:30:31 +0200 Subject: [PATCH 14/25] probe (scratch, to be removed) --- tests/Aetheria.Shared.Tests/ZProbeTests.cs | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/Aetheria.Shared.Tests/ZProbeTests.cs diff --git a/tests/Aetheria.Shared.Tests/ZProbeTests.cs b/tests/Aetheria.Shared.Tests/ZProbeTests.cs new file mode 100644 index 000000000..94c81414f --- /dev/null +++ b/tests/Aetheria.Shared.Tests/ZProbeTests.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Xunit; +using static CultMath.math; + +public sealed partial class RunStartTests +{ + [Fact] + public void ZProbeLockOn() + { + var (_, arena, staged, failures) = Launch(new LockOn(), Inputs(() => GalaxySeed)); + var player = staged.Player; + var hostile = staged.Entities.Single(); + var keys = arena.Orbits.Keys.ToList(); + var agent = arena.Agents.Single(); + var circuit = ((PatrolOrbitsTask) agent.Task).Circuit; + Console.WriteLine($"PROBE circuit idx={string.Join(",", circuit.Select(k => keys.IndexOf(k)))} orbits={keys.Count}"); + for (var i = 0; i < keys.Count; i++) Console.WriteLine($"PROBE orbit {i} at {arena.GetOrbitPosition(keys[i])}"); + var minD = 1e9f; + for (var tick = 0; tick < 600; tick++) + { + arena.Update(.1f); + var d = length(hostile.Position.xz - player.Position.xz); + minD = min(minD, d); + var locked = player.IncomingPaints.Any(p => p.Mode == PaintMode.Track); + if (tick % 40 == 0 || locked && tick % 10 == 0) + Console.WriteLine($"PROBE t={tick} d={d} host={hostile.Position.xz} orbit0={arena.Orbits[circuit[0]].Position} locked={locked} task={agent.Task?.GetType().Name} tgt={hostile is Ship s && s.Target.Value.Entity != null} vis={((Ship)hostile).VisibleEnemies.Count}"); + } + Console.WriteLine($"PROBE minD={minD}"); + Assert.Fail("probe"); + } +} From 6216b50d6f19cd942fc9135729839228c15dbff2 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 17 Oct 2026 21:33:33 +0200 Subject: [PATCH 15/25] probe (scratch) --- tests/Aetheria.Shared.Tests/ZProbeTests.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/Aetheria.Shared.Tests/ZProbeTests.cs b/tests/Aetheria.Shared.Tests/ZProbeTests.cs index 94c81414f..a8bafd3d4 100644 --- a/tests/Aetheria.Shared.Tests/ZProbeTests.cs +++ b/tests/Aetheria.Shared.Tests/ZProbeTests.cs @@ -11,12 +11,12 @@ public sealed partial class RunStartTests { var (_, arena, staged, failures) = Launch(new LockOn(), Inputs(() => GalaxySeed)); var player = staged.Player; - var hostile = staged.Entities.Single(); + var hostile = staged.Entities.Single(); var log = new List(); var keys = arena.Orbits.Keys.ToList(); var agent = arena.Agents.Single(); var circuit = ((PatrolOrbitsTask) agent.Task).Circuit; - Console.WriteLine($"PROBE circuit idx={string.Join(",", circuit.Select(k => keys.IndexOf(k)))} orbits={keys.Count}"); - for (var i = 0; i < keys.Count; i++) Console.WriteLine($"PROBE orbit {i} at {arena.GetOrbitPosition(keys[i])}"); + log.Add($"PROBE circuit idx={string.Join(",", circuit.Select(k => keys.IndexOf(k)))} orbits={keys.Count}"); + for (var i = 0; i < keys.Count; i++) log.Add($"PROBE orbit {i} at {arena.GetOrbitPosition(keys[i])}"); var minD = 1e9f; for (var tick = 0; tick < 600; tick++) { @@ -25,9 +25,11 @@ public sealed partial class RunStartTests minD = min(minD, d); var locked = player.IncomingPaints.Any(p => p.Mode == PaintMode.Track); if (tick % 40 == 0 || locked && tick % 10 == 0) - Console.WriteLine($"PROBE t={tick} d={d} host={hostile.Position.xz} orbit0={arena.Orbits[circuit[0]].Position} locked={locked} task={agent.Task?.GetType().Name} tgt={hostile is Ship s && s.Target.Value.Entity != null} vis={((Ship)hostile).VisibleEnemies.Count}"); + log.Add($"PROBE t={tick} d={d} host={hostile.Position.xz} orbit0={arena.Orbits[circuit[0]].Position} locked={locked} task={agent.Task?.GetType().Name} tgt={hostile is Ship s && s.Target.Value.Entity != null} vis={((Ship)hostile).VisibleEnemies.Count}"); } - Console.WriteLine($"PROBE minD={minD}"); - Assert.Fail("probe"); + log.Add($"PROBE minD={minD}"); + Assert.Fail(" +" + string.Join(" +", log)); } } From 244e98e46361e7784328bba787507a8931f93a6c Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 17 Oct 2026 21:35:54 +0200 Subject: [PATCH 16/25] probe (scratch 2) --- tests/Aetheria.Shared.Tests/ZProbeTests.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/Aetheria.Shared.Tests/ZProbeTests.cs b/tests/Aetheria.Shared.Tests/ZProbeTests.cs index a8bafd3d4..35f1ae1e6 100644 --- a/tests/Aetheria.Shared.Tests/ZProbeTests.cs +++ b/tests/Aetheria.Shared.Tests/ZProbeTests.cs @@ -28,8 +28,6 @@ public sealed partial class RunStartTests log.Add($"PROBE t={tick} d={d} host={hostile.Position.xz} orbit0={arena.Orbits[circuit[0]].Position} locked={locked} task={agent.Task?.GetType().Name} tgt={hostile is Ship s && s.Target.Value.Entity != null} vis={((Ship)hostile).VisibleEnemies.Count}"); } log.Add($"PROBE minD={minD}"); - Assert.Fail(" -" + string.Join(" -", log)); + Assert.Fail(string.Join(Environment.NewLine, log)); } } From 5f1fa7d63b826941225fd171730a57dca7dc9367 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 17 Oct 2026 21:37:12 +0200 Subject: [PATCH 17/25] probe (scratch 3) --- tests/Aetheria.Shared.Tests/ZProbeTests.cs | 38 ++++++++++++---------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/tests/Aetheria.Shared.Tests/ZProbeTests.cs b/tests/Aetheria.Shared.Tests/ZProbeTests.cs index 35f1ae1e6..68e366312 100644 --- a/tests/Aetheria.Shared.Tests/ZProbeTests.cs +++ b/tests/Aetheria.Shared.Tests/ZProbeTests.cs @@ -9,25 +9,29 @@ public sealed partial class RunStartTests [Fact] public void ZProbeLockOn() { - var (_, arena, staged, failures) = Launch(new LockOn(), Inputs(() => GalaxySeed)); - var player = staged.Player; - var hostile = staged.Entities.Single(); var log = new List(); - var keys = arena.Orbits.Keys.ToList(); - var agent = arena.Agents.Single(); - var circuit = ((PatrolOrbitsTask) agent.Task).Circuit; - log.Add($"PROBE circuit idx={string.Join(",", circuit.Select(k => keys.IndexOf(k)))} orbits={keys.Count}"); - for (var i = 0; i < keys.Count; i++) log.Add($"PROBE orbit {i} at {arena.GetOrbitPosition(keys[i])}"); - var minD = 1e9f; - for (var tick = 0; tick < 600; tick++) + var log = new List(); + for (var which = -1; which < 13; which++) { - arena.Update(.1f); - var d = length(hostile.Position.xz - player.Position.xz); - minD = min(minD, d); - var locked = player.IncomingPaints.Any(p => p.Mode == PaintMode.Track); - if (tick % 40 == 0 || locked && tick % 10 == 0) - log.Add($"PROBE t={tick} d={d} host={hostile.Position.xz} orbit0={arena.Orbits[circuit[0]].Position} locked={locked} task={agent.Task?.GetType().Name} tgt={hostile is Ship s && s.Target.Value.Entity != null} vis={((Ship)hostile).VisibleEnemies.Count}"); + var (_, arena, staged, failures) = Launch(new LockOn(), Inputs(() => GalaxySeed)); + var player = staged.Player; + var hostile = staged.Entities.Single(); + var keys = arena.Orbits.Keys.ToList(); + var agent = arena.Agents.Single(); + var task = (PatrolOrbitsTask) agent.Task; + if (which < 0) + foreach (var b in arena.PlanetInstances) + log.Add($"PROBE body {arena.Planets[b.Key].Name} orbit idx {keys.IndexOf(b.Value.Orbit.Data == null ? default : keys.First(k => ReferenceEquals(arena.Orbits[k], b.Value.Orbit)))}"); + else task.Circuit = new[] { keys[which] }; + var minD = 1e9f; + var lockedAt = -1; + for (var tick = 0; tick < 600 && lockedAt < 0; tick++) + { + arena.Update(.1f); + minD = min(minD, length(hostile.Position.xz - player.Position.xz)); + if (player.IncomingPaints.Any(p => p.Mode == PaintMode.Track)) lockedAt = tick; + } + log.Add($"PROBE only-orbit {which} start={arena.Orbits[keys[Math.Max(which, 0)]].Position} locked={lockedAt} minD={minD}"); } - log.Add($"PROBE minD={minD}"); Assert.Fail(string.Join(Environment.NewLine, log)); } } From f0cb87277bdb207827f97e4697edb7b7ad801eb6 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 17 Oct 2026 21:38:50 +0200 Subject: [PATCH 18/25] LockOn patrols orbit 3 by index; the probe file is dropped Co-Authored-By: Claude Opus 5.5 --- Assets/Scripts/ServerShared/ScenarioStage.cs | 13 +++---- .../Scripts/ServerShared/Scenarios/LockOn.cs | 5 ++- tests/Aetheria.Shared.Tests/ScenarioTests.cs | 7 +++- tests/Aetheria.Shared.Tests/ZProbeTests.cs | 37 ------------------- 4 files changed, 15 insertions(+), 47 deletions(-) delete mode 100644 tests/Aetheria.Shared.Tests/ZProbeTests.cs diff --git a/Assets/Scripts/ServerShared/ScenarioStage.cs b/Assets/Scripts/ServerShared/ScenarioStage.cs index d89e4c7af..735d40775 100644 --- a/Assets/Scripts/ServerShared/ScenarioStage.cs +++ b/Assets/Scripts/ServerShared/ScenarioStage.cs @@ -136,16 +136,15 @@ public sealed class ScenarioStage return entity; } - // The patrol order a piloted entity starts on: the one orbit that sits nearest `near` when the stage opens. A check - // that rests on where a pilot goes states it here, so the pilot's circuit is not a draw. An entity that is not - // piloted or not placed is a failure. - public void Patrol(Entity entity, float2 near) + // The patrol order a piloted entity starts on: the one orbit at this index of the arena's orbits, which a galaxy seed + // fixes. A check that rests on where a pilot goes states it here, so the pilot's circuit is not a draw. An entity that + // is not placed and piloted, or an index past the orbits, is a failure. + public void Patrol(Entity entity, int orbit) { var placement = _placed.FirstOrDefault(p => ReferenceEquals(p.Entity, entity)); if (placement == null || !placement.Piloted) { _failures.Add($"patrol: {entity?.Name ?? "no entity"} is not a placed, piloted ship"); return; } - var orbit = Arena.Orbits.Keys.OrderBy(key => lengthsq(Arena.GetOrbitPosition(key) - near)).Cast().FirstOrDefault(); - if (orbit == null) { _failures.Add("patrol: the arena has no orbit to patrol"); return; } - placement.Circuit = new[] { orbit.Value }; + if (orbit < 0 || orbit >= Arena.Orbits.Count) { _failures.Add($"patrol: the arena has no orbit {orbit} (it has {Arena.Orbits.Count})"); return; } + placement.Circuit = new[] { Arena.Orbits.Keys.ElementAt(orbit) }; } // Items in the entity's first cargo bay, one per name. A name is an equippable or consumable design (open: the stage diff --git a/Assets/Scripts/ServerShared/Scenarios/LockOn.cs b/Assets/Scripts/ServerShared/Scenarios/LockOn.cs index 370c2cd80..56195a9c7 100644 --- a/Assets/Scripts/ServerShared/Scenarios/LockOn.cs +++ b/Assets/Scripts/ServerShared/Scenarios/LockOn.cs @@ -21,6 +21,9 @@ public sealed class LockOn : Scenario // The fit's lots are minted at this quality, and the hostile's patrol order is stated, so the lock follows from the // staged situation and not from item draws or the pilot's drawn circuit (ruling scenario-stages-hostile-task). const float StagedQuality = .6f; + // The orbit it patrols: the fourth of the arena's, which carries the hostile across the player's lock envelope (lock + // at about 35 s, closest 880 m; the other twelve, patrolled alone, do not lock it in 600 ticks). + const int PatrolOrbit = 3; public override Galaxy Generate(GalaxyStage stage) => stage.Prelude(DemoTerminus.Cast); @@ -46,6 +49,6 @@ public sealed class LockOn : Scenario stage.Player(fighter, float2(0, 0), facing: float2(0, 1)); var hostile = stage.Place(fighter, HostileAt, facing: normalize(-HostileAt), stance: ScenarioStance.Hostile, piloted: true); - stage.Patrol(hostile, float2(0, 0)); // it patrols the orbit by the player, which brings it into lock range + stage.Patrol(hostile, PatrolOrbit); } } diff --git a/tests/Aetheria.Shared.Tests/ScenarioTests.cs b/tests/Aetheria.Shared.Tests/ScenarioTests.cs index 60b205765..fe457bbd6 100644 --- a/tests/Aetheria.Shared.Tests/ScenarioTests.cs +++ b/tests/Aetheria.Shared.Tests/ScenarioTests.cs @@ -309,11 +309,14 @@ public sealed partial class RunStartTests } CultRecordKey[] Circuit(Zone arena) => ((PatrolOrbitsTask) Assert.Single(arena.Agents).Task).Circuit; + // The orbit keys are fresh per galaxy, so a circuit is compared by the place of each orbit among its zone's. + int[] Places(Zone arena) => Circuit(arena).Select(key => arena.Orbits.Keys.ToList().IndexOf(key)).ToArray(); + var plain = Arena(0); var disturbed = Arena(3); Assert.True(plain.Orbits.Count > 4, "the zone has orbits to choose a circuit among"); - Assert.Equal(4, Circuit(plain).Length); - Assert.Equal(Circuit(plain), Circuit(disturbed)); + Assert.Equal(4, Places(plain).Length); + Assert.Equal(Places(plain), Places(disturbed)); } // A fit that states its quality mints every lot it builds at it, assembly and role fills alike; the same fit without one diff --git a/tests/Aetheria.Shared.Tests/ZProbeTests.cs b/tests/Aetheria.Shared.Tests/ZProbeTests.cs deleted file mode 100644 index 68e366312..000000000 --- a/tests/Aetheria.Shared.Tests/ZProbeTests.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Xunit; -using static CultMath.math; - -public sealed partial class RunStartTests -{ - [Fact] - public void ZProbeLockOn() - { - var log = new List(); - for (var which = -1; which < 13; which++) - { - var (_, arena, staged, failures) = Launch(new LockOn(), Inputs(() => GalaxySeed)); - var player = staged.Player; - var hostile = staged.Entities.Single(); - var keys = arena.Orbits.Keys.ToList(); - var agent = arena.Agents.Single(); - var task = (PatrolOrbitsTask) agent.Task; - if (which < 0) - foreach (var b in arena.PlanetInstances) - log.Add($"PROBE body {arena.Planets[b.Key].Name} orbit idx {keys.IndexOf(b.Value.Orbit.Data == null ? default : keys.First(k => ReferenceEquals(arena.Orbits[k], b.Value.Orbit)))}"); - else task.Circuit = new[] { keys[which] }; - var minD = 1e9f; - var lockedAt = -1; - for (var tick = 0; tick < 600 && lockedAt < 0; tick++) - { - arena.Update(.1f); - minD = min(minD, length(hostile.Position.xz - player.Position.xz)); - if (player.IncomingPaints.Any(p => p.Mode == PaintMode.Track)) lockedAt = tick; - } - log.Add($"PROBE only-orbit {which} start={arena.Orbits[keys[Math.Max(which, 0)]].Position} locked={lockedAt} minD={minD}"); - } - Assert.Fail(string.Join(Environment.NewLine, log)); - } -} From 203093bcbd93b05ccf4b85c80bfd5e01b6fed175 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 17 Oct 2026 21:57:33 +0200 Subject: [PATCH 19/25] probe (scratch 4) --- tests/Aetheria.Shared.Tests/ZProbeTests.cs | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 tests/Aetheria.Shared.Tests/ZProbeTests.cs diff --git a/tests/Aetheria.Shared.Tests/ZProbeTests.cs b/tests/Aetheria.Shared.Tests/ZProbeTests.cs new file mode 100644 index 000000000..624586786 --- /dev/null +++ b/tests/Aetheria.Shared.Tests/ZProbeTests.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Xunit; +using static CultMath.math; + +public sealed partial class RunStartTests +{ + [Fact] + public void ZProbeLockOn() + { + var log = new List(); + var circuits = new List { new[] { 3 } }; + for (var j = 0; j < 13; j++) if (j != 3) { circuits.Add(new[] { j, 3 }); circuits.Add(new[] { 3, j }); } + foreach (var c in circuits) + { + var (_, arena, staged, failures) = Launch(new LockOn(), Inputs(() => GalaxySeed)); + var player = staged.Player; + var hostile = staged.Entities.Single(); + var keys = arena.Orbits.Keys.ToList(); + ((PatrolOrbitsTask) arena.Agents.Single().Task).Circuit = c.Select(i => keys[i]).ToArray(); + var minD = 1e9f; + var lockedAt = -1; + var line = ""; + for (var tick = 0; tick < 600 && lockedAt < 0; tick++) + { + arena.Update(.1f); + var d = length(hostile.Position.xz - player.Position.xz); + minD = min(minD, d); + foreach (var paint in player.IncomingPaints.Where(p => p.Mode == PaintMode.Track)) + { + lockedAt = tick; + var live = normalize(hostile.Position.xz - player.Position.xz); + var err = degrees(acos(clamp(dot(normalize(paint.Bearing), live), -1f, 1f))); + line = $"err={err} d={d} hostV={length(hostile.Velocity)} relV={length(hostile.Velocity - player.Velocity)}"; + break; + } + } + log.Add($"PROBE circuit [{string.Join(",", c)}] locked={lockedAt} minD={minD} {line}"); + } + Assert.Fail(string.Join(Environment.NewLine, log)); + } +} From dbe4525a02443e63bdfcd9ffe1ac6d7e1354d760 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 17 Oct 2026 21:58:59 +0200 Subject: [PATCH 20/25] probe (scratch 5, reverted next) --- Assets/Scripts/ServerShared/Scenarios/LockOn.cs | 5 ++++- tests/Aetheria.Shared.Tests/ZProbeTests.cs | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Assets/Scripts/ServerShared/Scenarios/LockOn.cs b/Assets/Scripts/ServerShared/Scenarios/LockOn.cs index 56195a9c7..5b8457f78 100644 --- a/Assets/Scripts/ServerShared/Scenarios/LockOn.cs +++ b/Assets/Scripts/ServerShared/Scenarios/LockOn.cs @@ -3,6 +3,9 @@ using static ItemRotation; public sealed class LockOn : Scenario { + private readonly float _q; + public LockOn(float q = .6f) { _q = q; } + public override string Name => "Lock On"; public override string Brief => "A hostile closes from out of sight, finds you and locks. Verify: no warning at first; once it locks, one " + "indicator appears toward it and tightens as the lock grows; break line of sight or range and it vanishes; " + @@ -29,7 +32,7 @@ public sealed class LockOn : Scenario public override void Stage(ScenarioStage stage) { - var fighter = stage.Fit("Longinus", StagedQuality, + var fighter = stage.Fit("Longinus", _q, ("Cockpit 2x2", int2(2, 6), None), ("Large Drive", int2(1, 0), Reversed), ("Large Drive", int2(3, 0), Reversed), diff --git a/tests/Aetheria.Shared.Tests/ZProbeTests.cs b/tests/Aetheria.Shared.Tests/ZProbeTests.cs index 624586786..5037b5739 100644 --- a/tests/Aetheria.Shared.Tests/ZProbeTests.cs +++ b/tests/Aetheria.Shared.Tests/ZProbeTests.cs @@ -12,9 +12,9 @@ public sealed partial class RunStartTests var log = new List(); var circuits = new List { new[] { 3 } }; for (var j = 0; j < 13; j++) if (j != 3) { circuits.Add(new[] { j, 3 }); circuits.Add(new[] { 3, j }); } - foreach (var c in circuits) + foreach (var q in new[] { .2f, .3f, .4f, .5f, .7f, .8f, .9f, 1f }) foreach (var c in new[] { new[] { 3 } }) { - var (_, arena, staged, failures) = Launch(new LockOn(), Inputs(() => GalaxySeed)); + var (_, arena, staged, failures) = Launch(new LockOn(q), Inputs(() => GalaxySeed)); var player = staged.Player; var hostile = staged.Entities.Single(); var keys = arena.Orbits.Keys.ToList(); @@ -36,7 +36,7 @@ public sealed partial class RunStartTests break; } } - log.Add($"PROBE circuit [{string.Join(",", c)}] locked={lockedAt} minD={minD} {line}"); + log.Add($"PROBE q={q} circuit [{string.Join(",", c)}] locked={lockedAt} minD={minD} {line}"); } Assert.Fail(string.Join(Environment.NewLine, log)); } From eb752a49c90bc5a9f0a6973bbf7af26bceae0a84 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 17 Oct 2026 22:00:42 +0200 Subject: [PATCH 21/25] LockOn stages its fit at .8: the lock then holds the test's bearing check; probe files dropped Co-Authored-By: Claude Opus 5.5 --- .../Scripts/ServerShared/Scenarios/LockOn.cs | 9 ++-- tests/Aetheria.Shared.Tests/ZProbeTests.cs | 43 ------------------- 2 files changed, 4 insertions(+), 48 deletions(-) delete mode 100644 tests/Aetheria.Shared.Tests/ZProbeTests.cs diff --git a/Assets/Scripts/ServerShared/Scenarios/LockOn.cs b/Assets/Scripts/ServerShared/Scenarios/LockOn.cs index 5b8457f78..609e6b528 100644 --- a/Assets/Scripts/ServerShared/Scenarios/LockOn.cs +++ b/Assets/Scripts/ServerShared/Scenarios/LockOn.cs @@ -3,9 +3,6 @@ using static ItemRotation; public sealed class LockOn : Scenario { - private readonly float _q; - public LockOn(float q = .6f) { _q = q; } - public override string Name => "Lock On"; public override string Brief => "A hostile closes from out of sight, finds you and locks. Verify: no warning at first; once it locks, one " + "indicator appears toward it and tightens as the lock grows; break line of sight or range and it vanishes; " + @@ -23,7 +20,9 @@ public sealed class LockOn : Scenario // The fit's lots are minted at this quality, and the hostile's patrol order is stated, so the lock follows from the // staged situation and not from item draws or the pilot's drawn circuit (ruling scenario-stages-hostile-task). - const float StagedQuality = .6f; + // .8 and not Crossing's .6: the lock comes at the hostile's closest pass, where the warning's one-tick lag reads as bearing error + // (the test allows .5 degrees); at .6 the lock came at 880 m with .57, at .7 .48, at .8 .45 (942 m); at .2 to .5 and 1 no lock in 600 ticks. + const float StagedQuality = .8f; // The orbit it patrols: the fourth of the arena's, which carries the hostile across the player's lock envelope (lock // at about 35 s, closest 880 m; the other twelve, patrolled alone, do not lock it in 600 ticks). const int PatrolOrbit = 3; @@ -32,7 +31,7 @@ public sealed class LockOn : Scenario public override void Stage(ScenarioStage stage) { - var fighter = stage.Fit("Longinus", _q, + var fighter = stage.Fit("Longinus", StagedQuality, ("Cockpit 2x2", int2(2, 6), None), ("Large Drive", int2(1, 0), Reversed), ("Large Drive", int2(3, 0), Reversed), diff --git a/tests/Aetheria.Shared.Tests/ZProbeTests.cs b/tests/Aetheria.Shared.Tests/ZProbeTests.cs deleted file mode 100644 index 5037b5739..000000000 --- a/tests/Aetheria.Shared.Tests/ZProbeTests.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Xunit; -using static CultMath.math; - -public sealed partial class RunStartTests -{ - [Fact] - public void ZProbeLockOn() - { - var log = new List(); - var circuits = new List { new[] { 3 } }; - for (var j = 0; j < 13; j++) if (j != 3) { circuits.Add(new[] { j, 3 }); circuits.Add(new[] { 3, j }); } - foreach (var q in new[] { .2f, .3f, .4f, .5f, .7f, .8f, .9f, 1f }) foreach (var c in new[] { new[] { 3 } }) - { - var (_, arena, staged, failures) = Launch(new LockOn(q), Inputs(() => GalaxySeed)); - var player = staged.Player; - var hostile = staged.Entities.Single(); - var keys = arena.Orbits.Keys.ToList(); - ((PatrolOrbitsTask) arena.Agents.Single().Task).Circuit = c.Select(i => keys[i]).ToArray(); - var minD = 1e9f; - var lockedAt = -1; - var line = ""; - for (var tick = 0; tick < 600 && lockedAt < 0; tick++) - { - arena.Update(.1f); - var d = length(hostile.Position.xz - player.Position.xz); - minD = min(minD, d); - foreach (var paint in player.IncomingPaints.Where(p => p.Mode == PaintMode.Track)) - { - lockedAt = tick; - var live = normalize(hostile.Position.xz - player.Position.xz); - var err = degrees(acos(clamp(dot(normalize(paint.Bearing), live), -1f, 1f))); - line = $"err={err} d={d} hostV={length(hostile.Velocity)} relV={length(hostile.Velocity - player.Velocity)}"; - break; - } - } - log.Add($"PROBE q={q} circuit [{string.Join(",", c)}] locked={lockedAt} minD={minD} {line}"); - } - Assert.Fail(string.Join(Environment.NewLine, log)); - } -} From 14d3327c1927a9d463fc9d75b654bde63ec32ec7 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 18 Oct 2026 00:51:33 +0200 Subject: [PATCH 22/25] LockOn: the hostile is ordered to close on the player; the warning is measured against the poses it was stamped from ScenarioStage.Approach(entity, target) states a piloted entity's task as a follow task on the target, passed through Zone.Admit to the flight as the member's baseline task; it replaces Patrol(entity, orbit) and the orbit index, and RunStart's post-admit circuit overwrite. LockOn stages at .6, the quality Crossing and the other RunStart scenarios use (its brief states none), not .8 picked by outcome. The bearing check keeps well-law r4's intent (measure against the hostile's actual pose, not the staged line) but reads the poses of the tick before the paint was first seen, which is the tick it was stamped in, with a .05 deg limit for float error; the live-pose check at .5 deg spent its budget on the paint inbox's deliberate one-tick delay. LockOnHoldsUnderOnePercentOfEachStagedInput moves hostile x, y and quality by 1% each way. Co-Authored-By: Claude Opus 5.5 --- Assets/Scripts/ServerShared/Agents/Flight.cs | 13 +++-- Assets/Scripts/ServerShared/RunStart.cs | 5 +- Assets/Scripts/ServerShared/ScenarioStage.cs | 17 +++--- .../Scripts/ServerShared/Scenarios/LockOn.cs | 39 +++++++------ Assets/Scripts/ServerShared/Zone.cs | 18 +++--- .../LockOnScenarioTests.cs | 57 ++++++++++++++++--- 6 files changed, 100 insertions(+), 49 deletions(-) diff --git a/Assets/Scripts/ServerShared/Agents/Flight.cs b/Assets/Scripts/ServerShared/Agents/Flight.cs index b96250ad8..de3c8f0c0 100644 --- a/Assets/Scripts/ServerShared/Agents/Flight.cs +++ b/Assets/Scripts/ServerShared/Agents/Flight.cs @@ -25,7 +25,7 @@ public class Flight private class Member { public Agent Agent; - public PatrolOrbitsTask Patrol; + public AgentTask Baseline; } private readonly FactionDoctrine _doctrine; @@ -49,10 +49,11 @@ public class Flight public Phase PhaseOf(Entity track) => _tracks.TryGetValue(track, out var t) ? t.Phase : Phase.None; - public void Join(Agent agent, PatrolOrbitsTask circuit) + // The task a member holds when the flight has nothing to follow: its patrol circuit, or the task a scenario stated. + public void Join(Agent agent, AgentTask baseline) { - _members.Add(new Member { Agent = agent, Patrol = circuit }); - agent.Task = circuit; + _members.Add(new Member { Agent = agent, Baseline = baseline }); + agent.Task = baseline; } public void Leave(Agent agent) => _members.RemoveAll(m => m.Agent == agent); @@ -167,8 +168,8 @@ public class Flight if (!(member.Agent.Task is FollowTask current) || current.Anchor != anchor) member.Agent.Task = new FollowTask { Anchor = anchor, Standoff = Standoff(ship) }; } - else if (member.Agent.Task != member.Patrol) - member.Agent.Task = member.Patrol; + else if (member.Agent.Task != member.Baseline) + member.Agent.Task = member.Baseline; } private static void Aim(Ship ship, Entity target) diff --git a/Assets/Scripts/ServerShared/RunStart.cs b/Assets/Scripts/ServerShared/RunStart.cs index c9c287a3c..cce2ab977 100644 --- a/Assets/Scripts/ServerShared/RunStart.cs +++ b/Assets/Scripts/ServerShared/RunStart.cs @@ -53,10 +53,7 @@ public static class RunStart var hostile = placed.Stance == ScenarioStance.Hostile; placed.Entity.SetIff(player, hostile); player.SetIff(placed.Entity, hostile); - arena.Admit(placed.Entity, placed.Piloted); - // A stated patrol order replaces the circuit the zone drew for the pilot it just admitted. - if (placed.Circuit != null) - ((PatrolOrbitsTask) arena.Agents.Last(agent => ReferenceEquals(agent.Ship, placed.Entity)).Task).Circuit = placed.Circuit; + arena.Admit(placed.Entity, placed.Piloted, placed.Task); } return new Staged { Player = player, Credits = stage.Credits, Entities = stage.Placed.Select(placed => placed.Entity).ToList() }; } diff --git a/Assets/Scripts/ServerShared/ScenarioStage.cs b/Assets/Scripts/ServerShared/ScenarioStage.cs index 735d40775..c9531e60f 100644 --- a/Assets/Scripts/ServerShared/ScenarioStage.cs +++ b/Assets/Scripts/ServerShared/ScenarioStage.cs @@ -49,7 +49,7 @@ public sealed class ScenarioStage public Entity Entity; public ScenarioStance Stance; public bool Piloted; - public CultRecordKey[] Circuit; + public AgentTask Task; } // A hull fitted slot by slot: each slot a design or a product, the hull cell it goes in, and its rotation. A name is @@ -136,15 +136,16 @@ public sealed class ScenarioStage return entity; } - // The patrol order a piloted entity starts on: the one orbit at this index of the arena's orbits, which a galaxy seed - // fixes. A check that rests on where a pilot goes states it here, so the pilot's circuit is not a draw. An entity that - // is not placed and piloted, or an index past the orbits, is a failure. - public void Patrol(Entity entity, int orbit) + // The task a piloted entity starts on: it closes on the target and holds there (the flight's follow task, standoff + // nothing), in place of the patrol circuit the zone would draw for it. A check that rests on where a pilot goes states + // it here, so the pilot's course is the scenario's and not a draw. An entity that is not placed and piloted, or a + // target that is not placed, is a failure. + public void Approach(Entity entity, Entity target) { var placement = _placed.FirstOrDefault(p => ReferenceEquals(p.Entity, entity)); - if (placement == null || !placement.Piloted) { _failures.Add($"patrol: {entity?.Name ?? "no entity"} is not a placed, piloted ship"); return; } - if (orbit < 0 || orbit >= Arena.Orbits.Count) { _failures.Add($"patrol: the arena has no orbit {orbit} (it has {Arena.Orbits.Count})"); return; } - placement.Circuit = new[] { Arena.Orbits.Keys.ElementAt(orbit) }; + if (placement == null || !placement.Piloted) { _failures.Add($"approach: {entity?.Name ?? "no entity"} is not a placed, piloted ship"); return; } + if (target == null) { _failures.Add("approach: no target to close on"); return; } + placement.Task = new FollowTask { Anchor = target, Standoff = 0f }; } // Items in the entity's first cargo bay, one per name. A name is an equippable or consumable design (open: the stage diff --git a/Assets/Scripts/ServerShared/Scenarios/LockOn.cs b/Assets/Scripts/ServerShared/Scenarios/LockOn.cs index 609e6b528..171b34688 100644 --- a/Assets/Scripts/ServerShared/Scenarios/LockOn.cs +++ b/Assets/Scripts/ServerShared/Scenarios/LockOn.cs @@ -12,26 +12,33 @@ public sealed class LockOn : Scenario // The hostile starts about 4000 m off, ahead and to port of the player, facing the player. At that range its passive // sensors hold no track of the player (the test asks the sim's own PassiveInfo against the detection threshold). The - // hostile closes, sees the player some fourteen seconds in and locks. Its flanking approach and the zone's pull carry it - // off the staged line (about 5 degrees by the lock on the merged tree), and the warning must point at where the hostile - // is at the lock, which the test checks against the live bearing. At Duel's 900 m (and at 600 m) it sees and locks - // within a second. + // hostile is ordered to close on the player, finds it and locks. The zone's pull carries it off the staged line, so the + // warning must point at where the hostile was when the paint was stamped, which the test checks against the poses of + // that tick. At Duel's 900 m (and at 600 m) it sees and locks within a second. public static readonly CultMath.float2 HostileAt = float2(-2000, 3450); - // The fit's lots are minted at this quality, and the hostile's patrol order is stated, so the lock follows from the - // staged situation and not from item draws or the pilot's drawn circuit (ruling scenario-stages-hostile-task). - // .8 and not Crossing's .6: the lock comes at the hostile's closest pass, where the warning's one-tick lag reads as bearing error - // (the test allows .5 degrees); at .6 the lock came at 880 m with .57, at .7 .48, at .8 .45 (942 m); at .2 to .5 and 1 no lock in 600 ticks. - const float StagedQuality = .8f; - // The orbit it patrols: the fourth of the arena's, which carries the hostile across the player's lock envelope (lock - // at about 35 s, closest 880 m; the other twelve, patrolled alone, do not lock it in 600 ticks). - const int PatrolOrbit = 3; + // The fit's lots are minted at this quality, the one Crossing and the other RunStart scenarios stage (the brief states no + // other), and the hostile's order is to close on the player, so the lock follows from the staged situation and not + // from item draws or the pilot's drawn circuit (ruling scenario-stages-hostile-task). + const float StagedQuality = .6f; + + private readonly CultMath.float2 _hostileAt; + private readonly float _quality; + + public LockOn() : this(HostileAt, StagedQuality) { } + + // The staged inputs, open to a test that moves each a little and asks that the scenario still hold. + internal LockOn(CultMath.float2 hostileAt, float quality) + { + _hostileAt = hostileAt; + _quality = quality; + } public override Galaxy Generate(GalaxyStage stage) => stage.Prelude(DemoTerminus.Cast); public override void Stage(ScenarioStage stage) { - var fighter = stage.Fit("Longinus", StagedQuality, + var fighter = stage.Fit("Longinus", _quality, ("Cockpit 2x2", int2(2, 6), None), ("Large Drive", int2(1, 0), Reversed), ("Large Drive", int2(3, 0), Reversed), @@ -49,8 +56,8 @@ public sealed class LockOn : Scenario ("Panopticon Prime", int2(1, 6), Clockwise), // Fire Control Array ("Store-All Plus", int2(2, 8), None)); // Cargo Bay - stage.Player(fighter, float2(0, 0), facing: float2(0, 1)); - var hostile = stage.Place(fighter, HostileAt, facing: normalize(-HostileAt), stance: ScenarioStance.Hostile, piloted: true); - stage.Patrol(hostile, PatrolOrbit); + var player = stage.Player(fighter, float2(0, 0), facing: float2(0, 1)); + var hostile = stage.Place(fighter, _hostileAt, facing: normalize(-_hostileAt), stance: ScenarioStance.Hostile, piloted: true); + stage.Approach(hostile, player); } } diff --git a/Assets/Scripts/ServerShared/Zone.cs b/Assets/Scripts/ServerShared/Zone.cs index 4fc40fc53..4db63be46 100644 --- a/Assets/Scripts/ServerShared/Zone.cs +++ b/Assets/Scripts/ServerShared/Zone.cs @@ -279,13 +279,14 @@ public class Zone // turret all join through here. A piloted entity gets the zone's Minion; an unpiloted one gets no agent at all. // Only a ship can be piloted. The death watch is installed here, for every join, whichever caller admits it. // An entity that is already a member is refused: it would hold a second watch and a second agent. - public void Admit(Entity entity, bool piloted) + // A piloted entity starts on the zone's drawn patrol circuit unless the caller states its task (a scenario's approach). + public void Admit(Entity entity, bool piloted, AgentTask task = null) { if (_entities.Contains(entity)) throw new InvalidOperationException("entity: already a member of this zone"); _entities.Add(entity); _deathWatches.Add(entity, entity.Death.Subscribe(_ => { DropLoot(entity); Remove(entity); entity.Deactivate(); })); entity.Activate(); - if (piloted) Agents.Add(CreateAgent((Ship) entity)); + if (piloted) Agents.Add(CreateAgent((Ship) entity, task)); } // The one removal from this zone (death, dock, jump): membership and its death watch leave together. False, and @@ -300,20 +301,23 @@ public class Zone return true; } - private Agent CreateAgent(Ship ship) + private Agent CreateAgent(Ship ship, AgentTask stated) { var key = ship.Faction ?? Unaffiliated; if (!_flights.TryGetValue(key, out var flight)) _flights[key] = flight = new Flight(ship.Faction?.Doctrine, _itemManager.GameplaySettings); var id = NextAgentId(); var agent = new Minion(ship, flight.Combatant) { Id = id }; - var task = new PatrolOrbitsTask(); - var dice = SimulationDice.For(CombatSeed, SimulationDice.PatrolStream, id); - task.Circuit = Orbits.OrderBy(_ => dice.NextFloat()).Take(4).Select(x => x.Key).ToArray(); - flight.Join(agent, task); + flight.Join(agent, stated ?? PatrolCircuit(id)); return agent; } + private PatrolOrbitsTask PatrolCircuit(uint id) + { + var dice = SimulationDice.For(CombatSeed, SimulationDice.PatrolStream, id); + return new PatrolOrbitsTask { Circuit = Orbits.OrderBy(_ => dice.NextFloat()).Take(4).Select(x => x.Key).ToArray() }; + } + public ZonePack PackZone() { return new ZonePack diff --git a/tests/Aetheria.Shared.Tests/LockOnScenarioTests.cs b/tests/Aetheria.Shared.Tests/LockOnScenarioTests.cs index 0e326d7b0..603a6bea0 100644 --- a/tests/Aetheria.Shared.Tests/LockOnScenarioTests.cs +++ b/tests/Aetheria.Shared.Tests/LockOnScenarioTests.cs @@ -33,8 +33,25 @@ public sealed partial class RunStartTests var settled = hostile.PassiveInfo(player.Position.xz, player.Visibility); Assert.True(settled <= threshold, $"the hostile would settle at {settled} on the player, above the detection threshold {threshold}: staged inside its sight"); + var (lockedAt, bearingError, stagedDrift, strengths) = StepToLock(arena, player, hostile, toPlayer); + Assert.True(lockedAt >= 0, "the hostile never locked the player within 600 ticks of .1 s"); + Assert.True(bearingError <= StampedBearingLimit, $"the warning points at the hostile where it was when stamped, {bearingError} deg off (the hostile is {stagedDrift} deg off its staged line at the lock)"); + Assert.True(strengths.First() < strengths.Last(), $"the lock tightens: Strength went {strengths.First()} to {strengths.Last()}"); + } + + // Float error in the stamped pose and the normalizations, not a lag budget: the warning is exact for the tick it was stamped in. + const float StampedBearingLimit = .05f; + + // The paint is stamped from the poses at the end of one tick and published at the start of the next (an entity's inbox + // publishes a tick late, so the order of the entities does not matter), so the warning first read is measured against + // the poses of the tick before: where the hostile was when the paint was stamped, not where it is now. Steps up to 600 + // ticks of .1 s, and 40 past the lock. lockedAt is -1 when it never locks. + private static (int lockedAt, float bearingError, float stagedDrift, List strengths) StepToLock(Zone arena, Ship player, Entity hostile, CultMath.float2 toPlayer) + { + var hostileThen = hostile.Position.xz; + var playerThen = player.Position.xz; var lockedAt = -1; - var bearingDot = 0f; + var bearingError = 0f; var stagedDrift = 0f; var strengths = new List(); for (var tick = 0; tick < 600 && (lockedAt < 0 || tick < lockedAt + 40); tick++) @@ -45,16 +62,40 @@ public sealed partial class RunStartTests if (lockedAt < 0) { lockedAt = tick; - // The warning points at the hostile where it is at the lock; the hostile has left the staged line by then. - var live = normalize(hostile.Position.xz - player.Position.xz); - bearingDot = dot(normalize(paint.Bearing), live); - stagedDrift = degrees(acos(clamp(dot(live, -toPlayer), -1f, 1f))); + var stamped = normalize(hostileThen - playerThen); + bearingError = degrees(acos(clamp(dot(normalize(paint.Bearing), stamped), -1f, 1f))); + stagedDrift = degrees(acos(clamp(dot(stamped, -toPlayer), -1f, 1f))); } strengths.Add(paint.Strength); } + hostileThen = hostile.Position.xz; + playerThen = player.Position.xz; + } + return (lockedAt, bearingError, stagedDrift, strengths); + } + + // The staged inputs, each moved 1%: the lock and the warning's bearing still hold, so the scenario does not rest on the + // exact numbers it was written with. Kills: a pass geometry that only the staged numbers reach. + [Fact] + public void LockOnHoldsUnderOnePercentOfEachStagedInput() + { + var at = LockOn.HostileAt; + var variants = new (string what, LockOn scenario)[] + { + ("staged", new LockOn()), + ("x +1%", new LockOn(float2(at.x * 1.01f, at.y), .6f)), ("x -1%", new LockOn(float2(at.x * .99f, at.y), .6f)), + ("y +1%", new LockOn(float2(at.x, at.y * 1.01f), .6f)), ("y -1%", new LockOn(float2(at.x, at.y * .99f), .6f)), + ("quality +1%", new LockOn(at, .6f * 1.01f)), ("quality -1%", new LockOn(at, .6f * .99f)) + }; + foreach (var (what, scenario) in variants) + { + var (_, arena, staged, failures) = Launch(scenario, Inputs(() => GalaxySeed)); + Assert.True(failures.Count == 0, $"{what}: {string.Join("; ", failures)}"); + var hostile = Assert.Single(staged.Entities); + arena.Update(.1f); + var (lockedAt, bearingError, _, _) = StepToLock(arena, staged.Player, hostile, normalize(staged.Player.Position.xz - hostile.Position.xz)); + Assert.True(lockedAt >= 0, $"{what}: the hostile never locked the player within 600 ticks"); + Assert.True(bearingError <= StampedBearingLimit, $"{what}: the warning is {bearingError} deg off the pose it was stamped from"); } - Assert.True(lockedAt >= 0, "the hostile never locked the player within 600 ticks of .1 s"); - Assert.True(bearingDot >= cos(radians(.5f)), $"the warning points at the hostile where it is (the hostile is {stagedDrift} deg off its staged line at the lock)"); - Assert.True(strengths.First() < strengths.Last(), $"the lock tightens: Strength went {strengths.First()} to {strengths.Last()}"); } } From 05417f832eb3a1adacf659659b1a5163dea01e9c Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 18 Oct 2026 00:53:56 +0200 Subject: [PATCH 23/25] Tests: the role ceiling has no floor and no tolerance band; a product's own assembly replaces the maker's spread too Pins the survivors soul-cap-assembly-floored, soul-cap-tolerance-band and soul-product-override-mean-only of verdict s1. Co-Authored-By: Claude Opus 5.5 --- .../AssemblyFromMakerTests.cs | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/Aetheria.Shared.Tests/AssemblyFromMakerTests.cs b/tests/Aetheria.Shared.Tests/AssemblyFromMakerTests.cs index 90f3fae04..efc1e1b3a 100644 --- a/tests/Aetheria.Shared.Tests/AssemblyFromMakerTests.cs +++ b/tests/Aetheria.Shared.Tests/AssemblyFromMakerTests.cs @@ -151,6 +151,39 @@ public sealed class AssemblyFromMakerTests : IDisposable Assert.Equal(.9f, over.Roles.Single().Quality, 3); } + // The ceiling is the assembly itself at every height and to the last digit: a poor assembler (below any floor) still caps a + // good part at its own quality, a part just above the assembly reads the assembly and not its own, and a part at or below it + // keeps its own. + [Fact] + public void RoleCeilingHasNoFloorAndNoToleranceBand() + { + float Role(float assembly, float part) => + _items.Lots[_items.CreateLot(Product($"A{assembly}P{part}", new Faction { Name = $"Maker {assembly}/{part}", Assembly = A(assembly, 0) }, part))].QualityForRole("lens"); + Assert.Equal(.1f, Role(.1f, .9f), 3); + Assert.Equal(.02f, Role(.02f, .5f), 3); + Assert.Equal(.4f, Role(.4f, .41f), 3); + Assert.Equal(.4f, Role(.4f, .43f), 3); + Assert.Equal(.4f, Role(.4f, .4f), 3); + Assert.Equal(.39f, Role(.4f, .39f), 3); + } + + // The line's own final test replaces the maker's whole distribution, spread included: a maker of no spread and a product + // of a wide one mint a wide spread, and the reverse mints none. + [Fact] + public void ProductAssemblyOverridesMakersSpreadToo() + { + var steady = new Faction { Name = "Steady", Assembly = A(.5f, 0) }; + var wild = Product("Wild", steady, .5f); + wild.Assembly = A(.5f, .2f); + var wildLots = Mint(wild, 400); + Assert.InRange(Math.Sqrt(wildLots.Select(q => Math.Pow(q - wildLots.Average(), 2)).Average()), .15, .25); + + var loose = new Faction { Name = "Loose", Assembly = A(.5f, .2f) }; + var tight = Product("Tight", loose, .5f); + tight.Assembly = A(.5f, 0); + Assert.All(Mint(tight, 50), q => Assert.Equal(.5f, q, 3)); + } + // The fallbacks still read the assembly: an unnamed role, an unrolled role, and a lot with no roles. [Fact] public void FallbacksReadTheAssembly() From 997172af17b21369ff9619666656de50bc812520 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 18 Oct 2026 00:54:00 +0200 Subject: [PATCH 24/25] Tests: the assembly derive rule at fifteen part means and across products, not at the fixtures' two Pins the survivors soul-derive-quadratic-agrees-on-fixtures and soul-derive-floored-mean of verdict s1. Co-Authored-By: Claude Opus 5.5 --- .../AssemblyFromMakerCommandTests.cs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/Aetheria.Shared.Tests/AssemblyFromMakerCommandTests.cs b/tests/Aetheria.Shared.Tests/AssemblyFromMakerCommandTests.cs index 504b25120..76ac5c865 100644 --- a/tests/Aetheria.Shared.Tests/AssemblyFromMakerCommandTests.cs +++ b/tests/Aetheria.Shared.Tests/AssemblyFromMakerCommandTests.cs @@ -92,6 +92,29 @@ public sealed class AssemblyFromMakerCommandTests : IDisposable Assert.Null(Maker("Bystander").Assembly); } + // The rule is part mean plus the margin, capped at 1, rounded to 2 dp, at every part mean and not only at the catalog + // fixtures: a one-role product at each, then two products whose roles weigh by role count, and the deviation the plain + // mean of the roles' (not their maximum). + [Fact] + public void DeriveIsPartMeanPlusMarginAtEveryMean() + { + FactionProductData Product(params (float mean, float deviation)[] roles) => + new FactionProductData { Roles = roles.Select((r, i) => new ProductRole { Role = "r" + i, Mean = r.mean, StandardDeviation = r.deviation }).ToList() }; + + foreach (var mean in new[] { .02f, .05f, .12f, .2f, .31f, .38f, .44f, .57f, .63f, .71f, .79f, .86f, .9f, .93f, .99f }) + { + var derived = AssemblyFromMakerCommand.Derive(new[] { Product((mean, .13f)) }); + Assert.Equal(Math.Round(Math.Min(1, mean + AssemblyFromMakerCommand.Margin), 2), derived.Mean, 3); + Assert.Equal(.13f, derived.StandardDeviation, 3); + } + + // (.1 + .3 + .8) / 3 = .4 -> .5, and (.02 + .3 + .4) / 3 = .24. + var weighed = AssemblyFromMakerCommand.Derive(new[] { Product((.1f, .02f)), Product((.3f, .3f), (.8f, .4f)) }); + Assert.Equal(.5f, weighed.Mean, 3); + Assert.Equal(.24f, weighed.StandardDeviation, 3); + Assert.Null(AssemblyFromMakerCommand.Derive(new[] { Product() })); + } + // A value tuned in Studio survives every replay, a dry run writes nothing, and a second apply has nothing to do. [Fact] public void AuthoredAssemblyIsKept() From a899432d46742542161da6140d4145db402499f2 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 18 Oct 2026 00:54:01 +0200 Subject: [PATCH 25/25] Tests: the AI streams in both directions; sampling and admitting take nothing from the item stream, and each pilot's circuit is its own Pins the survivors soul-ai-consumes-item-stream and soul-patrol-same-for-every-pilot of verdict s1. Co-Authored-By: Claude Opus 5.5 --- .../Aetheria.Shared.Tests/ConsumableAiTests.cs | 14 ++++++++++++++ .../FireControlPerWeaponTests.cs | 7 +++++++ tests/Aetheria.Shared.Tests/ScenarioTests.cs | 17 +++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/tests/Aetheria.Shared.Tests/ConsumableAiTests.cs b/tests/Aetheria.Shared.Tests/ConsumableAiTests.cs index de982bf86..6ad889fda 100644 --- a/tests/Aetheria.Shared.Tests/ConsumableAiTests.cs +++ b/tests/Aetheria.Shared.Tests/ConsumableAiTests.cs @@ -339,6 +339,20 @@ public sealed class ConsumableAiTests : IDisposable Assert.True(s.Zone.Agents.Last(a => ReferenceEquals(a.Ship, s.Agent)).Id > first, "a re-admitted pilot is a new id"); } + // Admitting a pilot takes nothing from the item stream: its patrol circuit is its own draw, so how pilots are chosen never + // moves what is minted next. Kills: the circuit drawn from ItemManager.Random. + [Fact] + public void AdmittingAPilotDrawsNothingFromTheItemStream() + { + var s = Build(carryOverdrive: true); + Assert.True(s.Zone.Remove(s.Agent)); + s.Agent.Deactivate(); + var items = s.Agent.ItemManager; + var before = items.Random; + s.Zone.Admit(s.Agent, piloted: true); + Assert.Equal(before.NextFloat(), items.Random.NextFloat()); + } + // The production path for the optimum: a ship the zone admits as piloted derives it from its gun's live stats // before it needs it, and re-derives it when its loadout changes. The gun's effective range is 500 and the // heavy gun's is 800, so the optimum moves with the weapons it has now. diff --git a/tests/Aetheria.Shared.Tests/FireControlPerWeaponTests.cs b/tests/Aetheria.Shared.Tests/FireControlPerWeaponTests.cs index 90e142b3c..bbd57c7ac 100644 --- a/tests/Aetheria.Shared.Tests/FireControlPerWeaponTests.cs +++ b/tests/Aetheria.Shared.Tests/FireControlPerWeaponTests.cs @@ -811,6 +811,13 @@ public sealed class FireControlPerWeaponTests : IDisposable var cells = (Optimum(id, 0) - offset - min) / step; Assert.True(MathF.Abs(cells - MathF.Round(cells)) < .01f, $"id {id}: optimum is {cells} steps from the pilot's own offset"); } + + // The other direction: sampling the optimum takes nothing from the item stream, so how a pilot fights never moves + // what is minted next. Kills: an AI draw from ItemManager.Random. + var items = r.Shooter.ItemManager; + var before = items.Random; + Optimum(5, 0); + Assert.Equal(before.NextFloat(), items.Random.NextFloat()); } // A round refused on a Range that fell between the trigger and the round is still free: the burst is paid diff --git a/tests/Aetheria.Shared.Tests/ScenarioTests.cs b/tests/Aetheria.Shared.Tests/ScenarioTests.cs index fe457bbd6..314132459 100644 --- a/tests/Aetheria.Shared.Tests/ScenarioTests.cs +++ b/tests/Aetheria.Shared.Tests/ScenarioTests.cs @@ -319,6 +319,23 @@ public sealed partial class RunStartTests Assert.Equal(Places(plain), Places(disturbed)); } + // Each pilot's circuit is keyed by its own id: three pilots admitted into one zone do not all patrol the same orbits. + // Kills: the circuit keyed by a constant. + [Fact] + public void EachPilotsPatrolCircuitIsItsOwn() + { + var (_, arena, _, failures) = Launch(new Scripted(false, stage => + { + stage.Player(stage.Bare("Djinni"), float2(0, 0)); + for (var i = 0; i < 3; i++) + stage.Place(stage.Generated("Longinus"), float2(300 + 40 * i, 0), stance: ScenarioStance.Hostile, piloted: true); + })); + Assert.True(failures.Count == 0, string.Join("; ", failures)); + var circuits = arena.Agents.Select(agent => string.Join(",", ((PatrolOrbitsTask) agent.Task).Circuit.Select(key => arena.Orbits.Keys.ToList().IndexOf(key)))).ToArray(); + Assert.Equal(3, circuits.Length); + Assert.True(circuits.Distinct().Count() > 1, "every pilot patrols the same orbits: " + string.Join(" | ", circuits)); + } + // A fit that states its quality mints every lot it builds at it, assembly and role fills alike; the same fit without one // draws them from the item stream, so some lot comes out otherwise. A scenario's checks rest on the first. [Fact]