Fix the recon picture's wrecks and its emission sources (#139)
build / mod (push) Failing after 29s
build / mod (push) Failing after 29s
A look no longer reports a wreck as a lead: a first look at one makes no mark, and one the picture already held is radioed home as destroyed and takes its mark out of the picture. A hidden kill still never rewrites a mark, so the old assessment stands until its age runs out. The channel now follows actual work, not a switch: a radar emits only while radar_up, a jammer only while its transmitter is on the air. A silent, packed, failed or destroyed station is just a unit the flyby saw. A pending wreck observation is durable; older saves without its flag read as before, every look being of a unit alive when it was seen. Co-Authored-By: Kimi Code <noreply@moonshot.ai>
This commit is contained in:
@@ -403,7 +403,7 @@ impl Sim {
|
||||
);
|
||||
for l in &s.pending {
|
||||
body += &format!(
|
||||
"airrecobs {} {} {} {} {} {} {} {} {} {}\n",
|
||||
"airrecobs {} {} {} {} {} {} {} {} {} {} {}\n",
|
||||
l.truth,
|
||||
coord(l.area.x),
|
||||
coord(l.area.y),
|
||||
@@ -414,6 +414,7 @@ impl Sim {
|
||||
l.quality.name(),
|
||||
l.source.name(),
|
||||
l.observed,
|
||||
l.wreck,
|
||||
);
|
||||
}
|
||||
for z in &s.zones {
|
||||
@@ -715,8 +716,8 @@ impl Sim {
|
||||
recon_expect.push((pending, zones));
|
||||
}
|
||||
"airrecobs" => {
|
||||
if w.len() != 11 {
|
||||
return Err(l.bad("наблюдение разведки", "нужны юнит, место, категория, источник и такт"));
|
||||
if w.len() != 11 && w.len() != 12 {
|
||||
return Err(l.bad("наблюдение разведки", "нужны юнит, место, категория, источник, такт и признак остова"));
|
||||
}
|
||||
let Some(at) = recon_sortie_at else {
|
||||
return Err(l.bad("наблюдение разведки", "строка без разведчика"));
|
||||
@@ -739,7 +740,10 @@ impl Sim {
|
||||
let quality = recon::Quality::from_key(l.word(8, "качество")?).ok_or_else(|| l.bad("качество", "coarse или refined"))?;
|
||||
let source = recon::Source::from_key(l.word(9, "источник")?).ok_or_else(|| l.bad("источник", "flyby, emission, jamming или launch"))?;
|
||||
let observed = l.int(10, "такт наблюдения", 0, tick as i64)? as u64;
|
||||
recon.sorties[at].pending.push(recon::Look { truth, area, radius, category, role, quality, source, observed });
|
||||
// An older save has no wreck flag: every pending look it holds is of a unit
|
||||
// that was alive when it was seen.
|
||||
let wreck = if w.len() > 11 { l.flag(11, "остов")? } else { false };
|
||||
recon.sorties[at].pending.push(recon::Look { truth, area, radius, category, role, quality, source, observed, wreck });
|
||||
}
|
||||
"airreczone" => {
|
||||
if w.len() != 5 {
|
||||
|
||||
+250
-23
@@ -11,7 +11,9 @@
|
||||
//! What is reported is memory, not truth. A hidden move, a switch-off, a re-role or a
|
||||
//! kill does not rewrite a mark; only a later look can. A repeated report of the same
|
||||
//! observation does not raise its confidence: confidence is the mark's age alone, and a
|
||||
//! second independent look may refine the area and (for a radar) its role.
|
||||
//! second independent look may refine the area and (for a radar) its role. A wreck a look
|
||||
//! flies over is not a lead: a fresh one makes no mark, and one the picture already held is
|
||||
//! radioed home as destroyed and its mark leaves the picture (#139).
|
||||
use super::*;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
@@ -240,6 +242,8 @@ pub(super) struct Look {
|
||||
pub(super) quality: Quality,
|
||||
pub(super) source: Source,
|
||||
pub(super) observed: u64,
|
||||
/// The unit was a wreck when it was seen: the report takes its mark out of the picture.
|
||||
pub(super) wreck: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
@@ -368,6 +372,13 @@ impl Recon {
|
||||
if look.observed <= old.observed {
|
||||
return;
|
||||
}
|
||||
// The flight saw the wreck itself: the station is off the planner's leads, and
|
||||
// only the observation — never a hidden kill — takes the mark away (#139).
|
||||
if look.wreck {
|
||||
self.marks.remove(&id);
|
||||
self.truth.remove(&id);
|
||||
return;
|
||||
}
|
||||
let refine = look.observed.saturating_sub(old.observed) >= REFINE_GAP;
|
||||
let m = self.marks.get_mut(&id).unwrap();
|
||||
m.area = look.area;
|
||||
@@ -383,6 +394,10 @@ impl Recon {
|
||||
}
|
||||
}
|
||||
None => {
|
||||
// A wreck is no target: a first look at one leaves no mark at all.
|
||||
if look.wreck {
|
||||
return;
|
||||
}
|
||||
if self.marks.len() >= MAX_MARKS || self.next >= MARK_TOP - ID_BASE - 1 {
|
||||
return;
|
||||
}
|
||||
@@ -446,6 +461,29 @@ pub(super) fn look(sams: &[Sam], state: &Recon, intel: &ew::Intel, zone: &Zone,
|
||||
break;
|
||||
}
|
||||
let old = state.mark_for_truth(s.id);
|
||||
// The jitter is the zone's, not the unit's: the mark must not carry the unit id even
|
||||
// indirectly.
|
||||
let salt = (zone.center.x.round() as i64 as u32) ^ (zone.center.z.round() as i64 as u32).rotate_left(16);
|
||||
// A wreck is no lead and no emitter (#139). A fresh one makes no mark; one the picture
|
||||
// already held is reported as destroyed, and the report takes the old mark away. A
|
||||
// hidden kill never passes through here, so it never rewrites the picture.
|
||||
if !s.alive() {
|
||||
if old.is_none() {
|
||||
continue;
|
||||
}
|
||||
out.push(Look {
|
||||
truth: s.id,
|
||||
area: area_of(s.pos, COARSE_AREA, salt),
|
||||
radius: COARSE_AREA,
|
||||
category: Category::of(s.kind),
|
||||
role: None,
|
||||
quality: Quality::Coarse,
|
||||
source: Source::Flyby,
|
||||
observed: now,
|
||||
wreck: true,
|
||||
});
|
||||
continue;
|
||||
}
|
||||
let refine = old.is_some_and(|m| now.saturating_sub(m.observed) >= REFINE_GAP);
|
||||
let quality = if refine { Quality::Refined } else { Quality::Coarse };
|
||||
let cell = if refine { REFINED_AREA } else { COARSE_AREA };
|
||||
@@ -453,17 +491,17 @@ pub(super) fn look(sams: &[Sam], state: &Recon, intel: &ew::Intel, zone: &Zone,
|
||||
// A launch is a public event already watched by the disclosure channel; a look that
|
||||
// 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);
|
||||
// The switch is intent, not work: a radar is an emitter only while `radar_up`, a jammer
|
||||
// only while the transmitter is really on the air. A silent, packed or failed one is
|
||||
// just a unit the flyby saw.
|
||||
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_up() => Source::Jamming,
|
||||
SamKind::Radar if s.radar_up() => Source::Emission,
|
||||
_ if launched => Source::Launch,
|
||||
_ => Source::Flyby,
|
||||
};
|
||||
// The role is a public radar configuration only when a close second look can tell it.
|
||||
let role = (refine && s.kind == SamKind::Radar).then_some(s.radar_role);
|
||||
// The jitter is the zone's, not the unit's: the mark must not carry the unit id even
|
||||
// indirectly.
|
||||
let salt = (zone.center.x.round() as i64 as u32) ^ (zone.center.z.round() as i64 as u32).rotate_left(16);
|
||||
out.push(Look {
|
||||
truth: s.id,
|
||||
area: area_of(s.pos, cell, salt),
|
||||
@@ -473,6 +511,7 @@ pub(super) fn look(sams: &[Sam], state: &Recon, intel: &ew::Intel, zone: &Zone,
|
||||
quality,
|
||||
source,
|
||||
observed: now,
|
||||
wreck: false,
|
||||
});
|
||||
}
|
||||
out
|
||||
@@ -795,6 +834,7 @@ mod tests {
|
||||
quality: Quality::Refined,
|
||||
source: before.source,
|
||||
observed: before.observed,
|
||||
wreck: false,
|
||||
};
|
||||
sim.recon.report(look, before.reported + 10_000);
|
||||
let after = *sim.recon.marks.values().next().unwrap();
|
||||
@@ -824,35 +864,219 @@ mod tests {
|
||||
s.missiles = 0;
|
||||
sim.tick += 1000;
|
||||
assert_eq!(key(&sim.enemy_picture().recon), key(&before), "a hidden change rewrote the recon picture");
|
||||
// A hidden kill does not take the mark away either: it is still a lead until its age
|
||||
// runs out, and then it is forgotten like any other unrevisited mark (#139).
|
||||
let mark = before.first().expect("the look made no mark").id;
|
||||
let observed = sim.recon.marks.get(&mark).expect("the mark is gone").observed;
|
||||
assert!(sim.recon.leads(sim.tick).iter().any(|m| m.id == mark), "a hidden kill removed an active lead");
|
||||
assert!(sim.recon.leads(observed + MARK_TTL - 1).iter().any(|m| m.id == mark), "a mark died before its age");
|
||||
assert!(sim.recon.leads(observed + MARK_TTL).iter().all(|m| m.id != mark), "a mark outlived its age");
|
||||
}
|
||||
|
||||
|
||||
// #135: the channel matters. A silent radar is seen only by the flyby, a transmitting
|
||||
// radar by its emission, a jamming station by its transmission, and a just-fired system
|
||||
// by the launch the disclosure channel already watched. A hidden switch or magazine is
|
||||
// not read: only what the game shows.
|
||||
// #139: a look at a wreck is not a lead. A station destroyed before the flight arrives, with
|
||||
// its switch still on, makes no mark and no lead; its report is an empty observation.
|
||||
#[test]
|
||||
fn the_source_is_the_channel_that_showed_the_unit() {
|
||||
fn a_fresh_wreck_makes_no_mark_and_no_lead() {
|
||||
let mut sim = Sim::new(21);
|
||||
let object = DVec3::new(0.0, 70.0, 0.0);
|
||||
let id = sam(&mut sim, SamKind::Radar, object + DVec3::new(20.0, 0.0, 10.0));
|
||||
let s = sim.sams.iter_mut().find(|s| s.id == id).unwrap();
|
||||
s.health = 0.0;
|
||||
s.radar_on = true;
|
||||
assert!(!s.radar_up(), "a destroyed radar still reported itself working");
|
||||
sim.start_recon(&[object], 0.0, 300.0, &mut Out::default());
|
||||
let (_, at) = look_once(&mut sim);
|
||||
assert!(sim.recon.marks.is_empty(), "a look at a fresh wreck reached the picture");
|
||||
sim.tick = at + REPORT_DELAY;
|
||||
sim.step_recon(&mut Out::default());
|
||||
assert!(sim.recon.marks.is_empty(), "a fresh wreck made a mark");
|
||||
assert!(sim.recon.leads(sim.tick).is_empty(), "a fresh wreck became an active lead");
|
||||
}
|
||||
|
||||
// #139: a hidden kill leaves the mark as the picture remembers it, but a look that flies over
|
||||
// the wreck reports the destruction and the mark leaves the leads. Nothing of it stays to
|
||||
// aim at, and a mark no look revisits still ages out on its own.
|
||||
#[test]
|
||||
fn a_known_mark_leaves_the_leads_when_its_wreck_is_seen() {
|
||||
let mut sim = Sim::new(22);
|
||||
let object = DVec3::new(0.0, 70.0, 0.0);
|
||||
let id = sam(&mut sim, SamKind::Radar, object + DVec3::new(20.0, 0.0, 10.0));
|
||||
sim.start_recon(&[object], 0.0, 300.0, &mut Out::default());
|
||||
let (_, at) = look_once(&mut sim);
|
||||
sim.tick = at + REPORT_DELAY;
|
||||
sim.step_recon(&mut Out::default());
|
||||
let mark = sim.recon.mark_for_truth(id).expect("a live radar made no mark");
|
||||
assert!(sim.recon.leads(sim.tick).iter().any(|m| m.id == mark.id));
|
||||
|
||||
// A hidden kill is not an observation: the old assessment stands.
|
||||
sim.sams.iter_mut().find(|s| s.id == id).unwrap().health = 0.0;
|
||||
assert!(sim.recon.leads(sim.tick).iter().any(|m| m.id == mark.id), "a hidden kill removed the mark");
|
||||
|
||||
// A look that sees the wreck names it as a flyby, and its report takes the mark away.
|
||||
let zone = Zone { center: object, radius: ZONE_RADIUS };
|
||||
let wreck = super::look(&sim.sams, &sim.recon, &sim.intel, &zone, sim.tick).into_iter().find(|l| l.truth == id).expect("the wreck was not observed");
|
||||
assert!(wreck.wreck);
|
||||
assert_eq!(wreck.source, Source::Flyby, "a wreck named an emission");
|
||||
sim.recon.report(wreck, sim.tick + REPORT_DELAY);
|
||||
assert!(sim.recon.marks.is_empty(), "the wreck's report left a mark");
|
||||
assert!(sim.recon.truth.iter().all(|(_, t)| *t != id), "the wreck's truth mapping stayed");
|
||||
assert!(sim.recon.leads(sim.tick + REPORT_DELAY).is_empty(), "the wreck stayed an active lead");
|
||||
}
|
||||
|
||||
// #139: a wreck observation still waiting for its report is durable. A restored flight takes
|
||||
// the mark away on its tick, while an older save without the wreck flag reads as before.
|
||||
#[test]
|
||||
fn a_wreck_report_survives_a_save_and_removes_the_mark() {
|
||||
let mut sim = Sim::new(23);
|
||||
let object = DVec3::new(0.0, 70.0, 0.0);
|
||||
let id = sam(&mut sim, SamKind::Radar, object + DVec3::new(20.0, 0.0, 10.0));
|
||||
sim.start_recon(&[object], 0.0, 300.0, &mut Out::default());
|
||||
let (_, at) = look_once(&mut sim);
|
||||
sim.tick = at + REPORT_DELAY;
|
||||
sim.step_recon(&mut Out::default());
|
||||
let mark = sim.recon.mark_for_truth(id).expect("no mark to destroy");
|
||||
// The radar dies unseen; a second flight looks at the wreck and its report is unsent
|
||||
// when the save is taken.
|
||||
sim.sams.iter_mut().find(|s| s.id == id).unwrap().health = 0.0;
|
||||
sim.recon.sorties.clear();
|
||||
sim.recon.checked.clear();
|
||||
sim.start_recon(&[object], 0.0, 900.0, &mut Out::default());
|
||||
let (_, seen_wreck) = look_once(&mut sim);
|
||||
assert!(sim.recon.sorties.iter().flat_map(|s| &s.pending).any(|l| l.wreck), "the wreck was not pending");
|
||||
let text = sim.air_text().expect("a wreck report is durable");
|
||||
assert!(text.lines().any(|l| l.starts_with("airrecobs ") && l.ends_with(" true")), "the wreck flag was not written");
|
||||
|
||||
// An older save has no flag: the same look reads as a live re-observation.
|
||||
let legacy: String = text
|
||||
.lines()
|
||||
.map(|l| {
|
||||
if l.starts_with("airrecobs ") {
|
||||
let mut w: Vec<&str> = l.split_whitespace().collect();
|
||||
w.pop();
|
||||
w.join(" ")
|
||||
} else {
|
||||
l.to_string()
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n")
|
||||
+ "\n";
|
||||
let mut old = Sim::new(24);
|
||||
old.restore_air(Sim::parse_air(&legacy).expect("an older save reads").expect("the air section is there"));
|
||||
assert!(old.recon.sorties.iter().flat_map(|s| &s.pending).all(|l| !l.wreck), "an older save invented a wreck");
|
||||
|
||||
let mut back = Sim::new(25);
|
||||
back.restore_air(Sim::parse_air(&text).expect("the save reads").expect("the air section is there"));
|
||||
assert!(back.recon.marks.contains_key(&mark.id), "the save forgot the mark before its wreck report");
|
||||
assert!(back.recon.sorties.iter().flat_map(|s| &s.pending).any(|l| l.wreck), "the save lost the wreck report");
|
||||
back.tick = seen_wreck + REPORT_DELAY;
|
||||
back.step_recon(&mut Out::default());
|
||||
assert!(!back.recon.marks.contains_key(&mark.id), "a restored wreck report left the mark");
|
||||
assert!(back.recon.leads(back.tick).is_empty(), "a restored wreck report stayed an active lead");
|
||||
}
|
||||
|
||||
// #135/#139: the channel matters. A silent, packed or failed radar is only a flyby; so is a
|
||||
// jammer whose transmitter is off, packed or destroyed. Only a station actually working shows
|
||||
// its emission, and a wreck is no source at all. A just-fired system is still a launch the
|
||||
// disclosure channel already watched. A hidden empty magazine is not read.
|
||||
#[test]
|
||||
fn the_source_is_the_channel_that_showed_a_working_unit() {
|
||||
let mut sim = Sim::new(8);
|
||||
let zone = Zone { center: DVec3::new(0.0, 70.0, 0.0), radius: ZONE_RADIUS };
|
||||
let radar = sam(&mut sim, SamKind::Radar, DVec3::new(10.0, 70.0, 0.0));
|
||||
let ew = sam(&mut sim, SamKind::Ew, DVec3::new(-10.0, 70.0, 0.0));
|
||||
let s400 = sam(&mut sim, SamKind::S400, DVec3::new(0.0, 70.0, 10.0));
|
||||
sim.recon.checked.clear();
|
||||
let source = |sim: &Sim, id: u32| super::look(&sim.sams, &sim.recon, &sim.intel, &zone, sim.tick).into_iter().find(|l| l.truth == id).unwrap().source;
|
||||
let source = |sim: &Sim, id: u32| super::look(&sim.sams, &sim.recon, &sim.intel, &zone, sim.tick).into_iter().find(|l| l.truth == id).map(|l| l.source);
|
||||
fn unit(sim: &mut Sim, id: u32) -> &mut Sam {
|
||||
sim.sams.iter_mut().find(|s| s.id == id).unwrap()
|
||||
}
|
||||
|
||||
// Working: the radar emits and the jammer transmits.
|
||||
assert_eq!(source(&sim, radar), Some(Source::Emission));
|
||||
unit(&mut sim, ew).ew_on = true;
|
||||
assert_eq!(source(&sim, ew), Some(Source::Jamming));
|
||||
|
||||
// Off: the switch is intent, not work.
|
||||
unit(&mut sim, radar).radar_on = false;
|
||||
assert_eq!(source(&sim, radar), Some(Source::Flyby), "a silent radar was read as emitting");
|
||||
unit(&mut sim, radar).radar_on = true;
|
||||
unit(&mut sim, ew).ew_on = false;
|
||||
assert_eq!(source(&sim, ew), Some(Source::Flyby), "a silent jammer was read as transmitting");
|
||||
unit(&mut sim, ew).ew_on = true;
|
||||
|
||||
// Packed for a march: neither is on the air, whatever the switch says.
|
||||
unit(&mut sim, radar).state = SamState::Moving;
|
||||
unit(&mut sim, ew).state = SamState::Moving;
|
||||
assert_eq!(source(&sim, radar), Some(Source::Flyby), "a radar on the march was read as emitting");
|
||||
assert_eq!(source(&sim, ew), Some(Source::Flyby), "a jammer on the march was read as transmitting");
|
||||
unit(&mut sim, radar).state = SamState::Search;
|
||||
unit(&mut sim, ew).state = SamState::Search;
|
||||
|
||||
// Damage: a failed sensor is no radar; a damaged hull with a working sensor still emits.
|
||||
unit(&mut sim, radar).comps.0[Part::Sensor as usize] = 0.0;
|
||||
assert_eq!(source(&sim, radar), Some(Source::Flyby), "a radar with a failed sensor was read as emitting");
|
||||
unit(&mut sim, radar).comps.0[Part::Sensor as usize] = 1.0;
|
||||
unit(&mut sim, radar).health = 0.5;
|
||||
assert_eq!(source(&sim, radar), Some(Source::Emission), "a damaged but working radar lost its emission");
|
||||
|
||||
// Destroyed: a wreck is no source and makes no lead at all.
|
||||
unit(&mut sim, radar).health = 0.0;
|
||||
unit(&mut sim, ew).health = 0.0;
|
||||
assert_eq!(source(&sim, radar), None, "a wreck was reported as a lead");
|
||||
assert_eq!(source(&sim, ew), None, "a wrecked jammer was reported as transmitting");
|
||||
|
||||
sim.sams.iter_mut().find(|s| s.id == radar).unwrap().radar_on = false;
|
||||
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);
|
||||
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.intel.observe(sim.sams.iter().find(|s| s.id == s400).unwrap(), sim.tick, ew::Seen::Launch);
|
||||
assert_eq!(source(&sim, s400), Source::Launch);
|
||||
assert_eq!(source(&sim, s400), Some(Source::Launch));
|
||||
// A hidden empty magazine does not change the source.
|
||||
sim.sams.iter_mut().find(|s| s.id == s400).unwrap().missiles = 0;
|
||||
assert_eq!(source(&sim, s400), Source::Launch);
|
||||
assert_eq!(source(&sim, s400), Some(Source::Launch));
|
||||
}
|
||||
|
||||
// #139: a station the picture already holds, seen off, packed or damaged, stays a flyby
|
||||
// contact: the switch never turns its mark into an emitter, and a working station seen
|
||||
// again still names its emission.
|
||||
#[test]
|
||||
fn a_known_station_that_stops_working_stays_a_flyby_contact() {
|
||||
let mut sim = Sim::new(26);
|
||||
let zone = Zone { center: DVec3::new(0.0, 70.0, 0.0), radius: ZONE_RADIUS };
|
||||
let id = sam(&mut sim, SamKind::Radar, DVec3::new(10.0, 70.0, 0.0));
|
||||
let seen = |sim: &Sim, now: u64| super::look(&sim.sams, &sim.recon, &sim.intel, &zone, now).into_iter().find(|l| l.truth == id).expect("the radar was not observed");
|
||||
|
||||
let first = seen(&sim, 100);
|
||||
assert_eq!(first.source, Source::Emission);
|
||||
sim.recon.report(first, 100);
|
||||
let mark = sim.recon.mark_for_truth(id).expect("the working look made no mark");
|
||||
|
||||
// Off, then packed for a march, then with a failed sensor: the contact stays, the
|
||||
// channel is the flyby alone.
|
||||
for (change, now) in [(0, 200), (1, 900), (2, 1600)] {
|
||||
let s = sim.sams.iter_mut().find(|s| s.id == id).unwrap();
|
||||
match change {
|
||||
0 => s.radar_on = false,
|
||||
1 => {
|
||||
s.radar_on = true;
|
||||
s.state = SamState::Moving;
|
||||
}
|
||||
_ => {
|
||||
s.state = SamState::Search;
|
||||
s.comps.0[Part::Sensor as usize] = 0.0;
|
||||
}
|
||||
}
|
||||
let look = seen(&sim, now);
|
||||
assert!(!look.wreck, "case {change}: a working station was read as a wreck");
|
||||
assert_eq!(look.source, Source::Flyby, "case {change}: the switch was read as work");
|
||||
sim.recon.report(look, now);
|
||||
assert!(sim.recon.marks.contains_key(&mark.id), "case {change}: the contact was lost");
|
||||
}
|
||||
|
||||
// Working again: the refined look names the emission.
|
||||
let s = sim.sams.iter_mut().find(|s| s.id == id).unwrap();
|
||||
s.comps.0[Part::Sensor as usize] = 1.0;
|
||||
let look = seen(&sim, 2300);
|
||||
assert_eq!(look.source, Source::Emission);
|
||||
assert_eq!(look.quality, Quality::Refined);
|
||||
sim.recon.report(look, 2300);
|
||||
assert_eq!(sim.recon.mark_for_truth(id).unwrap().source, Source::Emission);
|
||||
}
|
||||
|
||||
// #135: the planner's order is the observed public role, freshness and quality, not the
|
||||
@@ -1043,6 +1267,7 @@ mod tests {
|
||||
quality: Quality::Coarse,
|
||||
source: Source::Flyby,
|
||||
observed: 100,
|
||||
wreck: false,
|
||||
};
|
||||
r.report(coarse_look, 200);
|
||||
let coarse = r.mark();
|
||||
@@ -1071,6 +1296,7 @@ mod tests {
|
||||
quality: Quality::Refined,
|
||||
source: Source::Emission,
|
||||
observed: 1000,
|
||||
wreck: false,
|
||||
};
|
||||
sim.recon.report(look(1, battery::RadarRole::Search), 1000);
|
||||
sim.recon.report(look(2, battery::RadarRole::Engagement), 1000);
|
||||
@@ -1117,6 +1343,7 @@ mod tests {
|
||||
quality: Quality::Coarse,
|
||||
source: Source::Flyby,
|
||||
observed: 100,
|
||||
wreck: false,
|
||||
},
|
||||
100,
|
||||
);
|
||||
|
||||
@@ -363,6 +363,11 @@ impl Sam {
|
||||
pub fn radar_up(&self) -> bool {
|
||||
self.radar_on && self.mode != battery::SamMode::LauncherOnly && self.alive() && !self.moving() && self.kind.spec().sensor > 0.0 && self.part(Part::Sensor) > 0.0
|
||||
}
|
||||
/// Its jammer is really on the air: the switch, a live station and a deployed one. The same
|
||||
/// state `step_ew` transmits in, so a look names jamming only while the transmitter works.
|
||||
pub fn ew_up(&self) -> bool {
|
||||
self.ew_on && self.alive() && !self.moving()
|
||||
}
|
||||
pub fn track(&self, id: u32) -> Option<&Track> {
|
||||
self.tracks.iter().find(|t| t.id == id)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user