Give the enemy a structured intent and a durable route queue (#127)
Stage 2 of #127. A smart drone now carries why it is aimed where it is (Intent: plan, sead, react, replace) apart from the aim bookkeeping (unit, since, switches, confidence). Assignments are throttled per adaptive tick and per contact, a fresh disclosure replaces an aim only after a hold, within a switch cap and when the change is worth a new route, and a killed aim is replaced as a separate, lower-priority decision. The queue is bounded and taken by priority (plan > sead > react > replace); unknown land is no longer free in a replanned route. The autosave now carries the air state: the drones in flight, the launch queue, every pending job with its id, aim, unit, version, priority, intent and relief version, the contacts the jobs were chosen from and the relief snapshots they plan over. The format is a versioned `air 1` section; older saves read as before, scenarios do not carry the sky, stale, ghost and duplicate jobs are cancelled on load, and the section is bounded (512 drones, 512 route points, 4096 contacts, 8 reliefs, 900 KB). A periodic save waits while a raid is only being planned. enemy_picture() now explains targets and pending jobs (aims, aimed_by, pending_jobs, reason, work_per_tick) in English, and intel_bench records the queue and intent evidence next to completion, losses and failures.
This commit is contained in:
@@ -130,6 +130,23 @@ pub struct Report {
|
||||
pub all_ended: bool,
|
||||
/// Systems the defence lost (destroyed units at the end).
|
||||
pub sams_lost: u32,
|
||||
/// The most retarget route jobs waiting at once (#127).
|
||||
pub retargets_max: usize,
|
||||
/// The largest air section a save would have taken, in bytes (#127).
|
||||
pub air_bytes: usize,
|
||||
/// The aims every drone ended with, by intent: "plan:1,sead:2,react:3,replace:0".
|
||||
pub intents: String,
|
||||
/// The most aim switches one drone went through.
|
||||
pub switches_max: u16,
|
||||
}
|
||||
|
||||
/// The last intent every smart drone of the run was seen carrying, as `name:count`.
|
||||
fn intent_counts(seen: &HashMap<u32, &'static str>) -> String {
|
||||
let mut counts = std::collections::BTreeMap::new();
|
||||
for name in seen.values() {
|
||||
*counts.entry(*name).or_insert(0usize) += 1;
|
||||
}
|
||||
["plan", "sead", "react", "replace"].iter().map(|k| format!("{k}:{}", counts.get(*k).copied().unwrap_or(0))).collect::<Vec<_>>().join(",")
|
||||
}
|
||||
|
||||
fn finite(v: DVec3) -> bool {
|
||||
@@ -164,6 +181,8 @@ pub fn run(sc: &Scenario) -> Report {
|
||||
let mut ended = vec![false; sc.raids.len()];
|
||||
// truck id -> (last position, ticks standing while busy)
|
||||
let mut standing: HashMap<u32, (DVec3, u64)> = HashMap::new();
|
||||
// drone id -> the last structured intent it carried (#127).
|
||||
let mut intents_seen: HashMap<u32, &'static str> = HashMap::new();
|
||||
let mut out = Out::default();
|
||||
for now in 1..=sc.ticks {
|
||||
// Raids come in order: one is ordered once the previous one has been sent.
|
||||
@@ -196,6 +215,18 @@ pub fn run(sc: &Scenario) -> Report {
|
||||
pending = wanted.into_iter().map(|(x, z)| (x, z, sc.terrain.height(x, z))).collect();
|
||||
}
|
||||
r.ticks_run = now;
|
||||
r.retargets_max = r.retargets_max.max(sim.retargets_len());
|
||||
r.switches_max = sim.drones.iter().chain(sim.queue.iter().map(|(_, d)| d)).map(|d| d.aim_switches()).max().unwrap_or(0).max(r.switches_max);
|
||||
for d in sim.drones.iter().chain(sim.queue.iter().map(|(_, d)| d)) {
|
||||
if d.alive() && d.smart() {
|
||||
intents_seen.insert(d.id, d.intent().name());
|
||||
}
|
||||
}
|
||||
// The air section a save would take, sampled when the sky is fullest (writing it every tick
|
||||
// would distort the timings the bench measures).
|
||||
if sim.drones.len() > r.air_bytes {
|
||||
r.air_bytes = sim.air_text().map_or(0, |t| t.len());
|
||||
}
|
||||
// NaN check on everything with a position.
|
||||
let bad = sim.drones.iter().filter(|d| !finite(d.pos) || !finite(d.vel)).count()
|
||||
+ sim.missiles.iter().filter(|m| !finite(m.pos)).count()
|
||||
@@ -239,6 +270,7 @@ pub fn run(sc: &Scenario) -> Report {
|
||||
r.failures = sim.tally.text();
|
||||
r.raids_ended = ended.iter().filter(|o| **o).count();
|
||||
r.all_ended = r.raids_ended == sc.raids.len();
|
||||
r.intents = intent_counts(&intents_seen);
|
||||
r.tick_total = times.iter().sum();
|
||||
times.sort();
|
||||
if !times.is_empty() {
|
||||
|
||||
Reference in New Issue
Block a user