Record energy loss and exercise meeting geometry
Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
@@ -2957,11 +2957,12 @@ impl Sim {
|
||||
fn step_missiles(&mut self, ground: &mut Ground, out: &mut Out) {
|
||||
let now = self.tick;
|
||||
let mut done: Vec<(u32, Option<u32>, bool, u32)> = Vec::new(); // (missile, target, kill, sam)
|
||||
let (mut missed, mut expired, mut orphaned) = (0u32, 0u32, 0u32);
|
||||
let (mut missed, mut expired, mut orphaned, mut energy_lost) = (0u32, 0u32, 0u32, 0u32);
|
||||
let (mut blocked, mut scrubbed) = (0u32, 0u32);
|
||||
let mut impacts = HashMap::new();
|
||||
let mut ignitions = Vec::new();
|
||||
let mut burnouts = Vec::new();
|
||||
let mut energy_losses = Vec::new();
|
||||
#[cfg(test)]
|
||||
let mut scrub_log = Vec::new();
|
||||
let sams_fit: HashMap<u32, f64> = self.sams.iter().map(|s| (s.id, 1.0 - 0.3 * (1.0 - s.health.clamp(0.0, 1.0)))).collect();
|
||||
@@ -3107,6 +3108,13 @@ impl Sim {
|
||||
done.push((m.id, None, false, m.sam));
|
||||
continue;
|
||||
}
|
||||
// A spent motor cannot sustain guidance once it has lost most of its speed.
|
||||
if coast && speed < spec.speed * 0.25 && target.is_some() {
|
||||
energy_lost += 1;
|
||||
energy_losses.push((m.pos, m.id, m.kind, speed));
|
||||
done.push((m.id, None, false, m.sam));
|
||||
continue;
|
||||
}
|
||||
if m.age > spec.life || (target.is_none() && m.age > 30) {
|
||||
// Its target gone (shot down by another, or lost), or its life spent chasing one.
|
||||
if target.is_none() {
|
||||
@@ -3145,11 +3153,15 @@ impl Sim {
|
||||
for (pos, missile, kind) in burnouts {
|
||||
self.scene_event(pos, record::SceneKind::MotorBurnout { missile, kind });
|
||||
}
|
||||
for (pos, missile, kind, speed) in energy_losses {
|
||||
self.scene_event(pos, record::SceneKind::MotorEnergyLost { missile, kind, speed });
|
||||
}
|
||||
#[cfg(test)]
|
||||
self.scrubs.extend(scrub_log);
|
||||
self.note(|t| {
|
||||
t.missed += missed;
|
||||
t.expired += expired;
|
||||
t.energy_lost += energy_lost;
|
||||
t.orphaned += orphaned;
|
||||
t.blocked += blocked;
|
||||
t.scrubbed += scrubbed;
|
||||
|
||||
Reference in New Issue
Block a user