#!/usr/bin/env python3
"""
Demo of the MiroFish Agentic Student Simulator.

This demonstrates the misconception-matching approach that produces
realistic student responses instead of LLM "cheating".
"""

import asyncio
import os
import sys

# Add parent src to path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "src"))

from mirofish_simulator import AgenticOrchestrator


async def main():
    """Run a quick demo of the agentic simulator."""

    # Initialize orchestrator
    orchestrator = AgenticOrchestrator()

    # Test question
    question = {
        "text": "How many electoral votes are needed to win the U.S. presidential election?",
        "options": ["218", "270", "300", "435"],
    }

    print("=" * 60)
    print("MiroFish Agentic Student Simulator Demo")
    print("=" * 60)
    print(f"\nQuestion: {question['text']}")
    print(f"Options: A) 218  B) 270  C) 300  D) 435")
    print(f"Correct: B) 270")
    print()

    # Simulate different students
    students = [
        {"grade": 5, "archetype": "class_clown"},
        {"grade": 8, "archetype": "average_student"},
        {"grade": 11, "archetype": "honors_overachiever"},
    ]

    print("Simulating students...")
    print("-" * 60)

    for student in students:
        result = await orchestrator.simulate(
            question=question,
            correct_answer="B",
            grade=student["grade"],
            archetype=student["archetype"],
        )

        status = "✓" if result.is_correct else "✗"
        print(f"\nGrade {result.grade} {result.archetype}:")
        print(f"  Answer: {result.selected}) {result.selected_text} {status}")
        print(f"  Familiarity: {result.student_model.topic_familiarity:.0%}")
        print(f"  Confidence: {result.selection_result.confidence}")

        if result.selection_result.misconception_matched:
            print(f"  Misconception: {result.selection_result.misconception_matched[:50]}...")
        else:
            print(f"  Based on: Correct belief")

    print("\n" + "=" * 60)
    print("Demo complete!")


if __name__ == "__main__":
    asyncio.run(main())
