From 8dcaf3d7e5be5ddb8bae3cd9ced3032875c861ae Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Tue, 1 Dec 2026 09:15:21 +0400 Subject: fix(ai): identify intruders during base defence Read the live target class and preserve the existing problem record when reweighting its priority. The stock replay now reaches group recruitment during base defence. --- crates/fparkan-script/src/lib.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'crates/fparkan-script') diff --git a/crates/fparkan-script/src/lib.rs b/crates/fparkan-script/src/lib.rs index 60b3a9d7..4dd73efd 100644 --- a/crates/fparkan-script/src/lib.rs +++ b/crates/fparkan-script/src/lib.rs @@ -1957,6 +1957,13 @@ impl Handler2RecordScheduler { self.records.retain(|record| record.key != key); } + /// Reweights an existing problem without refreshing its arguments or counter. + pub fn set_priority(&mut self, key: Handler2RecordKey, priority: f32) { + if let Some(record) = self.records.iter_mut().find(|record| record.key == key) { + record.scalar_1 = priority; + } + } + /// Inserts or refreshes one resolved handler input. /// /// The original compares the three identity words bit-for-bit. On an @@ -2516,6 +2523,18 @@ mod tests { assert_eq!(scheduler.records().len(), 2); } + #[test] + fn handler_sixty_two_changes_only_the_current_problem_priority() { + let mut scheduler = Handler2RecordScheduler::default(); + let current = handler_two_input(1.5, -0.0, 3.0, 9.0, 4); + scheduler.submit(current); + scheduler.submit(handler_two_input(2.5, 0.0, 3.0, 12.0, 1)); + let mut expected = scheduler.records().to_vec(); + expected[0].scalar_1 = 17.75; + scheduler.set_priority(current.into(), 17.75); + assert_eq!(scheduler.records(), expected); + } + #[test] fn handler_two_scheduler_refreshes_nan_and_wraps_counter() { let mut scheduler = Handler2RecordScheduler::default(); -- cgit v1.2.3