aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-runtime/src/lib.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-11-25 18:20:42 +0300
committerValentin Popov <valentin@popov.link>2026-11-25 18:20:42 +0300
commitd4e008fe33337494c0a28d9e35da9986a7dd42c7 (patch)
tree46a5f96065f4be457a5f84d90ce4feeeb88b2cda /crates/fparkan-runtime/src/lib.rs
parentf0e3a84cf5c0d7a0edd890c303299306c513ba8b (diff)
downloadfparkan-d4e008fe33337494c0a28d9e35da9986a7dd42c7.tar.xz
fparkan-d4e008fe33337494c0a28d9e35da9986a7dd42c7.zip
fix(ai): schedule clan cycles with native jitter and logical time
Use a separate AI CRT stream for the 7000 + rand() % 1000 ms cycle. Require a strictly later deadline, reschedule late callbacks from actual arrival time, and advance script time by seven seconds per cycle. Count executed cycles by clan; retain explicit initial-phase and RNG-order gaps. Validated the native RNG through ai.dll and the timer in the running original. Workspace fmt/check/tests and all 29 stock 900-second reports pass. A stock-start mission-28 window ran through warbot and transport production and successive laboratory projects. This is not full G7 chronology acceptance; candidate properties for 65/69 remain stubbed.
Diffstat (limited to 'crates/fparkan-runtime/src/lib.rs')
-rw-r--r--crates/fparkan-runtime/src/lib.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/crates/fparkan-runtime/src/lib.rs b/crates/fparkan-runtime/src/lib.rs
index 20d05295..b810eda8 100644
--- a/crates/fparkan-runtime/src/lib.rs
+++ b/crates/fparkan-runtime/src/lib.rs
@@ -50,6 +50,7 @@ mod clan_ai_events;
mod clan_area_strength;
mod clan_build_limits;
mod clan_building_queries;
+mod clan_clock;
mod clan_combat_groups;
mod clan_combat_strength;
mod clan_mining;
@@ -1341,6 +1342,7 @@ pub struct Engine {
world: World,
loaded: Option<LoadedMissionState>,
behavior_rng_state: u32,
+ ai_rng_state: u32,
autodemo_combat: Option<unit_combat::AutoDemoCombat>,
autodemo_reinforcements: Option<autodemo::LiveReinforcements>,
production: Option<production::Production>,
@@ -1725,6 +1727,7 @@ pub fn create(services: EngineServices) -> Result<Engine, EngineError> {
world: new_world(WorldConfig),
loaded: None,
behavior_rng_state: INITIAL_BEHAVIOR_RNG_STATE,
+ ai_rng_state: 1,
autodemo_combat: None,
autodemo_reinforcements: None,
production: None,
@@ -2914,6 +2917,8 @@ pub struct SimulationReport {
pub mission_event_stops: Vec<MissionEventStop>,
/// Uncovered clan AI instructions and the number of invocations they stopped.
pub clan_ai_event_stops: Vec<(MissionEventStop, u64)>,
+ /// Executed AI clock cycles by clan; initial phase and full RNG ordering remain approximate.
+ pub clan_ai_clock_ticks: Vec<(usize, u64)>,
/// Calls to stubbed research policy or status, grouped by clan and handler.
pub clan_research_status_stubs: Vec<(usize, u8, u64)>,
pub clan_research_catalogs: Vec<(usize, usize, u32, u64)>,
@@ -2988,6 +2993,7 @@ pub fn simulate_mission_report(
mission_events: 0,
mission_event_stops: Vec::new(),
clan_ai_event_stops: Vec::new(),
+ clan_ai_clock_ticks: Vec::new(),
clan_research_status_stubs: Vec::new(),
clan_research_catalogs: Vec::new(),
laboratory: Default::default(),
@@ -3092,6 +3098,9 @@ pub fn simulate_mission_report(
.clan_research_status_stubs
.extend(loaded.clan_ai_events.research_status_stubs());
report
+ .clan_ai_clock_ticks
+ .extend(loaded.clan_ai_events.clock_ticks());
+ report
.clan_research_catalogs
.extend(loaded.clan_ai_events.research_catalogs());
report.laboratory = loaded.laboratories.report();