from ..npc.npc_manager import NPCManager from ..npc.npc_base import NPC from ..npc.npc_memory_embedder import embed_npc_memories def setup_initial_scenario() -> NPCManager: """ 테스트를 위한 초기 NPC 월드를 설정하고 NPCManager를 반환합니다. - 5명의 NPC 생성 - 각기 다른 초기 성격 및 기억 부여 - NPC 간의 초기 관계 설정 """ print("새로운 시나리오를 설정합니다.: '시작의마을'") npc_manager = NPCManager() # --- 1. NPC 객체 생성 --- # 엘린: 호기심 많고 감정적인 마법사 personality_elin = {"sensitive": 0.8, "stoic": 0.3, "cognitive_bias": 0.7} elin = NPC('elin', "엘린", "마법사", personality=personality_elin) # 밥: 무뚝뚝하지만 정직한 대장장이 personality_bob = {"sensitive": 0.2, "stoic": 0.8, "cognitive_bias": 0.4} bob = NPC('bob', "밥", "대장장이", personality=personality_bob) # 앨리스: 사교적이고 계산적인 상인 personality_alice = {"sensitive": 0.5, "stoic": 0.5, "cognitive_bias": 0.8} alice = NPC('alice', "앨리스", "상인", personality=personality_alice) # 찰리: 성실하고 평화로운 농부 personality_charlie = {"sensitive": 0.6, "stoic": 0.6, "cognitive_bias": 0.3} charlie = NPC('charlie', "찰리", "농부", personality=personality_charlie) # 다이애나: 조용하고 관찰력 있는 사서 personality_diana = {"sensitive": 0.7, "stoic": 0.7, "cognitive_bias": 0.9} diana = NPC('diana', "다이애나", "사서", personality=personality_diana) # 플레이어를 위한 NPC 객체를 생성 # 플레이어는 고유 ID "Player"를 가지며, 성격은 가장 균형잡힌 상태로 시작 player_personality = {"sensitive": 0.5, "stoic": 0.5, "cognitive_bias": 0.5} player = NPC("player", "플레이어", "모험가", personality=player_personality) # --- 2. 초기 기억 주입 --- elin.remember(content="어젯밤 앨리스와 시장 가격 때문에 크게 다퉜다.", importance=8, emotion="anger") alice.remember(content="어젯밤 엘린이 내게 무례하게 소리쳤다.", importance=8, emotion="resentment") bob.remember(content="찰리가 어제 우리 집 지붕을 고쳐주어서 고맙다.", importance=7, emotion="gratitude") charlie.remember(content="밥의 대장간 일을 도와주고 빵을 얻었다. 그는 좋은 친구다.", importance=6, emotion="joy") diana.remember(content="도서관에서 밥이 책을 빌려가며 거칠게 다루어 조금 기분이 상했다.", importance=5, emotion="disgust") # --- 3. NPC 매니저에 추가 --- npc_manager.add_npc(elin) npc_manager.add_npc(bob) npc_manager.add_npc(alice) npc_manager.add_npc(charlie) npc_manager.add_npc(diana) npc_manager.add_npc(player) # --- 4. 초기 관계 설정 --- # 엘린 <-> 앨리스 (나쁜 관계) elin.relationships.update_relationship("alice", "anger", strength=5.0) alice.relationships.update_relationship("elin", "resentment", strength=4.0) # 밥 <-> 찰리 (좋은 관계) bob.relationships.update_relationship("charlie", "gratitude", strength=6.0) charlie.relationships.update_relationship("bob", "joy", strength=7.0) # 다이애나 -> 밥 (약간 부정적) diana.relationships.update_relationship("bob", "disgust", strength=3.0) # 엘린, 찰리 <-> 플레이어 (낯선 사람) elin.relationships.update_relationship("player", "neutral", strength=0.0) charlie.relationships.update_relationship("player", "neutral", strength=0.0) # --- 5. 초기 지식 베이스 설정 --- all_npc = npc_manager.get_all_npcs_except_player() # 플레이어를 제외한 NPC 목록 for npc in all_npc: for other_npc in all_npc: if npc != other_npc: npc.knowledge[other_npc.name] = { "job": other_npc.job, # 모든 NPC가 서로의 직업을 알고 시작하도록 설정 "age": other_npc.age # 모든 NPC가 서로의 나이를 알고 시작하도록 설정 } # 모든 NPC의 초기 기억을 FAISS 인덱스로 저장 print("모든 NPC의 초기 기억에 대한 FAISS 인덱스를 생성합니다...") for npc in npc_manager.all(): embed_npc_memories(npc) print("✅ '시작의 마을' 시나리오 설정이 완료되었습니다.") return npc_manager