File size: 1,552 Bytes
7415e01
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""
CivicAI Analyst Agent

Interfaces with the environment to summarize real-world context, 
historical trends, and current emergencies for the Policy maker.
"""
from __future__ import annotations
from civicai.models import SocietyState, AgentMessage

class AnalystAgent:
    def __init__(self, name: str = "AnalystAgent", role: str = "📊 Chief Analyst"):
        self.name = name
        self.role = role

    def analyze_state(self, state: SocietyState) -> AgentMessage:
        """Analyze current state and active events."""
        warnings = []
        if state.inflation > 0.08:
            warnings.append(f"Inflation is extremely high ({state.inflation:.1%}). Fiscal tightening needed.")
        if state.employment_rate < 0.80:
            warnings.append(f"High unemployment ({1-state.employment_rate:.1%}). Consider stimulus or education.")
        if state.public_satisfaction < 0.40:
            warnings.append("Public satisfaction critically low. Risk of severe unrest.")
            
        events_str = ", ".join(state.active_events) if state.active_events else "None"
        
        reasoning = (
            f"GDP Growth: {state.gdp_growth:.2%}, Inflation: {state.inflation:.2%}, "
            f"Active Events: {events_str}. "
            f"Warnings: {' '.join(warnings) if warnings else 'None.'}"
        )
        
        return AgentMessage(
            agent_name=self.name,
            agent_role=self.role,
            proposal="Data Analysis Complete. Awaiting Policy action.",
            reasoning=reasoning
        )