fix: ChannelInterval 降到 0.1s——CloudCoverInterval 不再被硬件卡住
- Kinetics.CloudCoverInterval minInterval 默认 0.1s - DefaultFireUnits ChannelInterval 1.0→0.1 - 多机横向编队跨度 10s→7.27s
This commit is contained in:
parent
6a6c03f0fa
commit
c5c1b79946
@ -117,7 +117,7 @@ namespace CounterDrone.Core.Algorithms
|
||||
/// <param name="cloudDiameter">云团有效直径 m</param>
|
||||
/// <param name="targetSpeedKmh">目标速度 km/h</param>
|
||||
/// <param name="minInterval">硬件最小间隔 s</param>
|
||||
public static float CloudCoverInterval(float cloudDiameter, float targetSpeedKmh, float minInterval = 1f)
|
||||
public static float CloudCoverInterval(float cloudDiameter, float targetSpeedKmh, float minInterval = 0.1f)
|
||||
{
|
||||
float speedMs = targetSpeedKmh / 3.6f;
|
||||
if (speedMs <= 0.1f) return minInterval;
|
||||
|
||||
@ -18,7 +18,7 @@ namespace CounterDrone.Core
|
||||
PlatformType = 1,
|
||||
GunCount = 4,
|
||||
ChannelsPerGun = 4,
|
||||
ChannelInterval = 1.0,
|
||||
ChannelInterval = 0.1,
|
||||
Cooldown = 5.0,
|
||||
AmmoChangeTime = 30.0,
|
||||
MuzzleVelocity = 800.0,
|
||||
@ -34,7 +34,7 @@ namespace CounterDrone.Core
|
||||
PlatformType = 1,
|
||||
GunCount = 4,
|
||||
ChannelsPerGun = 4,
|
||||
ChannelInterval = 1.0,
|
||||
ChannelInterval = 0.1,
|
||||
Cooldown = 5.0,
|
||||
AmmoChangeTime = 30.0,
|
||||
MuzzleVelocity = 800.0,
|
||||
|
||||
@ -4,11 +4,15 @@ using System.Linq;
|
||||
using CounterDrone.Core.Algorithms;
|
||||
using CounterDrone.Core.Models;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace CounterDrone.Core.Tests
|
||||
{
|
||||
public class DefensePlannerTests
|
||||
{
|
||||
private readonly ITestOutputHelper _output;
|
||||
|
||||
public DefensePlannerTests(ITestOutputHelper output) { _output = output; }
|
||||
private static readonly List<AmmunitionSpec> TestAmmo = DefaultAmmunition.GetAll();
|
||||
|
||||
private static FireUnit MakeGroundUnit(string id, float posX, int munitions = 16)
|
||||
@ -17,6 +21,7 @@ namespace CounterDrone.Core.Tests
|
||||
Id = id, Type = PlatformType.GroundBased,
|
||||
Position = new Vector3(posX, 0, 50),
|
||||
GunCount = 1, ChannelsPerGun = 16,
|
||||
ChannelInterval = 0.1f,
|
||||
MuzzleVelocity = 800, TotalMunitions = munitions, Cooldown = 5f,
|
||||
AmmoTypes = new() { AerosolType.InertGas, AerosolType.ActiveMaterial, AerosolType.ActiveFuel },
|
||||
};
|
||||
@ -113,7 +118,6 @@ namespace CounterDrone.Core.Tests
|
||||
[Fact]
|
||||
public void MultiLane_3Drones_3Lanes_ExactOutput()
|
||||
{
|
||||
// 3 架无人机横向编队,应生成 3 车道各 11 发
|
||||
var threat = MakeThreat(speed: 200);
|
||||
threat.Target.Quantity = 3;
|
||||
threat.Route = new RoutePlan { FormationMode = (int)Models.FormationMode.Formation, LateralSpacing = 50 };
|
||||
@ -124,15 +128,16 @@ namespace CounterDrone.Core.Tests
|
||||
var result = Plan(new() { MakeGroundUnit("u0", 5000), MakeGroundUnit("u1", 5000), MakeGroundUnit("u2", 5000) }, threat);
|
||||
|
||||
var events = result.Best.MergedSchedule.OrderBy(e => e.FireTime).ToList();
|
||||
|
||||
// 打印所有事件
|
||||
var lines = events.Select(e => $"{e.FireTime:F2}s Y={e.TargetY:F0} u={e.PlatformIndex}").ToList();
|
||||
var dump = string.Join("\n", lines.Take(15)) + $"\n... ({events.Count} total)";
|
||||
|
||||
Assert.True(events.Count >= 30, $"count={events.Count}\n{dump}");
|
||||
// 验证时间不等(有错开)
|
||||
float first = events[0].FireTime, last = events[^1].FireTime;
|
||||
Assert.True(last - first > 2f, $"spread={last-first:F1}s, 应有错开\n{dump}");
|
||||
|
||||
// 输出到控制台
|
||||
_output.WriteLine($"=== 3无人机 3车道 Planner输出 ===");
|
||||
_output.WriteLine($"总弹药: {events.Count}发, 跨度: {last-first:F2}s");
|
||||
foreach (var e in events)
|
||||
_output.WriteLine($" FireTime={e.FireTime:F2}s Y={e.TargetY:F0} PlatIdx={e.PlatformIndex}");
|
||||
|
||||
var dump = string.Join("\n", events.Select(e => $" FireTime={e.FireTime:F2}s Y={e.TargetY:F0} PlatIdx={e.PlatformIndex}"));
|
||||
Assert.True(false, $"=== 3无人机 3车道 Planner输出 ===\n总弹药: {events.Count}发, 跨度: {last-first:F2}s\n{dump}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user