1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//! Perception mechanic: Information accuracy and confidence.
//!
//! This module provides a policy-based system for modeling how entities
//! perceive the world, distinguishing between "ground truth" (absolute reality)
//! and "perceived reality" (what an observer believes).
//!
//! # Key Insight: Information is Uncertain
//!
//! In strategy games, players rarely have perfect information. This mechanic
//! models the gap between reality and perception:
//!
//! - **Accuracy**: How close perceived values are to ground truth
//! - **Confidence**: How reliable the information is (decays over time)
//! - **Delay**: How long until information reaches the observer
//! - **Noise**: Distortion applied based on accuracy
//!
//! # Architecture
//!
//! The perception mechanic follows **Policy-Based Design**:
//! - The core `PerceptionMechanic<P>` is generic over `PerceptionPolicy`
//! - `P: PerceptionPolicy` determines how accuracy and noise are calculated
//! - All logic is resolved at compile time via static dispatch
//!
//! # Quick Start
//!
//! ```
//! use issun_core::mechanics::perception::prelude::*;
//! use issun_core::mechanics::{Mechanic, EventEmitter};
//!
//! // Define perception type (using default FogOfWar policy)
//! type FogOfWar = PerceptionMechanic;
//!
//! // Create configuration
//! let config = PerceptionConfig::default();
//! let mut state = PerceptionState::default();
//!
//! // Prepare input: scout observing enemy troops
//! let input = PerceptionInput {
//! ground_truth: GroundTruth::quantity(1000),
//! fact_id: FactId("enemy_troops".into()),
//! observer: ObserverStats {
//! entity_id: "scout".into(),
//! capability: 0.8,
//! range: 100.0,
//! tech_bonus: 1.0,
//! traits: vec![],
//! },
//! target: TargetStats {
//! entity_id: "enemy_army".into(),
//! concealment: 0.3,
//! stealth_bonus: 1.0,
//! environmental_bonus: 1.0,
//! traits: vec![],
//! },
//! distance: 50.0,
//! rng: 0.5,
//! current_tick: 100,
//! };
//!
//! // Event collector
//! # struct TestEmitter { events: Vec<PerceptionEvent> }
//! # impl EventEmitter<PerceptionEvent> for TestEmitter {
//! # fn emit(&mut self, event: PerceptionEvent) { self.events.push(event); }
//! # }
//! let mut emitter = TestEmitter { events: vec![] };
//!
//! // Execute one step
//! FogOfWar::step(&config, &mut state, input, &mut emitter);
//!
//! // Scout perceives ~1000 troops (with noise based on accuracy)
//! assert!(state.perception.is_some());
//! assert!(state.accuracy > 0.5);
//! ```
//!
//! # Use Cases
//!
//! - **Fog of War**: Distance-based visibility in strategy games
//! - **Intelligence Networks**: Spy networks providing information with varying accuracy
//! - **Sensor Systems**: Radar/sonar detection with noise and delay
//! - **Market Information**: Price discovery with information asymmetry
//! - **Social Perception**: Reputation and relationship information
// Re-export core types
pub use ;
pub use PerceptionPolicy;
pub use ;
/// Prelude module for convenient imports.
///
/// Import everything needed to use the perception mechanic:
///
/// ```
/// use issun_core::mechanics::perception::prelude::*;
/// ```