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
114
115
116
117
//! Delegation mechanic: Directive handling and compliance dynamics.
//!
//! This module provides a policy-based system for modeling how entities
//! respond to directives, commands, requests, and tasks from others.
//!
//! # Key Insight: Delegation is a Spectrum
//!
//! Rather than binary "obey/disobey", delegation models a continuous spectrum:
//! - **Compliance** (-1.0 to 1.0): How faithfully the delegate follows the directive
//! - **Interpretation** (0.0 to 1.0): How much creative freedom the delegate takes
//! - **Priority** (0.0 to 1.0): How important the delegate considers the directive
//! - **Response**: Accept, AcceptWithReservation, Defer, Ignore, or Defy
//!
//! # Architecture
//!
//! The delegation mechanic follows **Policy-Based Design**:
//! - The core `DelegationMechanic<P>` is generic over `DelegationPolicy`
//! - `P: DelegationPolicy` determines how compliance and responses are calculated
//! - All logic is resolved at compile time via static dispatch
//!
//! # Quick Start
//!
//! ```
//! use issun_core::mechanics::delegation::prelude::*;
//! use issun_core::mechanics::{Mechanic, EventEmitter};
//!
//! // Define delegation type
//! type SimpleDelegation = DelegationMechanic<SimpleDelegationPolicy>;
//!
//! // Create configuration
//! let config = DelegationConfig::default();
//! let mut state = DelegationState::default();
//!
//! // Prepare input
//! let input = DelegationInput {
//! directive: Directive {
//! id: DirectiveId("order_001".into()),
//! directive_type: DirectiveType::Command {
//! target: "outpost".into(),
//! action: "defend".into(),
//! },
//! urgency: 0.8,
//! importance: 0.9,
//! issued_at: 100,
//! },
//! delegator: DelegatorStats {
//! entity_id: EntityId("commander".into()),
//! authority: 0.9,
//! charisma: 0.7,
//! hierarchy_rank: 0,
//! reputation: 0.8,
//! },
//! delegate: DelegateStats {
//! entity_id: EntityId("soldier".into()),
//! loyalty: 0.8,
//! morale: 0.7,
//! relationship: 0.6,
//! hierarchy_rank: 2,
//! personality: DelegateTrait::Loyal,
//! workload: 0.3,
//! skill_level: 0.75,
//! },
//! current_tick: 100,
//! };
//!
//! // Event collector
//! # struct TestEmitter { events: Vec<DelegationEvent> }
//! # impl EventEmitter<DelegationEvent> for TestEmitter {
//! # fn emit(&mut self, event: DelegationEvent) { self.events.push(event); }
//! # }
//! let mut emitter = TestEmitter { events: vec![] };
//!
//! // Execute one step
//! SimpleDelegation::step(&config, &mut state, input, &mut emitter);
//!
//! // Loyal soldier accepts command
//! assert_eq!(state.response, ResponseType::Accept);
//! ```
//!
//! # Use Cases
//!
//! - **Military Command**: Orders with strict compliance expectations
//! - **Ally Requests**: Cooperative tasks with relationship-based compliance
//! - **NPC Tasks**: Delegating work to party members or hired help
//! - **Faction Politics**: Negotiating compliance through authority and reputation
// Re-export core types
pub use ;
pub use DelegationPolicy;
pub use ;
/// Prelude module for convenient imports.
///
/// Import everything needed to use the delegation mechanic:
///
/// ```
/// use issun_core::mechanics::delegation::prelude::*;
/// ```