File size: 4,519 Bytes
97627cd
 
d57920f
97627cd
6fe0d0c
97627cd
 
 
 
 
 
 
 
 
 
 
 
d57920f
97627cd
 
 
d57920f
97627cd
 
 
d57920f
97627cd
 
 
d57920f
97627cd
 
 
d57920f
97627cd
1a6fb12
 
 
a147abc
1a6fb12
97627cd
 
6fe0d0c
97627cd
 
 
 
 
 
 
 
 
 
1a6fb12
97627cd
 
f1c565e
d57920f
 
97627cd
 
d57920f
 
97627cd
 
d57920f
 
1a6fb12
 
 
 
a147abc
e01cc89
a147abc
 
 
 
 
 
 
d57920f
 
 
 
97627cd
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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