Add the recon UI and diagnostic layer to the smart enemy (#135)

The core recon flights and partial reports (9d8f3da57) had no player-facing
or diagnostic consumer: enemy_picture().recon/recon_sorties were read only by
core tests. This adds the missing layer on top, without touching the mechanics,
models or textures.

- Map: a tracked recon aircraft is a recognisable yellow hollow diamond with a
  "разведчик" label, a role line in the selection panel and a filter legend; in
  the sandbox truth mode it gets an amber marker of its own.
- Battle UI: the summary panel and the map show the flight's coarse phase
  (разведка → донесение → завершение) only while the player's network actually
  holds a recon aircraft — what the visible aircraft are doing, not what the
  enemy learned. The truth mode adds a recon count line.
- Diagnostics and after-action review: /airdef recon and the menu page
  "Разведка противника (разбор)" (from Main and Replays) list the enemy's marks
  best-first with the reason each outranks the rest — priority = freshness×4 +
  quality×3 + observed role (recon::priority_parts, cross-checked against
  Mark::priority by a test) — plus the sortie phases and the drones aimed at a
  mark. The omniscient enemy picture is never shown in the normal HUD; it is
  explicit debug/review only.

recon_view reads only the current report types (EnemyPictureReport, ReconReport,
ReconSortieReport); the sim side only widens visibility and adds priority_parts
and the is_recon_drone/recon_status read helpers. Tests: recon_view, panel,
command tree, priority_parts cross-check. README and IMPLEMENTATION-STATUS updated.

Co-Authored-By: Kimi Code <noreply@moonshot.ai>
This commit is contained in:
2026-11-20 23:09:34 +03:00
parent 245aceb434
commit c4e002ed8b
9 changed files with 528 additions and 30 deletions
+2 -2
View File
@@ -27,8 +27,8 @@ mod terrain;
mod ew;
mod recon;
mod durable;
pub use ew::{AimReport, Confidence, ContactReport, EnemyPictureReport, Intent, PendingReport};
pub use recon::{Category, Mark, Quality, Source};
pub use ew::{AimReport, Confidence, ContactReport, EnemyPictureReport, Intent, PendingReport, ReconReport, ReconSortieReport};
pub use recon::{Category, Mark, Quality, Source, is_drone_id, priority_parts};
pub mod lights;
mod logistics;
mod orders;
+60 -6
View File
@@ -57,8 +57,9 @@ pub(super) fn is_mark(id: u32) -> bool {
(ID_BASE..MARK_TOP).contains(&id)
}
/// Whether an id belongs to a recon aircraft (a role of its own, not a strike drone).
pub(super) fn is_drone_id(id: u32) -> bool {
/// Whether an id belongs to a recon aircraft (a role of its own, not a strike drone). The
/// player's map and panel read it to mark a tracked aircraft as a recon flight (#135).
pub fn is_drone_id(id: u32) -> bool {
id >= DRONE_BASE
}
@@ -85,7 +86,7 @@ impl Category {
Self::Support => "support",
}
}
pub(super) fn from_key(key: &str) -> Option<Self> {
pub fn from_key(key: &str) -> Option<Self> {
[Self::Unknown, Self::Radar, Self::Launcher, Self::Gun, Self::Ew, Self::Support].into_iter().find(|c| c.name() == key)
}
/// The public role a look at this kind can tell apart, nothing finer.
@@ -101,7 +102,7 @@ impl Category {
}
}
/// What a confirmed contact of this category is worth to the planner, before freshness.
pub(super) fn weight(self) -> u8 {
pub fn weight(self) -> u8 {
match self {
Self::Radar | Self::Launcher => 3,
Self::Ew | Self::Gun => 2,
@@ -112,7 +113,7 @@ impl Category {
}
/// A radar role is public only after a refined look; a coarse report leaves it unknown.
pub(super) fn role_weight(role: battery::RadarRole) -> u8 {
pub fn role_weight(role: battery::RadarRole) -> u8 {
match role {
battery::RadarRole::Multifunction | battery::RadarRole::Engagement => 3,
battery::RadarRole::Search => 2,
@@ -120,6 +121,24 @@ pub(super) fn role_weight(role: battery::RadarRole) -> u8 {
}
}
/// The three parts a mark's priority is priced from, in the same terms `Mark::priority` uses:
/// freshness (its confidence band), how well it is known (quality) and the observed public role
/// (a refined radar's role, else its category). The priority is `freshness * 4 + quality * 3 + role`
/// (#135). The diagnostic reads this to show *why* a mark outranks another, never the unit's truth.
pub fn priority_parts(confidence: Confidence, quality: Quality, category: Category, role: Option<battery::RadarRole>) -> (u8, u8, u8) {
let freshness = match confidence {
Confidence::Confirmed => 4,
Confidence::Probable => 2,
Confidence::Doubtful => 0,
};
let quality = match quality {
Quality::Refined => 2,
Quality::Coarse => 0,
};
let role = role.map_or_else(|| category.weight(), role_weight);
(freshness, quality, role)
}
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub enum Quality {
Coarse,
@@ -133,7 +152,7 @@ impl Quality {
Self::Refined => "refined",
}
}
pub(super) fn from_key(key: &str) -> Option<Self> {
pub fn from_key(key: &str) -> Option<Self> {
[Self::Coarse, Self::Refined].into_iter().find(|q| q.name() == key)
}
}
@@ -485,6 +504,18 @@ pub(super) fn plan_zones(objects: &[DVec3], state: &Recon, now: u64) -> Vec<Zone
}
impl Sim {
/// Whether an aircraft is the enemy's recon flight (#135): the sandbox's truth gives it a
/// sign of its own; the normal picture classes it as any other drone.
pub fn is_recon_drone(&self, id: u32) -> bool {
recon::is_drone_id(id)
}
/// The recon flight's state for the sandbox's truth line (#135): the aircraft still out
/// with a task, and the marks the picture holds. Nothing of the hidden force is in it.
pub fn recon_status(&self) -> (usize, usize) {
(self.recon.sorties.len(), self.recon.marks.values().filter(|m| m.live(self.tick)).count())
}
/// Sends the raid's recon flight: a few unarmed aircraft, physically in the air, ahead
/// of the strike. Their zones come from the marked objectives alone, never from the
/// hidden force, so the same seed and objectives order the same flight whatever the
@@ -854,6 +885,29 @@ mod tests {
assert!(leads.iter().all(|m| m.id != 1 && m.id != 2), "a true id leaked into the marks");
}
// #135: the diagnostic's breakdown is the planner's own price: for every confidence, quality,
// category and role the parts sum to exactly `Mark::priority`, so the reason shown can never
// drift from the order the planner actually uses.
#[test]
fn priority_parts_sum_to_the_planners_priority() {
for confidence in [Confidence::Doubtful, Confidence::Probable, Confidence::Confirmed] {
let now = match confidence {
Confidence::Confirmed => 100,
Confidence::Probable => 1000,
Confidence::Doubtful => 4000,
};
for quality in [Quality::Coarse, Quality::Refined] {
for category in [Category::Unknown, Category::Radar, Category::Launcher, Category::Gun, Category::Ew, Category::Support] {
for role in [None, Some(battery::RadarRole::Search), Some(battery::RadarRole::Engagement), Some(battery::RadarRole::Height), Some(battery::RadarRole::Multifunction)] {
let m = Mark { id: ID_BASE + 1, area: DVec3::ZERO, radius: COARSE_AREA, category, role, source: Source::Flyby, observed: 0, reported: 0, quality, looks: 1 };
assert_eq!(m.confidence(now), confidence);
let (f, q, r) = priority_parts(confidence, quality, category, role);
assert_eq!(f * 4 + q * 3 + r, m.priority(now), "{confidence:?} {quality:?} {category:?} {role:?}");
}
}
}
}
}
// #135: only the smart enemy gets the phase. A simple preset's raid gets no aircraft and
// spends no time on a role it never had.