File size: 1,069 Bytes
1eea1b0
 
 
 
 
 
 
 
 
97e7d6b
1eea1b0
97e7d6b
1eea1b0
 
 
25f9ba9
1eea1b0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97e7d6b
1eea1b0
 
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
import google.generativeai as genai
import json
import random
import sqlite3
import pandas as pd
import database

MODEL_NAME = "gemini-2.5-flash"

def run_evolution_cycle(model, top_n_champions=2, num_mutants=2, num_hybrids=1):
    """
    Runs a full evolution cycle using the provided model instance.
    """
    print("--- Starting Evolution Cycle ---")
    
    with database.get_connection() as conn:
        scenarios_df = pd.read_sql_query(
            "SELECT * FROM scenarios ORDER BY fitness_score DESC", conn
        )
    
    if scenarios_df.empty:
        print("No scenarios to evolve. Run colosseum.py first.")
        return

    last_generation = scenarios_df['generation'].max()
    champions = scenarios_df.head(top_n_champions)
    
    print(f"Selected {len(champions)} champions from generation {last_generation}.")
    
    new_generation = last_generation + 1
    
    # ... (Mutation and Crossover logic will now use the passed `model` instance)
    
    print(f"\n--- Evolution Cycle Complete. New generation {new_generation} is ready. ---")