The player's picture and the enemy's intel apart from the truth (#93); world answers carry their context, worlds told apart by seed, a drone that can't reach its aim gives up (#90)
build / mod (push) Successful in 8m25s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-31 03:20:07 +03:00
parent 557346548a
commit 1a693763fd
54 changed files with 560 additions and 119 deletions
+41 -1
View File
@@ -119,7 +119,7 @@ impl Ground {
let hit = self.known.get(&k).or_else(|| {
self.known.get(&(k.0.div_euclid(LAT) * LAT + LAT / 2, k.1.div_euclid(LAT) * LAT + LAT / 2))
});
hit.and_then(|&(y, _)| (y > -64).then_some(f64::from(y)))
hit.and_then(|&(y, _)| land_height(y))
}
}
@@ -235,6 +235,8 @@ impl Ident {
#[derive(Clone, Copy, Debug)]
pub struct Track {
pub id: u32,
/// What the radar made of it when it measured (the class the picture shows).
pub kind: DroneKind,
/// Where it was and how it went when last measured (blocks, blocks a tick).
pub pos: DVec3,
pub vel: DVec3,
@@ -248,6 +250,24 @@ pub struct Track {
pub locked: bool,
}
/// What the player's side knows of the air: the network's tracks as last measured, never the drones themselves.
pub struct AirPicture {
pub now: u64,
pub tracks: Vec<Track>,
/// No system is deployed: the tracks are the sky as it is.
pub unaided: bool,
}
impl AirPicture {
pub fn get(&self, id: u32) -> Option<&Track> {
self.tracks.iter().find(|t| t.id == id)
}
/// The track nearest to a point, by its forecast place.
pub fn nearest(&self, to: DVec3) -> Option<&Track> {
self.tracks.iter().min_by(|a, b| a.est(self.now).distance(to).total_cmp(&b.est(self.now).distance(to)))
}
}
impl Track {
pub fn age(&self, now: u64) -> u64 {
now.saturating_sub(self.tick)
@@ -396,6 +416,7 @@ impl Sim {
let noise = DVec3::new(dice(seed, now, key, 1) - 0.5, (dice(seed, now, key, 2) - 0.5) * 0.5, dice(seed, now, key, 3) - 0.5) * 2.0 * sigma;
fresh.push(Track {
id: d.id,
kind: d.kind,
pos: d.pos + noise,
vel: d.vel,
tick: now,
@@ -447,6 +468,25 @@ impl Sim {
self.sams.iter().any(|s| s.seen.contains(&id))
}
/// The air picture as the player's panel and radar read it (the only thing they read).
pub fn air_picture(&self) -> AirPicture {
let now = self.tick;
// With no system deployed there is no radar to be blind: the sky as it is (the same fallback the screens
// always had); a network's picture is only what it holds.
let unaided = self.sams.is_empty();
let mut tracks: Vec<Track> = if unaided {
self.drones
.iter()
.filter(|d| d.alive())
.map(|d| Track { id: d.id, kind: d.kind, pos: d.pos, vel: d.vel, tick: now, own_tick: now, ttl: 1, hits: 3, locked: false })
.collect()
} else {
self.picture().into_values().collect()
};
tracks.sort_by_key(|t| t.id);
AirPicture { now, tracks, unaided }
}
/// The freshest track of each drone any system holds: the air picture.
pub fn picture(&self) -> HashMap<u32, Track> {
let mut best: HashMap<u32, Track> = HashMap::new();