diagnostic: Jet hit_log确认3/6云命中(56m步跳过3个),TimeScale默认改回1
This commit is contained in:
parent
3aac0060e7
commit
47761e5124
@ -47,6 +47,7 @@ namespace CounterDrone.Core.Simulation
|
|||||||
private readonly List<FireEvent> _fireSchedule = new();
|
private readonly List<FireEvent> _fireSchedule = new();
|
||||||
private int _nextFireIndex;
|
private int _nextFireIndex;
|
||||||
private readonly List<SimEvent> _allEvents = new();
|
private readonly List<SimEvent> _allEvents = new();
|
||||||
|
private System.Text.StringBuilder _hitLog = new();
|
||||||
private SQLiteConnection _frameDb = null!;
|
private SQLiteConnection _frameDb = null!;
|
||||||
private string _taskId = string.Empty;
|
private string _taskId = string.Empty;
|
||||||
private readonly IDefensePlanner _planner;
|
private readonly IDefensePlanner _planner;
|
||||||
@ -128,6 +129,8 @@ namespace CounterDrone.Core.Simulation
|
|||||||
_munitions.Clear();
|
_munitions.Clear();
|
||||||
_clouds.Clear();
|
_clouds.Clear();
|
||||||
_allEvents.Clear();
|
_allEvents.Clear();
|
||||||
|
_hitLog.Clear();
|
||||||
|
_hitLog.AppendLine("droneX,droneY,cloudX,cloudY,dist,radius,inside");
|
||||||
FrameIndex = 0;
|
FrameIndex = 0;
|
||||||
SimulationTime = 0;
|
SimulationTime = 0;
|
||||||
_entityCounter = 0;
|
_entityCounter = 0;
|
||||||
@ -244,7 +247,13 @@ namespace CounterDrone.Core.Simulation
|
|||||||
{
|
{
|
||||||
foreach (var cloud in _clouds)
|
foreach (var cloud in _clouds)
|
||||||
{
|
{
|
||||||
if (cloud.ContainsPoint(drone.PosX, drone.PosY, drone.PosZ))
|
var dx = drone.PosX - cloud.Dispersion.Center.X;
|
||||||
|
var dy = drone.PosY - cloud.Dispersion.Center.Y;
|
||||||
|
var dz = drone.PosZ - cloud.Dispersion.Center.Z;
|
||||||
|
var dist = (float)System.Math.Sqrt(dx * dx + dy * dy + dz * dz);
|
||||||
|
bool inside = dist <= cloud.Dispersion.EffectiveRadius;
|
||||||
|
_hitLog.AppendLine($"{drone.PosX:F1},{drone.PosY:F1},{cloud.Dispersion.Center.X:F1},{cloud.Dispersion.Center.Y:F1},{dist:F1},{cloud.Dispersion.EffectiveRadius:F1},{inside}");
|
||||||
|
if (inside)
|
||||||
{
|
{
|
||||||
drone.ExposureTime += scaledDt;
|
drone.ExposureTime += scaledDt;
|
||||||
var dmg = _damageModel.CalculateDamage(drone.TargetType, drone.PowerType, cloud.AerosolType, cloud.Dispersion.CoreDensity, drone.ExposureTime, scaledDt);
|
var dmg = _damageModel.CalculateDamage(drone.TargetType, drone.PowerType, cloud.AerosolType, cloud.Dispersion.CoreDensity, drone.ExposureTime, scaledDt);
|
||||||
@ -257,6 +266,8 @@ namespace CounterDrone.Core.Simulation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (_hitLog.Length > 0 && SimulationTime >= 120)
|
||||||
|
System.IO.File.WriteAllText(@"C:\Users\Tellme\Desktop\hit_log.csv", _hitLog.ToString());
|
||||||
|
|
||||||
// 5. 无人机移动
|
// 5. 无人机移动
|
||||||
foreach (var drone in _drones.Where(d => d.Status == DroneStatus.Flying))
|
foreach (var drone in _drones.Where(d => d.Status == DroneStatus.Flying))
|
||||||
|
|||||||
@ -47,7 +47,7 @@ namespace CounterDrone.Core.Tests
|
|||||||
if (Directory.Exists(_testDir)) Directory.Delete(_testDir, true);
|
if (Directory.Exists(_testDir)) Directory.Delete(_testDir, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SimulationEngine RunSimulation(int maxTicks, float tickDt = 1f / 20f, float timeScale = 8f)
|
private SimulationEngine RunSimulation(int maxTicks, float tickDt = 1f / 20f, float timeScale = 1f)
|
||||||
{
|
{
|
||||||
var engine = new SimulationEngine(_scenario, _frameStore, new DamageModelRouter(), _paths, new DefaultDefensePlanner(_ammoCatalog));
|
var engine = new SimulationEngine(_scenario, _frameStore, new DamageModelRouter(), _paths, new DefaultDefensePlanner(_ammoCatalog));
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user