From c5c1b7994664e3cd2033d45bb7d1974f8123b3db Mon Sep 17 00:00:00 2001
From: tian <11429339@qq.com>
Date: Sat, 13 Jun 2026 14:24:11 +0800
Subject: [PATCH] =?UTF-8?q?fix:=20ChannelInterval=20=E9=99=8D=E5=88=B0=200?=
=?UTF-8?q?.1s=E2=80=94=E2=80=94CloudCoverInterval=20=E4=B8=8D=E5=86=8D?=
=?UTF-8?q?=E8=A2=AB=E7=A1=AC=E4=BB=B6=E5=8D=A1=E4=BD=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- Kinetics.CloudCoverInterval minInterval 默认 0.1s
- DefaultFireUnits ChannelInterval 1.0→0.1
- 多机横向编队跨度 10s→7.27s
---
.../Algorithms/Kinematics.cs | 2 +-
src/CounterDrone.Core/DefaultFireUnits.cs | 4 ++--
.../DefensePlannerTests.cs | 23 +++++++++++--------
3 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/src/CounterDrone.Core/Algorithms/Kinematics.cs b/src/CounterDrone.Core/Algorithms/Kinematics.cs
index bb70d03..a479490 100644
--- a/src/CounterDrone.Core/Algorithms/Kinematics.cs
+++ b/src/CounterDrone.Core/Algorithms/Kinematics.cs
@@ -117,7 +117,7 @@ namespace CounterDrone.Core.Algorithms
/// 云团有效直径 m
/// 目标速度 km/h
/// 硬件最小间隔 s
- 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;
diff --git a/src/CounterDrone.Core/DefaultFireUnits.cs b/src/CounterDrone.Core/DefaultFireUnits.cs
index b96ae13..19756d8 100644
--- a/src/CounterDrone.Core/DefaultFireUnits.cs
+++ b/src/CounterDrone.Core/DefaultFireUnits.cs
@@ -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,
diff --git a/test/unit/CounterDrone.Core.Tests/DefensePlannerTests.cs b/test/unit/CounterDrone.Core.Tests/DefensePlannerTests.cs
index 29ee7c2..a92f8b1 100644
--- a/test/unit/CounterDrone.Core.Tests/DefensePlannerTests.cs
+++ b/test/unit/CounterDrone.Core.Tests/DefensePlannerTests.cs
@@ -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 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]