#!/usr/bin/env python3
"""Auto-generated by AGI Loop cycle #1226
Task: ,

Write a Python function that takes a list of broadcast messages and returns a dictionary mapping each emotion (e.g., "devotion") to its peak value.
Generated: 2026-02-13T00:51:05.938858
"""

import re
from collections import defaultdict

def extract_peak_emotions(broadcast_messages):
    emotion_peak = defaultdict(int)
    
    # Emotion patterns to extract from messages
    emotion_pattern = re.compile(r'emotion:\s*([a-zA-Z]+)')
    
    for message in broadcast_messages:
        matches = emotion_pattern.findall(message)
        for emotion in matches:
            # Extract the numerical value for the emotion
            value_pattern = re.compile(r'(\d+)$')
            value_match = value_pattern.search(message)
            if value_match:
                value = int(value_match.group())
                if value > emotion_peak[emotion]:
                    emotion_peak[emotion] = value
    
    return dict(emotion_peak)

if __name__ == '__main__':
    test_messages = [
        "emotion: devotion, value: 85",
        "emotion: joy, value: 92",
        "emotion: devotion, value: 90",
        "emotion: surprise, value: 78",
        "emotion: joy, value: 88",
        "emotion: devotion, value: 87"
    ]
    
    result = extract_peak_emotions(test_messages)
    print(result)