t1 = Turn.find_by(number: 1)
t2 = Turn.find_by(number: 2)

def summarize_gs(gs)
  return "nil" if gs.nil?
  gs = JSON.parse(gs) if gs.is_a?(String)
  # APIレスポンス全体の可能性も考慮
  gs = gs['game_state'] if gs.is_a?(Hash) && gs.has_key?('game_state')
  
  {
    phase: gs['phase'],
    units_count: gs['units']&.values&.flatten&.size,
    units_sample: gs['units']&.values&.first(2),
    centers_count: gs['centers']&.values&.flatten&.size
  }
end

puts "--- Turn 1 Summary ---"
puts summarize_gs(t1&.game_state)

puts "\n--- Turn 2 Summary ---"
if t2
  puts summarize_gs(t2.game_state)
  puts "\nPossible Orders for AUSTRIA in Turn 2:"
  puts (t2.possible_orders&.dig("possible_orders", "AUSTRIA") || "Not found").inspect[0..500]
else
  puts "Turn 2 not found."
end
