Arcs player gets a bay; Arcs and Pursuit crates sized from a measured run
The Arcs fighter had no hold, so its Autocannon and Cell Blasters went silent after one magazine: it now fits the one free 2x2 bay. The estimated crate counts are replaced by measured draws (ten minutes of play or death by heat) plus margin, authored for every ammunition-drawing shooter; ScenarioAmmunitionRunTests drives both scenarios and fails if any shooter is stocked below its measured draw. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
dcd27cb3b0
commit
465ab50666
3 changed files with 121 additions and 8 deletions
|
|
@ -21,7 +21,10 @@ public sealed class Arcs : Scenario
|
|||
public static readonly CultMath.float2 Bow = float2(0, 400), Stern = float2(0, -400), Turret = float2(600, 300),
|
||||
Port = float2(-400, 0), Starboard = float2(400, 0);
|
||||
|
||||
public const int TurretAmmoCrates = 30;
|
||||
// Crates of ammunition each shooter's hold is stocked with: the measured draw over a run (ScenarioAmmunitionRunTests: ten minutes of play,
|
||||
// or until the shooter dies of heat) plus half again and one. The turret drew 14 Ammo with the player in its range; the player drew 27 Ammo
|
||||
// holding every gun down. The guided launchers fire only on a lock, which that run cannot give them, so they carry the default three crates.
|
||||
public const int TurretAmmoCrates = 22, PlayerAmmoCrates = 42, PlayerMissileCrates = 3;
|
||||
|
||||
public override Galaxy Generate(GalaxyStage stage) => stage.Prelude();
|
||||
|
||||
|
|
@ -43,7 +46,8 @@ public sealed class Arcs : Scenario
|
|||
("not if i see you first", int2(5, 10), None), // Compact Sensor
|
||||
("Panopticon Prime", int2(3, 6), Clockwise), // Fire Control Array
|
||||
("🫳🔫", int2(8, 4), Clockwise), // Autocannon
|
||||
("ChargeBlast SG", int2(0, 4), CounterClockwise)); // Charged Scatter Blaster
|
||||
("ChargeBlast SG", int2(0, 4), CounterClockwise), // Charged Scatter Blaster
|
||||
("Store-All Plus", int2(4, 8), None)); // Cargo Bay: the only 2x2 the hull has free
|
||||
var turret = stage.Fit("Turret",
|
||||
("ClearPath", int2(1, 2), None), // Light Machine Gun
|
||||
("ClearPath", int2(5, 2), None), // Light Machine Gun
|
||||
|
|
@ -55,10 +59,11 @@ public sealed class Arcs : Scenario
|
|||
("Panopticon Prime", int2(3, 6), None), // Fire Control Array
|
||||
("Store-All Plus", int2(3, 1), None)); // Cargo Bay: the only 2x2 the turret hull has free
|
||||
|
||||
stage.Player(fighter, float2(0, 0), facing: float2(0, 1));
|
||||
var player = stage.Player(fighter, float2(0, 0), facing: float2(0, 1));
|
||||
stage.Cargo(player, Enumerable.Repeat("Ammo", PlayerAmmoCrates).Concat(Enumerable.Repeat("Missiles", PlayerMissileCrates)).ToArray());
|
||||
stage.Place(stage.Bare("Longinus"), Bow);
|
||||
stage.Place(stage.Bare("Longinus"), Stern);
|
||||
// The turret's guns reload from its hold, a crate of Ammo per 100-round magazine: both guns firing without pause spend about 3.5 crates a minute, so 30 outlast any session.
|
||||
// The turret's guns reload from its hold, a crate of Ammo per magazine.
|
||||
stage.Cargo(stage.Place(turret, Turret, stance: ScenarioStance.Hostile), Enumerable.Repeat("Ammo", TurretAmmoCrates).ToArray());
|
||||
stage.Place(stage.Bare("Longinus"), Port);
|
||||
stage.Place(stage.Bare("Longinus"), Starboard);
|
||||
|
|
|
|||
|
|
@ -8,7 +8,11 @@ public sealed class Pursuit : Scenario
|
|||
// cloud breaking a sensor's lock, and well outside the 40 at which AStrongCloseSensorBurnsThrough shows a close
|
||||
// sensor burning through.
|
||||
private const float Astern = 300;
|
||||
public const int MineCrates = 10;
|
||||
// Crates each shooter's hold is stocked with: the measured draw over a run (ScenarioAmmunitionRunTests: ten minutes of play, or until the
|
||||
// shooter dies of heat) plus half again and one where the hold has room. The player laid four crates of Mines and drew
|
||||
// 33 Ammo; its hold takes 54 crates after five consumables and Mines, so its Ammo stops at 39. The pursuer drew 31 Ammo and one Missiles. A launcher
|
||||
// that drew under a reload carries the default three crates.
|
||||
public const int MineCrates = 7, PlayerAmmoCrates = 39, PlayerMissileCrates = 3, PursuerAmmoCrates = 47, PursuerMissileCrates = 3;
|
||||
|
||||
public override string Name => "Pursuit";
|
||||
public override string Id => "pursuit";
|
||||
|
|
@ -57,8 +61,9 @@ public sealed class Pursuit : Scenario
|
|||
("Store-All Plus", int2(2, 8), None)); // Cargo Bay
|
||||
|
||||
var player = stage.Player(layer, float2(0, 0), facing: float2(0, 1));
|
||||
// The Mine Launcher reloads a magazine of six from a crate of Mines: ten crates are sixty-six mines, minutes of laying at its cooldown, more than a chase lasts.
|
||||
stage.Cargo(player, new[] { "Morning Fog", "Morning Fog", "Morning Fog", "send it", "send it" }.Concat(Enumerable.Repeat("Mines", MineCrates)).ToArray());
|
||||
stage.Place(pursuer, float2(0, -Astern), facing: float2(0, 1), stance: ScenarioStance.Hostile, piloted: true);
|
||||
stage.Cargo(player, new[] { "Morning Fog", "Morning Fog", "Morning Fog", "send it", "send it" }
|
||||
.Concat(Enumerable.Repeat("Mines", MineCrates)).Concat(Enumerable.Repeat("Ammo", PlayerAmmoCrates)).Concat(Enumerable.Repeat("Missiles", PlayerMissileCrates)).ToArray());
|
||||
var hostile = stage.Place(pursuer, float2(0, -Astern), facing: float2(0, 1), stance: ScenarioStance.Hostile, piloted: true);
|
||||
stage.Cargo(hostile, Enumerable.Repeat("Ammo", PursuerAmmoCrates).Concat(Enumerable.Repeat("Missiles", PursuerMissileCrates)).ToArray());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
103
tests/Aetheria.Shared.Tests/ScenarioAmmunitionRunTests.cs
Normal file
103
tests/Aetheria.Shared.Tests/ScenarioAmmunitionRunTests.cs
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using GameCult.Caching;
|
||||
using Xunit;
|
||||
|
||||
// How much ammunition a staged scenario really spends over a run (ruling ballistics-real-ammo): the crates a scenario authors are pinned to
|
||||
// this measurement, not to an estimate. A run is RunSeconds of continuous play: the player holds every ammunition-drawing weapon down with its
|
||||
// hostile-or-flank hull standing in weapon range, an AI shooter fires on its own, and every hull keeps its armour so no shooter or target leaves
|
||||
// the run early. The draw is counted in crates (one reload per crate) and each drawn crate is put back, so the count is not capped by the stock.
|
||||
public sealed partial class RunStartTests
|
||||
{
|
||||
// Ten minutes: longer than any session the Arcs and Pursuit briefs ask a tester for.
|
||||
public const float RunSeconds = 600f;
|
||||
|
||||
// Crates each armed entity of the scenario draws over the run, keyed by (index in the stage's entities, -1 for the player; ammunition name),
|
||||
// and the crates each held when the run began.
|
||||
private (Dictionary<(int, string), int> drawn, Dictionary<(int, string), int> stocked) RunAmmunition(Scenario scenario, bool playerFires, bool standNearHostile)
|
||||
{
|
||||
var (_, arena, staged, failures) = Launch(scenario, Inputs(() => GalaxySeed));
|
||||
Assert.Empty(failures);
|
||||
arena.Update(0);
|
||||
var shooters = staged.Entities.Select((entity, index) => (entity, index)).Append((staged.Player, -1))
|
||||
.Where(s => s.Item1.Weapons.Any(weapon => weapon.WeaponData.AmmoType.IsSet())).ToList();
|
||||
var drawn = new Dictionary<(int, string), int>();
|
||||
var stocked = new Dictionary<(int, string), int>();
|
||||
var held = new Dictionary<(int, string), int>();
|
||||
string NameOf(CultRecordKey key) => _items.ItemData.Get<SimpleCommodityData>(key).Name;
|
||||
foreach (var (entity, index) in shooters)
|
||||
foreach (var key in entity.Weapons.Where(weapon => weapon.WeaponData.AmmoType.IsSet()).Select(weapon => weapon.WeaponData.AmmoType.Key).Distinct())
|
||||
{
|
||||
stocked[(index, NameOf(key))] = entity.CountItemsInCargo(key);
|
||||
// A shooter with no crate cannot reload at all, so a run could not show what it would draw: it is given one to start.
|
||||
if (stocked[(index, NameOf(key))] == 0)
|
||||
entity.CargoBays.First().TryStore(new SimpleCommodity { Data = new CultRecordRef<ItemData>(key), Quantity = 1 });
|
||||
drawn[(index, NameOf(key))] = 0;
|
||||
held[(index, NameOf(key))] = entity.CountItemsInCargo(key);
|
||||
}
|
||||
var everyone = staged.Entities.Append(staged.Player).ToList();
|
||||
var player = staged.Player;
|
||||
var sound = everyone.SelectMany(entity => entity.Equipment).ToDictionary(item => item, item => item.EquippableItem.Durability);
|
||||
var hostile = standNearHostile ? staged.Entities.First(entity => player.IsHostileTo(entity)) : null;
|
||||
for (var tick = 0; tick < System.MathF.Round(RunSeconds / SimClock.GameStep); tick++)
|
||||
{
|
||||
foreach (var entity in everyone)
|
||||
for (var x = 0; x < entity.Armor.GetLength(0); x++)
|
||||
for (var y = 0; y < entity.Armor.GetLength(1); y++)
|
||||
entity.Armor[x, y] = entity.MaxArmor[x, y];
|
||||
foreach (var (item, durability) in sound) item.EquippableItem.Durability = durability;
|
||||
if (hostile != null) player.Position = hostile.Position + CultMath.math.float3(-200, 0, 0);
|
||||
if (playerFires)
|
||||
foreach (var weapon in player.Weapons.Where(weapon => weapon.WeaponData.AmmoType.IsSet())) weapon.Activate();
|
||||
arena.Update(SimClock.GameStep);
|
||||
if (false) System.IO.File.AppendAllText(System.Environment.GetEnvironmentVariable("TMPDIR") + "/dbg.txt", $"{scenario.Name} t={tick*SimClock.GameStep:F0} active={player.Active} me={player.Position} " + string.Join(",", player.Weapons.Select(w => w.WeaponData.AmmoType.IsSet() ? w.Ammo + "/" + w.Reserve : "e")) + "\n");
|
||||
foreach (var (entity, index) in shooters)
|
||||
foreach (var key in entity.Weapons.Where(weapon => weapon.WeaponData.AmmoType.IsSet()).Select(weapon => weapon.WeaponData.AmmoType.Key).Distinct())
|
||||
{
|
||||
var slot = (index, NameOf(key));
|
||||
var spent = held[slot] - entity.CountItemsInCargo(key);
|
||||
if (spent <= 0) continue;
|
||||
drawn[slot] += spent;
|
||||
for (var crate = 0; crate < spent; crate++)
|
||||
entity.CargoBays.First().TryStore(new SimpleCommodity { Data = new CultRecordRef<ItemData>(key), Quantity = 1 });
|
||||
}
|
||||
}
|
||||
return (drawn, stocked);
|
||||
}
|
||||
|
||||
// The most crates each shooter draws in any of the modes, and what it was stocked with.
|
||||
private List<(int shooter, string ammo, int drawn, int stocked)> WorstRun(Scenario scenario, params (bool playerFires, bool standNearHostile)[] modes)
|
||||
{
|
||||
var worst = new Dictionary<(int, string), (int drawn, int stocked)>();
|
||||
foreach (var (fires, near) in modes)
|
||||
{
|
||||
var (drawn, stocked) = RunAmmunition(scenario, fires, near);
|
||||
foreach (var slot in drawn.Keys)
|
||||
worst[slot] = (System.Math.Max(drawn[slot], worst.TryGetValue(slot, out var seen) ? seen.drawn : 0), stocked[slot]);
|
||||
}
|
||||
return worst.Select(kv => (kv.Key.Item1, kv.Key.Item2, kv.Value.drawn, kv.Value.stocked)).ToList();
|
||||
}
|
||||
|
||||
// Arcs, run to its end twice: the player holding every gun down, and the player standing in the hostile turret's range while the turret
|
||||
// shoots. Kills: a crate count nobody measured (the turret's 30 and the player's none were estimates), a scenario shooter stocked below
|
||||
// what a run draws so its guns go silent, and a harness that measures nothing.
|
||||
[Fact]
|
||||
public void ArcsStocksEveryShooterForARun()
|
||||
{
|
||||
var run = WorstRun(new Arcs(), (true, false), (false, true));
|
||||
Assert.Contains(run, r => r.shooter == 2 && r.ammo == "Ammo" && r.drawn > 0);
|
||||
Assert.Contains(run, r => r.shooter == -1 && r.ammo == "Ammo" && r.drawn > 0);
|
||||
Assert.All(run, r => Assert.True(r.stocked >= r.drawn, $"Arcs shooter {r.shooter} drew {r.drawn} {r.ammo} over a run and was stocked {r.stocked}"));
|
||||
}
|
||||
|
||||
// Pursuit, the player holding every gun down and the pursuer shooting back, then the player idle. Kills: as above, for the Mine Launcher's
|
||||
// crates and the pursuer's.
|
||||
[Fact]
|
||||
public void PursuitStocksEveryShooterForARun()
|
||||
{
|
||||
var run = WorstRun(new Pursuit(), (true, false), (false, false));
|
||||
Assert.Contains(run, r => r.shooter == -1 && r.ammo == "Mines" && r.drawn > 0);
|
||||
Assert.Contains(run, r => r.shooter == 0 && r.ammo == "Ammo" && r.drawn > 0);
|
||||
Assert.All(run, r => Assert.True(r.stocked >= r.drawn, $"Pursuit shooter {r.shooter} drew {r.drawn} {r.ammo} over a run and was stocked {r.stocked}"));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue