aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-script
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-12-01 08:15:21 +0300
committerValentin Popov <valentin@popov.link>2026-12-01 08:15:21 +0300
commit8dcaf3d7e5be5ddb8bae3cd9ced3032875c861ae (patch)
tree7ca5cb08018ceb3e6dd8b91fb997f2addec4cfbf /crates/fparkan-script
parent594e910853c98b1b35809799657b058d7b7dc2a0 (diff)
downloadfparkan-8dcaf3d7e5be5ddb8bae3cd9ced3032875c861ae.tar.xz
fparkan-8dcaf3d7e5be5ddb8bae3cd9ced3032875c861ae.zip
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.
Diffstat (limited to 'crates/fparkan-script')
-rw-r--r--crates/fparkan-script/src/lib.rs19
1 files changed, 19 insertions, 0 deletions
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
@@ -2517,6 +2524,18 @@ mod tests {
}
#[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();
scheduler.submit(handler_two_input(f32::NAN, 1.0, 2.0, 3.0, u32::MAX));