Spaces:
Sleeping
Sleeping
| 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. ---") | |