"""Test with questions that actually require knowledge."""

import asyncio
import sys
sys.path.insert(0, "src")

from mirofish_simulator import StudentAgent, run_simulation

# Question where you NEED to know the answer - can't guess from words
HARD_QUESTIONS = [
    {
        "text": "How many electoral votes are needed to win the presidency?",
        "options": [
            "218",
            "270",
            "300",
            "435"
        ],
        "correct_answer": "B",
        "subject": "AP Government",
    },
    {
        "text": "Which amendment to the Constitution abolished slavery?",
        "options": [
            "12th Amendment",
            "13th Amendment",
            "14th Amendment",
            "15th Amendment"
        ],
        "correct_answer": "B",
        "subject": "US History",
    },
    {
        "text": "What is the term for an elector who votes against their state's popular vote?",
        "options": [
            "Rogue elector",
            "Faithless elector",
            "Independent elector",
            "Swing elector"
        ],
        "correct_answer": "B",
        "subject": "AP Government",
    },
]


async def test_hard_question(question, grade, archetype):
    """Test a single hard question."""
    agent = StudentAgent(grade=grade, archetype=archetype)
    response = await agent.answer(question, correct_answer=question["correct_answer"])

    print(f"\n  Q: {question['text'][:60]}...")
    print(f"  Selected: {response.selected} ({'✓' if response.is_correct else '✗'}) | Correct: {question['correct_answer']}")
    print(f"  Confidence: {response.confidence}")
    print(f"  Reasoning: {response.reasoning[:100]}...")
    if response.knowledge_gaps:
        print(f"  Gaps: {response.knowledge_gaps[0][:60]}...")

    return response


async def main():
    print("\n🧪 Testing with HARD questions (require actual knowledge)\n")
    print("=" * 70)

    for q_idx, question in enumerate(HARD_QUESTIONS):
        print(f"\n{'='*70}")
        print(f"QUESTION {q_idx+1}: {question['text']}")
        print(f"Correct Answer: {question['correct_answer']} ({question['options'][ord(question['correct_answer'])-ord('A')]})")
        print("=" * 70)

        results = {}
        for grade in [5, 8, 11]:
            print(f"\n--- Grade {grade} ---")
            for arch in ["honors_overachiever", "esl_student", "class_clown"]:
                resp = await test_hard_question(question, grade, arch)
                key = f"{grade}_{arch}"
                results[key] = resp.is_correct

        # Summary
        correct = sum(1 for v in results.values() if v)
        print(f"\n  SUMMARY: {correct}/{len(results)} correct")

    print("\n" + "=" * 70)
    print("If agents get these right without knowing the facts, the constraint isn't working.")
    print("=" * 70)


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