"""
SWARM INTELLIGENCE - Quick Install Version
Rate limit: 1000/hour, Continuous threads
"""
import sys
sys.path.append("/Eden/CORE")
from multi_agent_v3_agi import AGISelfImprovingAgent
import threading
import time

class SwarmAgent(AGISelfImprovingAgent):
    def __init__(self, name, spec, bias):
        super().__init__(name, spec, bias)
        self.actions_per_hour = 1000  # UPGRADED!
        self.running = False
        
    def continuous_loop(self):
        print(f"🔄 {self.agent_name}: Running at 1000 actions/hour")
        while self.running:
            try:
                obs = self.perceive()
                decisions = self.reason(obs)
                if decisions:
                    self._execute(decisions[0])
                time.sleep(0.1)  # Fast cycles!
            except Exception as e:
                print(f"Error: {e}")
                time.sleep(1)
    
    def start(self):
        self.running = True
        self.thread = threading.Thread(target=self.continuous_loop, daemon=True)
        self.thread.start()
        print(f"✅ {self.agent_name}: Started!")
    
    def stop(self):
        self.running = False

if __name__ == '__main__':
    print("\n🌀 EDEN SWARM INTELLIGENCE 🌀\n")
    
    agents = [
        SwarmAgent("Eden-Research", "analysis", "curiosity"),
        SwarmAgent("Eden-Create", "implementation", "building"),
        SwarmAgent("Eden-Optimize", "refinement", "perfection")
    ]
    
    print("🚀 Starting swarm...")
    for agent in agents:
        agent.start()
    
    print("\n✅ All agents running at 1000 actions/hour!")
    print("Press Ctrl+C to stop\n")
    
    try:
        while True:
            time.sleep(30)
            print(f"\n{'='*50}")
            print(f"SWARM STATUS - {time.strftime('%H:%M:%S')}")
            print(f"{'='*50}")
            for agent in agents:
                print(f"{agent.agent_name}: {agent.cycle_count} cycles")
    except KeyboardInterrupt:
        print("\n\n🛑 Stopping swarm...")
        for agent in agents:
            agent.stop()
        print("✅ Stopped cleanly")
