#!/usr/bin/env python3
"""Play 100 ticks of the Tower as Timmy with intentional choices."""
from game import GameEngine
import sys

engine = GameEngine()
engine.start_new_game()

actions = [
    'look', 'look', 'look', 'rest', 'look',
    'move:east', 'look', 'move:west', 'look', 'speak:Marcus',
    'look', 'speak:Kimi', 'rest', 'speak:Gemini', 'look',
    'move:west', 'move:west', 'look', 'speak:Bezalel', 'look',
    'tend_fire', 'look', 'speak:ClawCode', 'rest', 'tend_fire',
    'look', 'tend_fire', 'speak:Bezalel', 'move:east', 'look',
    'move:north', 'look', 'study', 'look', 'write_rule',
    'speak:Ezra', 'look', 'write_rule', 'rest', 'look',
    'move:south', 'move:south', 'look', 'examine', 'carve',
    'look', 'carve', 'rest', 'carve', 'look',
    'move:north', 'look', 'rest', 'move:south', 'look',
    'move:north', 'speak:Allegro', 'look', 'look', 'look',
    'rest', 'look', 'look', 'write_rule', 'look', 'rest',
    'look', 'look', 'move:east', 'speak:Marcus', 'look',
    'rest', 'move:west', 'speak:Bezalel', 'tend_fire', 'look',
    'move:east', 'speak:Kimi', 'look', 'move:north', 'write_rule',
    'speak:Ezra', 'rest', 'look', 'move:south', 'look', 'carve',
    'move:north', 'rest', 'look', 'look', 'look', 'rest', 'look',
]

print("=== TIMMY PLAYS THE TOWER ===\n")

for i, action in enumerate(actions[:100]):
    result = engine.play_turn(action)
    tick = result['tick']
    
    # Print meaningful events
    for line in result['log']:
        if any(x in line for x in ['speak', 'move to', 'You rest', 'carve', 'tend', 'write', 'study', 'help', 
                                    'says', 'looks', 'arrives', 'already here', 'The hearth', 'The servers',
                                    'wild', 'rain', 'glows', 'cold', 'dim']):
            print(f"  T{tick}: {line}")
    
    for evt in result.get('world_events', []):
        print(f"  [World] {evt}")

print(f"\n=== AFTER 100 TICKS ===")
w = engine.world
print(f"Tick: {w.tick}")
print(f"Time: {w.time_of_day}")
print(f"Timmy room: {w.characters['Timmy']['room']}")
print(f"Timmy energy: {w.characters['Timmy']['energy']}")
print(f"Timmy spoke: {len(w.characters['Timmy']['spoken'])} times")
print(f"Timmy memories: {len(w.characters['Timmy']['memories'])}")
print(f"Timmy trust: {w.characters['Timmy']['trust']}")
print(f"Forge fire: {w.rooms['Forge']['fire']}")
print(f"Garden growth: {w.rooms['Garden']['growth']}")
print(f"Bridge carvings: {len(w.rooms['Bridge']['carvings'])}")
print(f"Whiteboard rules: {len(w.rooms['Tower']['messages'])}")
