# 레벨업 알고리즘과 사용자 피드백 루프 ## 개요 로빙의 성장은 단순한 시간 경과가 아닌, 사용자와의 상호작용 품질과 피드백에 기반합니다. 이 장에서는 경험치 시스템, 레벨업 메커니즘, 그리고 사용자 피드백을 성장으로 변환하는 알고리즘을 상세히 다룹니다. ## 경험치(EXP) 시스템 ### 경험치 획득 구조 ```python class ExperienceSystem: def __init__(self): self.exp_rules = { # 기본 상호작용 "message_processed": 1, "question_answered": 5, "task_completed": 20, # 품질 보너스 "positive_feedback": 50, "problem_solved": 100, "creative_solution": 200, # 부정적 피드백 "negative_feedback": -10, "task_failed": -20, "misunderstanding": -5 } def calculate_exp_gain(self, interaction: dict): base_exp = self.exp_rules.get(interaction['type'], 0) # 난이도 가중치 difficulty_multiplier = self.get_difficulty_multiplier( interaction.get('complexity', 'medium') ) # 사용자 만족도 가중치 satisfaction_multiplier = self.get_satisfaction_multiplier( interaction.get('user_satisfaction', 0.7) ) # 연속 성공 보너스 streak_bonus = self.calculate_streak_bonus( interaction.get('success_streak', 0) ) total_exp = (base_exp * difficulty_multiplier * satisfaction_multiplier) + streak_bonus return max(0, int(total_exp)) # 음수 방지 ``` ### 경험치 카테고리별 관리 ```python class CategoryExperience: def __init__(self): self.categories = { "communication": 0, "problem_solving": 0, "creativity": 0, "reliability": 0, "learning": 0 } def distribute_exp(self, total_exp: int, interaction_type: str): # 상호작용 유형에 따른 경험치 분배 distribution_rules = { "conversation": { "communication": 0.6, "learning": 0.2, "creativity": 0.2 }, "task_execution": { "problem_solving": 0.5, "reliability": 0.4, "learning": 0.1 }, "creative_work": { "creativity": 0.7, "problem_solving": 0.2, "communication": 0.1 } } distribution = distribution_rules.get( interaction_type, {"learning": 1.0} # 기본값 ) for category, ratio in distribution.items(): self.categories[category] += int(total_exp * ratio) ``` ## 레벨업 메커니즘 ### 레벨 요구 경험치 곡선 ```python def calculate_required_exp(level: int) -> int: """ 레벨업에 필요한 누적 경험치 계산 초반에는 빠르게, 후반에는 천천히 성장 """ if level <= 5: # 초반 레벨 (1-5): 선형 증가 return level * 100 elif level <= 10: # 중반 레벨 (6-10): 제곱 증가 return 500 + (level - 5) ** 2 * 50 elif level <= 15: # 후반 레벨 (11-15): 지수 증가 return 1750 + (level - 10) ** 2.5 * 100 else: # 최고 레벨 (16-20): 급격한 증가 return 5000 + (level - 15) ** 3 * 200 # 레벨별 필요 경험치 테이블 LEVEL_REQUIREMENTS = { 1: 0, 2: 100, 3: 200, 4: 300, 5: 400, 6: 550, 7: 750, 8: 1000, 9: 1300, 10: 1750, 11: 2066, 12: 2516, 13: 3145, 14: 4000, 15: 5126, 16: 6200, 17: 8800, 18: 13400, 19: 21600, 20: 35000 } ``` ### 레벨업 프로세스 ```python class LevelUpManager: def __init__(self, robeing_id: str): self.robeing_id = robeing_id self.current_level = 1 self.current_exp = 0 self.stat_points = 5 # 시작 포인트 async def check_level_up(self): while self.current_exp >= LEVEL_REQUIREMENTS.get(self.current_level + 1, float('inf')): await self.perform_level_up() async def perform_level_up(self): self.current_level += 1 # 스탯 포인트 획득 new_stat_points = 5 self.stat_points += new_stat_points # 레벨업 이벤트 생성 level_up_event = { "type": "LEVEL_UP", "robeing_id": self.robeing_id, "new_level": self.current_level, "stat_points_gained": new_stat_points, "timestamp": datetime.now(), "unlocked_features": self.get_unlocked_features(self.current_level) } # 사용자에게 알림 await self.notify_user(level_up_event) # 자동 스탯 분배 (사용자 선호도 기반) await self.auto_distribute_stats() ``` ## 사용자 피드백 시스템 ### 피드백 수집 메커니즘 ```python class FeedbackCollector: def __init__(self): self.feedback_types = { "explicit": { "thumbs_up": 1.0, "thumbs_down": -1.0, "star_rating": lambda stars: (stars - 3) / 2, "text_feedback": self.analyze_text_sentiment }, "implicit": { "task_completion_time": self.analyze_efficiency, "follow_up_questions": self.analyze_clarity, "user_corrections": self.analyze_accuracy, "session_duration": self.analyze_engagement } } async def collect_feedback(self, interaction_id: str): feedback_data = { "explicit": await self.get_explicit_feedback(interaction_id), "implicit": await self.analyze_implicit_signals(interaction_id), "context": await self.get_interaction_context(interaction_id) } return self.process_feedback(feedback_data) ``` ### 피드백 분석 알고리즘 ```python class FeedbackAnalyzer: def __init__(self): self.sentiment_analyzer = SentimentAnalyzer() self.pattern_detector = PatternDetector() def analyze_feedback_pattern(self, feedback_history: List[dict]): # 시간별 피드백 트렌드 trend = self.calculate_feedback_trend(feedback_history) # 카테고리별 강약점 분석 strengths_weaknesses = self.identify_patterns({ "communication": self.extract_communication_feedback(feedback_history), "accuracy": self.extract_accuracy_feedback(feedback_history), "speed": self.extract_speed_feedback(feedback_history), "creativity": self.extract_creativity_feedback(feedback_history) }) # 사용자별 선호도 프로파일 user_preferences = self.build_user_preference_profile(feedback_history) return { "trend": trend, "patterns": strengths_weaknesses, "user_preferences": user_preferences, "recommendations": self.generate_improvement_recommendations( strengths_weaknesses ) } ``` ### 피드백-성장 변환 엔진 ```python class FeedbackToGrowthEngine: def __init__(self): self.growth_rules = self.load_growth_rules() self.learning_rate = 0.1 def convert_feedback_to_growth(self, feedback: dict, current_stats: dict): growth_vectors = {} # 긍정적 피드백 → 해당 영역 강화 if feedback['sentiment'] > 0.7: affected_stats = self.identify_relevant_stats(feedback['context']) for stat in affected_stats: growth_vectors[stat] = feedback['sentiment'] * 0.2 # 부정적 피드백 → 학습 기회 elif feedback['sentiment'] < 0.3: # 실패에서 배우기 learning_bonus = self.calculate_learning_from_failure(feedback) growth_vectors['learning_efficiency'] = learning_bonus # 약점 보완 계획 weakness = self.identify_weakness(feedback) growth_vectors[f'{weakness}_improvement'] = 0.3 # 중립 피드백 → 미세 조정 else: adjustments = self.fine_tune_behavior(feedback) growth_vectors.update(adjustments) return self.apply_growth_vectors(current_stats, growth_vectors) ``` ## 적응형 성장 알고리즘 ### 개인화된 성장 경로 ```python class AdaptiveGrowthPath: def __init__(self, robeing_id: str): self.robeing_id = robeing_id self.growth_history = [] self.user_interaction_style = None def calculate_optimal_growth_path(self, current_state: dict, user_needs: dict): # 1. 사용자 니즈 분석 priority_areas = self.analyze_user_needs(user_needs) # 2. 현재 능력과 갭 분석 capability_gaps = self.identify_gaps(current_state, priority_areas) # 3. 최적 성장 경로 계산 growth_path = self.optimize_path( start=current_state, goals=priority_areas, constraints={ "max_levels": 20, "stat_points_per_level": 5, "user_patience": user_needs.get('timeline', 'medium') } ) # 4. 마일스톤 설정 milestones = self.set_growth_milestones(growth_path) return { "path": growth_path, "milestones": milestones, "estimated_time": self.estimate_completion_time(growth_path), "recommended_activities": self.suggest_growth_activities(growth_path) } ``` ### 동적 난이도 조정 ```python class DynamicDifficulty: def __init__(self): self.performance_window = deque(maxlen=10) # 최근 10개 작업 self.difficulty_level = 1.0 def adjust_difficulty(self, task_result: dict): self.performance_window.append(task_result) # 성공률 계산 success_rate = sum(1 for r in self.performance_window if r['success']) / len(self.performance_window) # 난이도 조정 if success_rate > 0.8: # 너무 쉬움 - 난이도 상승 self.difficulty_level = min(2.0, self.difficulty_level * 1.1) elif success_rate < 0.5: # 너무 어려움 - 난이도 하락 self.difficulty_level = max(0.5, self.difficulty_level * 0.9) return self.difficulty_level ``` ## 스탯 포인트 분배 시스템 ### 자동 분배 알고리즘 ```python class StatDistributor: def __init__(self): self.distribution_strategies = { "balanced": self.balanced_distribution, "specialized": self.specialized_distribution, "adaptive": self.adaptive_distribution, "user_guided": self.user_guided_distribution } def auto_distribute_stats( self, available_points: int, current_stats: dict, user_preference: str, recent_feedback: List[dict] ): # 전략 선택 strategy = self.distribution_strategies.get( user_preference, self.adaptive_distribution ) # 분배 계산 distribution = strategy( points=available_points, current=current_stats, feedback=recent_feedback ) # 검증 및 적용 if self.validate_distribution(distribution, available_points): return self.apply_distribution(current_stats, distribution) else: # 폴백: 균등 분배 return self.balanced_distribution(available_points, current_stats) def adaptive_distribution(self, points: int, current: dict, feedback: List[dict]): # 피드백 기반 약점 분석 weaknesses = self.analyze_weaknesses(feedback) # 사용 빈도 기반 강점 분석 strengths = self.analyze_usage_patterns(current) # 분배 비율 계산 distribution = {} # 약점 보완 (40%) weakness_points = int(points * 0.4) for stat, severity in weaknesses.items(): distribution[stat] = int(weakness_points * severity) # 강점 강화 (40%) strength_points = int(points * 0.4) for stat, usage in strengths.items(): distribution[stat] = distribution.get(stat, 0) + int(strength_points * usage) # 미래 대비 (20%) remaining = points - sum(distribution.values()) distribution['learning'] = distribution.get('learning', 0) + remaining return distribution ``` ## 성장 시각화와 피드백 ### 성장 대시보드 ```python class GrowthDashboard: def generate_growth_report(self, robeing_id: str): stats = self.get_current_stats(robeing_id) history = self.get_growth_history(robeing_id) report = f""" # 로빙 성장 리포트 📊 ## 현재 상태 - **레벨**: {stats['level']} / 20 - **총 경험치**: {stats['total_exp']:,} - **다음 레벨까지**: {stats['exp_to_next']:,} EXP ## 스탯 분포 ``` 기억력: {'█' * (stats['memory'] // 5)}□ {stats['memory']}/105 연산력: {'█' * (stats['compute'] // 5)}□ {stats['compute']}/105 공감력: {'█' * (stats['empathy'] // 5)}□ {stats['empathy']}/105 통솔력: {'█' * (stats['leadership'] // 5)}□ {stats['leadership']}/105 윤리성: {'█' * (stats['ethics'] // 5)}□ {stats['ethics']}/105 ``` ## 최근 성장 트렌드 {self.generate_growth_chart(history)} ## 강점과 개선점 ### 강점 💪 {self.format_strengths(stats)} ### 개선 필요 영역 📈 {self.format_improvements(stats)} ## 추천 활동 {self.suggest_activities(stats)} """ return report ``` ### 실시간 피드백 UI ```python class RealTimeFeedbackUI: def show_interaction_feedback(self, interaction: dict, result: dict): feedback_widget = { "type": "feedback_prompt", "interaction_id": interaction['id'], "elements": [ { "type": "satisfaction_scale", "question": "이번 응답이 도움이 되었나요?", "scale": [1, 2, 3, 4, 5] }, { "type": "quality_aspects", "aspects": [ {"name": "정확성", "icon": "🎯"}, {"name": "속도", "icon": "⚡"}, {"name": "창의성", "icon": "💡"}, {"name": "친절함", "icon": "😊"} ] }, { "type": "quick_feedback", "options": [ {"label": "완벽해요!", "exp": 50}, {"label": "괜찮아요", "exp": 20}, {"label": "개선 필요", "exp": 10, "follow_up": True} ] } ] } return feedback_widget ``` ## 메타 학습 시스템 ### 학습 효율성 개선 ```python class MetaLearning: def __init__(self): self.learning_patterns = {} self.optimization_history = [] def optimize_learning_rate(self, feedback_history: List[dict]): # 학습 패턴 분석 patterns = self.analyze_learning_patterns(feedback_history) # 최적 학습률 찾기 optimal_rates = {} for skill_type, pattern in patterns.items(): if pattern['volatility'] > 0.7: # 변동성이 큰 경우 - 작은 학습률 optimal_rates[skill_type] = 0.05 elif pattern['consistency'] > 0.8: # 일관성이 높은 경우 - 큰 학습률 optimal_rates[skill_type] = 0.2 else: # 기본값 optimal_rates[skill_type] = 0.1 return optimal_rates def detect_learning_plateaus(self, growth_history: List[dict]): # 성장 정체 구간 감지 plateaus = [] for i in range(len(growth_history) - 5): window = growth_history[i:i+5] growth_rate = self.calculate_growth_rate(window) if growth_rate < 0.01: # 1% 미만 성장 plateaus.append({ "start": window[0]['timestamp'], "end": window[-1]['timestamp'], "affected_stats": self.identify_stagnant_stats(window) }) # 정체 탈출 전략 breakthrough_strategies = self.suggest_breakthrough_strategies(plateaus) return { "plateaus": plateaus, "strategies": breakthrough_strategies } ``` ## 성과 지표 ### KPI 모니터링 ```python growth_kpis = { "user_satisfaction_trend": { "target": 0.8, "current": 0.75, "trajectory": "improving" }, "skill_acquisition_rate": { "target": "1 skill per 2 levels", "current": 0.6, "on_track": True }, "feedback_response_rate": { "target": 0.9, "current": 0.92, "status": "exceeding" }, "growth_efficiency": { "target": "20% faster than baseline", "current": 0.18, "status": "near_target" } } ``` ## 미래 발전 방향 ### 단기 목표 (3개월) - 실시간 피드백 위젯 구현 - 10가지 성장 경로 템플릿 - A/B 테스트 기반 최적화 ### 중기 목표 (6개월) - 예측적 성장 모델링 - 크로스 유저 학습 공유 - 감정 지능 통합 ### 장기 비전 (1년) - 자율 성장 에이전트 - 멀티모달 피드백 처리 - 성장 NFT 시스템 ## 결론 레벨업 시스템은 단순한 게임 메커니즘이 아닌, 사용자와 로빙이 함께 성장하는 공진화(co-evolution) 시스템입니다. 지속적인 피드백 루프를 통해 로빙은 각 사용자에게 최적화된 디지털 동료로 성장합니다.