Compare commits

..

1 Commits

Author SHA1 Message Date
Codex 9d904335b1 Ignore wrecks and silent emitters in recon reports
build / mod (push) Failing after 39s
Refs #139

Co-Authored-By: Codex <codex@openai.com>
2026-11-21 05:30:38 +00:00
2 changed files with 30 additions and 6 deletions
+28 -3
View File
@@ -439,7 +439,7 @@ pub(super) fn area_of(at: DVec3, cell: f64, salt: u32) -> DVec3 {
pub(super) fn look(sams: &[Sam], state: &Recon, intel: &ew::Intel, zone: &Zone, now: u64) -> Vec<Look> {
let mut out = Vec::new();
for s in sams {
if horizontal(s.pos - zone.center).length() > zone.radius {
if !s.alive() || horizontal(s.pos - zone.center).length() > zone.radius {
continue;
}
if out.len() >= MAX_OBSERVED {
@@ -454,8 +454,8 @@ pub(super) fn look(sams: &[Sam], state: &Recon, intel: &ew::Intel, zone: &Zone,
// passes just after one can name that source too. Health, magazine and link never are.
let launched = intel.contacts().get(&s.id).is_some_and(|c| c.seen == ew::Seen::Launch && now.saturating_sub(c.tick) < 200);
let source = match s.kind {
SamKind::Ew if s.ew_on => Source::Jamming,
SamKind::Radar if s.radar_on => Source::Emission,
SamKind::Ew if s.ew_on && !s.moving() && !s.ew_lock => Source::Jamming,
SamKind::Radar if s.radar_up() => Source::Emission,
_ if launched => Source::Launch,
_ => Source::Flyby,
};
@@ -845,9 +845,13 @@ mod tests {
assert_eq!(source(&sim, radar), Source::Flyby, "a silent radar was read as emitting");
sim.sams.iter_mut().find(|s| s.id == radar).unwrap().radar_on = true;
assert_eq!(source(&sim, radar), Source::Emission);
sim.sams.iter_mut().find(|s| s.id == radar).unwrap().state = super::super::SamState::Moving;
assert_eq!(source(&sim, radar), Source::Flyby, "a moving radar is not emitting");
assert_eq!(source(&sim, ew), Source::Flyby, "a silent jammer was read as transmitting");
sim.sams.iter_mut().find(|s| s.id == ew).unwrap().ew_on = true;
assert_eq!(source(&sim, ew), Source::Jamming);
sim.sams.iter_mut().find(|s| s.id == ew).unwrap().ew_lock = true;
assert_eq!(source(&sim, ew), Source::Flyby, "an overheated jammer is not transmitting");
sim.intel.observe(sim.sams.iter().find(|s| s.id == s400).unwrap(), sim.tick, ew::Seen::Launch);
assert_eq!(source(&sim, s400), Source::Launch);
// A hidden empty magazine does not change the source.
@@ -855,6 +859,27 @@ mod tests {
assert_eq!(source(&sim, s400), Source::Launch);
}
#[test]
fn wrecks_do_not_create_targets_in_a_new_flyby_report() {
let mut sim = Sim::new(8);
let object = DVec3::new(0.0, 70.0, 0.0);
sam(&mut sim, SamKind::Radar, object);
sam(&mut sim, SamKind::Ew, object + DVec3::X * 10.0);
sim.sams[0].radar_on = true;
sim.sams[1].ew_on = true;
for s in &mut sim.sams { s.health = 0.0; }
sam(&mut sim, SamKind::Gepard, object + DVec3::X * 20.0);
sim.start_recon(&[object], 0.0, 300.0, &mut Out::default());
let (_, seen) = look_once(&mut sim);
sim.tick = seen + REPORT_DELAY;
sim.step_recon(&mut Out::default());
let leads = sim.recon.leads(sim.tick);
assert_eq!(leads.len(), 1);
assert_eq!(leads[0].category, Category::of(SamKind::Gepard));
}
// #135: the planner's order is the observed public role, freshness and quality, not the
// unit id or its true importance. A fresh modest mark outranks an old doubtful big one;
// the synthetic ids are only the last deterministic tie.
+2 -3
View File
@@ -50,14 +50,13 @@ expect.feedback = "№2 С-400: режим launcher"
[[step]]
command = "airdef deploy radar_track"
# A deployed radar keeps its equipment profile; only its emissions can be switched.
[[step]]
command = "airdef radar 4 search"
expect.error = "Профиль РЛС задаётся при размещении (deploy radar_search|radar_track|radar_height); переключение в search не меняет оборудование. Доступно on/off."
expect.feedback = "№4 РЛС: роль search"
[[step]]
command = "airdef radar 4 engagement"
expect.error = "Профиль РЛС задаётся при размещении (deploy radar_search|radar_track|radar_height); переключение в engagement не меняет оборудование. Доступно on/off."
expect.feedback = "№4 РЛС: роль engagement"
[[step]]
command = "airdef radar 4 off"