Spaces:
Sleeping
Sleeping
Test step
Browse files- .gitattributes +2 -1
- npc_social_network/README.txt +212 -0
- npc_social_network/npc/emotion_config.py +20 -1
- npc_social_network/npc/npc_base.py +18 -7
.gitattributes
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
*.ipynb text eol=lf
|
2 |
-
*.bat text eol=
|
3 |
*.sh text eol=lf
|
|
|
4 |
*.png filter=lfs diff=lfs merge=lfs -text
|
|
|
1 |
*.ipynb text eol=lf
|
2 |
+
*.bat text eol=lf
|
3 |
*.sh text eol=lf
|
4 |
+
*.txt text eol=lf
|
5 |
*.png filter=lfs diff=lfs merge=lfs -text
|
npc_social_network/README.txt
ADDED
@@ -0,0 +1,212 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# ๐ง README - NPC ์์
๋คํธ์ํฌ AI ์๋ฎฌ๋ ์ด์
|
2 |
+
|
3 |
+
๋ณธ ๋ฌธ์๋ ๋ณธ ํ๋ก์ ํธ๋ฅผ **์ ๋ก ๋ฒ ์ด์ค์์ ์์ ์ฌํ**ํ ์ ์๋๋ก ์ค๊ณ๋์์ต๋๋ค.
|
4 |
+
์ง๊ธ๊น์ง์ ๊ตฌ์กฐ, ์ค๊ณ ์ฒ ํ, ๊ตฌํ ๋จ๊ณ, ๊ฐ ํ์ผ ๊ธฐ๋ฅ์ **๋จ ํ๋์ ๋ฌธ์๋ก ์์ ํ๊ฒ ์ ๋ฆฌ**ํ ๊ณต์ ๋ฌธ์์
๋๋ค.
|
5 |
+
|
6 |
+
---
|
7 |
+
|
8 |
+
## ๐ ํ๋ก์ ํธ ๊ฐ์ (Overview)
|
9 |
+
|
10 |
+
์ด ํ๋ก์ ํธ๋ ๊ฐ์ , ๊ธฐ์ต, ์ฑ๊ฒฉ, ๊ด๊ณ, ํ๋์ ๊ธฐ๋ฐ์ผ๋ก ํ **์ธ๊ฐ ์ ์ฌ NPC ์๋ฎฌ๋ ์ด์
**์
๋๋ค.
|
11 |
+
ํ๋ ์ด์ด์์ ๋ํ, NPC ๊ฐ ์ํธ์์ฉ, ์๊ฐ ํ๋ฆ์ ๋ฐ๋ฅธ ๊ฐ์ ๋ณํ ๋ฑ์ ๋ฐ์ํ๋ฉฐ,
|
12 |
+
LLM๊ณผ embedding ๊ธฐ๋ฐ ๊ธฐ์ต ์์คํ
์ ํตํด ์ ๊ตํ NPC ๋ฐ์์ ๊ตฌ์ฑํฉ๋๋ค.
|
13 |
+
|
14 |
+
---
|
15 |
+
|
16 |
+
## ๐ ํด๋ ๊ตฌ์กฐ
|
17 |
+
|
18 |
+
```
|
19 |
+
portfolio/
|
20 |
+
โโโ app.py # Flask ์ง์
์
|
21 |
+
โโโ requirements.txt
|
22 |
+
โโโ run_npc_interactions.py
|
23 |
+
โโโ test.ipynb
|
24 |
+
โโโ npc_social_network/
|
25 |
+
โโโ README.txt
|
26 |
+
โโโ routes/
|
27 |
+
โ โโโ npc_route.py # ์น ๋ผ์ฐํธ (API)
|
28 |
+
โโโ maps/
|
29 |
+
โ โโโ villages/town_hall.py # Pygame ๋ฉ์ธ ์คํ
|
30 |
+
โ โโโ engine/game_engine.py # ๊ฒ์ ๋ฃจํ, ๊ฐ์ HUD
|
31 |
+
โ โโโ manager/
|
32 |
+
โ โโโ tile.py # Tile ํด๋์ค
|
33 |
+
โ โโโ building.py # ๊ฑด๋ฌผ ํด๋์ค
|
34 |
+
โ โโโ image_loader.py # ์ด๋ฏธ์ง ๋ก๋ฉ
|
35 |
+
โ โโโ image_registry.py # ์ด๋ฏธ์ง ๊ฒฝ๋ก ์ฌ์
|
36 |
+
โ โโโ village_map.py # Village ์ ์ฒด ๊ตฌ์ฑ
|
37 |
+
โโโ npc/
|
38 |
+
โ โโโ npc_base.py # NPC ๋ณธ์ฒด (๊ฐ์ /๊ธฐ์ต/๊ด๊ณ ํฌํจ)
|
39 |
+
โ โโโ npc_manager.py # NPC ๋ฆฌ์คํธ ๊ด๋ฆฌ
|
40 |
+
โ โโโ npc_emotion.py # EmotionManager
|
41 |
+
โ โโโ npc_memory.py # Memory / MemoryStore
|
42 |
+
โ โโโ npc_behavior.py # ๊ฐ์ โ ํ๋ ๋งคํ
|
43 |
+
โ โโโ npc_relationship.py # ๊ด๊ณ ์ ์ ๊ด๋ฆฌ
|
44 |
+
โ โโโ npc_memory_embedder.py # ๊ธฐ์ต ์๋ฒ ๋ฉ + FAISS ๊ฒ์
|
45 |
+
โ โโโ emotion_config.py # ๊ฐ์ ๊ตฌ์กฐ ์ ์
|
46 |
+
โ โโโ personality_config.py # ์ฑ๊ฒฉ ๋ฐ ๋์ด ํ๋กํ
|
47 |
+
โโโ models/
|
48 |
+
โ โโโ llm_helper.py # ๊ฐ์ ์ถ๋ก , ์๋ต ์์ฑ
|
49 |
+
โ โโโ llm_prompt_builder.py # ํ๋กฌํํธ ์์ฑ
|
50 |
+
โโโ templates/
|
51 |
+
โ โโโ chat.html # ์ฑํ
UI
|
52 |
+
โ โโโ base.html # ๊ณตํต ํ
ํ๋ฆฟ
|
53 |
+
โ โโโ test_memory_tools.html # ์๋ฒ ๋ฉ ํ
์คํธ์ฉ ํ์ด์ง
|
54 |
+
โโโ static/
|
55 |
+
โโโ css/style.css
|
56 |
+
โโโ js/npc_chat.js
|
57 |
+
|
58 |
+
```
|
59 |
+
|
60 |
+
---
|
61 |
+
|
62 |
+
## ๐ก ๊ฐ์ ๊ตฌ์กฐ (๊ณ ์ฐจ์ ๊ฐ์ ๋ชจ๋ธ)
|
63 |
+
|
64 |
+
> โ
โGoEmotions ๊ธฐ๋ฐโ์ด ์๋์ ์ฃผ์!
|
65 |
+
> โ
๋์ **GoEmotions์์ ์๊ฐ์ ๋ฐ์ ์ง์ ์ฌ์ค๊ณํ 4๊ณ์ธต ๊ฐ์ ๋ชจ๋ธ (ComplexEmotions)**
|
66 |
+
|
67 |
+
| ๊ณ์ธต (Layer) | ๊ฐ์ ์์ |
|
68 |
+
|--------------|------------|
|
69 |
+
| `core` | joy, sadness, anger, fear, disgust, surprise, neutral |
|
70 |
+
| `social` | gratitude, shame, empathy, pride, jealousy, compassion, love, admiration, awe, attachment, comfort |
|
71 |
+
| `cognitive` | anticipation, curiosity, confusion, interest, engagement, boredom, relief, anxiety, calm, skepticism |
|
72 |
+
| `complex` | nostalgia, bittersweet, schadenfreude, resentment, anticipatory_joy, regret, rumination, hope, groundedness |
|
73 |
+
|
74 |
+
- ๊ฐ์ ์ ๊ฐ์ฑ(`sensitive`, `stoic`, `*_bias`)์ ๋ฐ๋ผ ๊ฐ์ ๋ฐ์ ๋ฐ decay ์๋๊ฐ ๋ฌ๋ผ์ง๋๋ค.
|
75 |
+
- ๊ฐ์ ์ ํ๋, ๊ธฐ์ต ์์ฑ, ๊ด๊ณ ๋ณํ, ์ฑ๊ฒฉ ๋ณํ์ ์ง์ ๋ฐ์๋ฉ๋๋ค.
|
76 |
+
|
77 |
+
---
|
78 |
+
|
79 |
+
## ๐ง ํต์ฌ ์์คํ
์ค๋ช
|
80 |
+
|
81 |
+
### โ
๊ฐ์ ์์คํ
|
82 |
+
- `EmotionManager`: ๊ฐ์ ๋ฒํผ ๊ด๋ฆฌ, decay, ๊ฐ์ ์
๋ฐ์ดํธ
|
83 |
+
- ๊ฐ์ ์ ์ต๋ 100.0๊น์ง ๋์ ๋๋ฉฐ, decay๋ personality์ ์ฐ๊ณ๋จ
|
84 |
+
- ๊ฐ์ ์ ํ๋ ์์ฑ, ๊ธฐ์ต ์ ์ฅ ๊ฐ๋, ๊ด๊ณ ์ํฅ, ์ฑ๊ฒฉ ๋ณํ์ ๊ธฐ๋ฐ์ด ๋จ
|
85 |
+
|
86 |
+
### โ
๊ธฐ์ต ์์คํ
|
87 |
+
- `Memory`: content, timestamp, importance, emotion, type ๋ณด์
|
88 |
+
- `MemoryStore`: ๋จ๊ธฐ/์ฅ๊ธฐ ๊ธฐ์ต ๋ถ๋ฆฌ, decay, ์น๊ฒฉ, ๊ฒ์ ๊ธฐ๋ฅ ํฌํจ
|
89 |
+
- decay๋ memory_type๋ณ๋ก ๋ค๋ฅด๊ฒ ์ ์ฉ๋จ
|
90 |
+
|
91 |
+
### โ
์ฑ๊ฒฉ ์์คํ
|
92 |
+
- `PERSONALITY_PROFILE`: stable/emotional/logical
|
93 |
+
- `AGE_PROFILE`: ์ธ์ ๋จ๊ณ๋ณ ๋ณํ์จ (์: ์ด๋ฆฐ์ด๋ ๋น ๋ฆ)
|
94 |
+
- ๊ธฐ์ต์ ๊ธฐ๋ฐํด personality gradually drift (ex: ๊ฐ์ ์ ์ด๊ฑฐ๋ ์ด์ฑ์ ์ฑํฅ ๊ฐํ)
|
95 |
+
|
96 |
+
### โ
๊ด๊ณ ์์คํ
|
97 |
+
- `RelationshipManager`: -100 ~ +100 ๋ฒ์์ ๊ด๊ณ ์ ์ ๊ด๋ฆฌ
|
98 |
+
- ๊ฐ์ ํํ ๋ฐ ๊ธฐ์ต์ด ๊ด๊ณ์ ์ํฅ์ ์ค (`reflect_memory_on_relationship`)
|
99 |
+
|
100 |
+
### โ
ํ๋ ์์คํ
|
101 |
+
- ๊ฐ์ โ ํ๋ ์ํ์ค๋ก ๋ณํ (`BehaviorManager`)
|
102 |
+
- ํ๋์ ๊ธฐ์ต์ ๊ธฐ๋ก๋๊ณ , ๋ค์ ๊ฐ์ ์ ์ํฅ์ ์ค (์ญ๋งคํ)
|
103 |
+
|
104 |
+
### โ
LLM ์์คํ
|
105 |
+
- `query_llm_for_emotion`: ๊ฐ์ ์ถ๋ก ์ฉ LLM ํธ์ถ
|
106 |
+
- `query_llm_with_prompt`: ๋์ฌ ์์ฑ์ฉ LLM ํธ์ถ
|
107 |
+
- `build_npc_prompt`: ๊ฐ์ /๊ธฐ์ต ๊ธฐ๋ฐ ํ๋กฌํํธ ์์ฑ
|
108 |
+
- `summarize_memories`: ์ฅ๊ธฐ ๏ฟฝ๏ฟฝ์ต ์์ฝ
|
109 |
+
|
110 |
+
### โ
์๋ฒ ๋ฉ ์์คํ
|
111 |
+
- `npc_memory_embedder.py`:
|
112 |
+
- `embed_npc_memories`: FAISS ์ ์ฅ
|
113 |
+
- `search_similar_memories`: ์ง์ ์ ์ฌ๋ ๊ฒ์
|
114 |
+
- ๋ชจ๋ธ: `all-MiniLM-L6-v2` ์ฌ์ฉ ์ค
|
115 |
+
|
116 |
+
---
|
117 |
+
|
118 |
+
## ๐ ์ฃผ์ ์ํ์ค ํ๋ฆ
|
119 |
+
|
120 |
+
### ๐จ๏ธ `interact_with_player()` ์ ์ฒด ํ๋ฆ
|
121 |
+
1. LLM์ผ๋ก ๊ฐ์ ์ถ๋ก (`query_llm_for_emotion`)
|
122 |
+
2. ๊ธฐ์ต ๊ฒ์ (FAISS + embedding)
|
123 |
+
3. LLM ํ๋กฌํํธ ์์ฑ (`build_npc_prompt`)
|
124 |
+
4. ์๋ต ์์ฑ + ๊ธฐ์ต ์ ์ฅ
|
125 |
+
5. ๊ฐ์ ์
๋ฐ์ดํธ (`update_emotion`)
|
126 |
+
6. ๊ด๊ณ ๋ณํ ๋ฐ์ (`reflect_memory_on_relationship`)
|
127 |
+
7. ์ฑ๊ฒฉ ๋ณํ (`update_personality`)
|
128 |
+
|
129 |
+
---
|
130 |
+
|
131 |
+
## ๐ฆ ์คํ ๋ฐฉ๋ฒ
|
132 |
+
|
133 |
+
```bash
|
134 |
+
conda activate portfolio
|
135 |
+
|
136 |
+
# Flask ์น ์๋ฒ ์คํ
|
137 |
+
python portfolio/app.py
|
138 |
+
# โ http://127.0.0.1:5000/npc_social_network/
|
139 |
+
|
140 |
+
# ์๋ฎฌ๋ ์ด์
Pygame ์คํ (์น ๋ผ์ฐํธ๋ก ์คํ๋จ)
|
141 |
+
GET /run_npc_simulation
|
142 |
+
โ ๋๋ app.py ๋ด subprocess.Popen์ผ๋ก ์คํ๋จ
|
143 |
+
```
|
144 |
+
|
145 |
+
---
|
146 |
+
|
147 |
+
## โ
ํ์ฌ๊น์ง ๊ตฌํ๋ ๋จ๊ณ (์ค๊ณ ๊ธฐ๋ฐ)
|
148 |
+
|
149 |
+
| ๋จ๊ณ | ๋ด์ฉ |
|
150 |
+
|------|------|
|
151 |
+
| 1๋จ๊ณ | ํ์ผ/๊ฑด๋ฌผ/๋ง์ ๊ตฌ์กฐ ์์ฑ | โ
์๋ฃ | ๋ง์ ๊ตฌ์กฐ ์์ฑ ๋ฐ ๋งต ๋ ๋๋ง
|
152 |
+
| 2๋จ๊ณ | NPC ๊ฐ์ ์ํ ๋ฐ ๊ฐ์ HUD ๊ตฌํ | โ
์๋ฃ | ๊ฐ์ ์ํ ๋ฐ HUD ํ์ (Pygame + ์น)
|
153 |
+
| 3๋จ๊ณ | ๊ฐ์ โ ํ๋ ์ฐ๋ ๊ตฌ์กฐ ๊ตฌํ | โ
์๋ฃ | ๊ฐ์ โ ํ๋ ๋งคํ ๊ตฌํ
|
154 |
+
| 4๋จ๊ณ | ๊ฐ์ โ ๊ธฐ์ต ์ ์ฅ ๋ฐ decay ๊ตฌํ | โ
์๋ฃ | Memory ๊ฐ์ ๋ฐ decay ์ ์ฉ ๊ตฌ์กฐ
|
155 |
+
| 5๋จ๊ณ | ๊ฐ์ โ ๊ด๊ณ ๋ณํ ๊ตฌ์กฐ ๊ตฌํ | ๐ธ ๋ถ๋ถ ์๋ฃ | ๊ตฌ์กฐ๋ ๊ตฌํ๋จ, ํ๋ ์ด์ด ๋์ ๋ฐ์ ๋ณด์ ์ค
|
156 |
+
| 6๋จ๊ณ | ์ฑ๊ฒฉ ์์คํ
๋์
| โ
์๋ฃ | ์ฑ๊ฒฉ ๋ถ๋ฆฌ + ์ด๊ธฐ bias ์ค๊ณ
|
157 |
+
| 7๋จ๊ณ | NPC ๊ฐ ์ํธ์์ฉ ๊ตฌ์กฐํ | โ
์๋ฃ | NPC ์ํธ์์ฉ โ ๊ฐ์ /๊ด๊ณ ๋ฐ์
|
158 |
+
| 8๋จ๊ณ | Memory ์๋ฒ ๋ฉ + FAISS ๊ธฐ๋ฐ ๊ฒ์ | โ
์๋ฃ | FAISS ๊ฒ์ + ์๋ฒ ๋ฉ ์ ์ฅ ๊ตฌ์กฐ
|
159 |
+
| 9๋จ๊ณ | LLM ๊ธฐ๋ฐ ํ๋กฌํํธ ๋์ฌ ์์ฑ | โ
์๋ฃ | ํ๋กฌํํธ ์ค๊ณ ๋ฐ LLM ์๋ต
|
160 |
+
| 10๋จ๊ณ | ๊ฐ์ ์ํ HUD ์๊ฐํ (์น + ๊ฒ์ ํ๋ฉด) | โ
์๋ฃ | ๊ฐ์ ์ํ HUD (์น/๊ฒ์ ์ฐ๋)
|
161 |
+
|
162 |
+
# ํต์ฌ ์์คํ
๊ณ ๋ํ
|
163 |
+
| 11๋จ๊ณ | ๊ฐ์ /๊ธฐ์ต/๊ด๊ณ ํตํฉ ์ ๋น | ๐ ์งํ์ค | ๊ด๊ณ ํตํฉ, ๊ฐ์ -๊ธฐ์ต-๊ด๊ณ ์ฐ๊ฒฐ ์์ฑ๋ ํฅ์ ์ค
|
164 |
+
| 12๋จ๊ณ | LLM ๋์ฌ ์์ฑ ๊ณ ๋ํ | โ
์๋ฃ | LLM ๋์ฌ ์์ฑ ๊ฐ์ , ํ๋กฌํํธ ์์ฑ
|
165 |
+
| 13๋จ๊ณ | ๊ธฐ์ต decay ์ ๊ตํ | โณ ๋ฏธ์งํ | decay ์์ ๋ณ ๋ณํ์จ ์กฐ์ ๋ฑ ์ ๊ตํ ๋ฏธ์คํ
|
166 |
+
| 14-1๋จ๊ณ | ๊ธฐ์ต ์๋ฒ ๋ฉ ๊ตฌ์กฐ ํ์ฅ | โ
์๋ฃ | Memory ๊ฐ์ฒด ์๋ฒ ๋ฉ ๊ตฌ์กฐ ๋์
|
167 |
+
| 14-2๋จ๊ณ | ์๋ฒ ๋ฉ ๋ชจ๋ธ ๊ต์ฒด | โ
์๋ฃ | ๋ฒกํฐ ์๋ฒ ๋ฉ ๋ชจ๋ธ ๊ต์ฒด ์์ ์ํ๋ก ์ ๋ฆฌ
|
168 |
+
| 15๋จ๊ณ | ํ๋ ๊ณํ ์์ฑ๊ธฐ (LLM Planner ์ฐ๋) | โณ ๋ฏธ์งํ | Planner ์ฐ๋์ ์์ ์
|
169 |
+
| 16๋จ๊ณ | ์ฌํ์ ํ๋กํ์ผ ์์คํ
๋์
| โณ ๋ฏธ์งํ | ๊ด๊ณ ์ค๋ช
โ ์๊ฐํ ๊ตฌ์กฐ๋ก ํ์ฅ ์์
|
170 |
+
| 17๋จ๊ณ | ์์ง ๊ธฐ์ต / ๋ํ ๊ธฐ์ต ์์ฑ | โณ ๋ฏธ์งํ | ์์ง ๊ธฐ์ต ๋ถ๋ฅ/์์ฝ ์์ง ๋ฏธ์คํ
|
171 |
+
| 18๋จ๊ณ | ๊ธฐ์ต ์ฒด๊ณ ํ์ฅ: ์๊ฐ ๋งฅ๋ฝ ๋ถ์ฌ | โณ ๋ฏธ์งํ | ๊ธฐ์ต์ ์๊ฐ ๋งฅ๋ฝ/๊ณ์ /์๊ธฐ ๋ถ์ฌ ๋ฏธ์๋ฃ
|
172 |
+
| 19๋จ๊ณ | ๊ฐ์ -์ฑ๊ฒฉ-ํ๋ ์ผ๊ด์ฑ ์ ์ง ํ๊ฐ | โณ ๋ฏธ์งํ | ์ฑ๊ฒฉ ๊ธฐ๋ฐ ๊ฐ์ /ํ๋ ๋๊ธฐ ์ผ๊ด์ฑ ํ์ธ ์ค๊ณ
|
173 |
+
| 20๋จ๊ณ | NPC ์ฌํ ๋คํธ์ํฌ ์๊ฐํ | โณ ๋ฏธ์งํ |
|
174 |
+
|
175 |
+
# ๊ณ ๊ธ ์ธ๊ฐํ ๋ฐ ์๊ฐํ NPC ํ์ฅ
|
176 |
+
| 21๋จ๊ณ | ์ฑ๊ฒฉ ์ง์์ ๋ณํ ์ค๊ณ ์์ฑ |
|
177 |
+
| 22๋จ๊ณ | ํ๋ ์ ๋ ๊ธฐ๋ฐ ๊ณํํ NPC |
|
178 |
+
| 23๋จ๊ณ | ์ค๋ฆฌ ์์คํ
์คํ (์๊ฐํ ๊ตฌ์กฐํ) |
|
179 |
+
| 24๋จ๊ณ | NPC ์์ ํ์ฑ ์ํ์ค ํ
์คํธ |
|
180 |
+
| 25๋จ๊ณ | ํ๋ ์ด์ด ๊ธฐ์ต ๋ฐ ๋ฐ์ ์์คํ
๊ตฌ์ถ |
|
181 |
+
| 26๋จ๊ณ | ๋ฉํฐ์บ๋ฆญํฐ ๋ค์ ๊ฐ ์ํธ์์ฉ ๋ฃจํ |
|
182 |
+
| 27๋จ๊ณ | ์๋ฎฌ๋ ์ด์
UI ์๊ฐํ ๊ณ ๋ํ |
|
183 |
+
| 28๋จ๊ณ | ๋ฉํ๊ธฐ์ต ์์คํ
|
|
184 |
+
| 29๋จ๊ณ | LLM+RAG+ํ๋๋ ์ข
ํฉ ๊ตฌ์กฐ ํตํฉ |
|
185 |
+
| 30๋จ๊ณ | ๋
ผ๋ฌธ/์ฐ๊ตฌ ๊ฒฐ๊ณผ ์ ๋ฆฌ ๊ตฌ์กฐํ |
|
186 |
+
|
187 |
+
|
188 |
+
---
|
189 |
+
|
190 |
+
## ๐ dependency ์์ (requirements ์ผ๋ถ)
|
191 |
+
|
192 |
+
```txt
|
193 |
+
flask
|
194 |
+
pygame
|
195 |
+
sentence-transformers
|
196 |
+
faiss-cpu
|
197 |
+
numpy
|
198 |
+
```
|
199 |
+
โ ์ค์ ๋ชจ๋ธ ์ฌ์ฉ์ ์ํด GPU ๋ฒ์ ๋๋ `transformers`, `openai`, `google-generativeai` ๋ฑ ์ถ๊ฐ ๊ฐ๋ฅ
|
200 |
+
|
201 |
+
---
|
202 |
+
|
203 |
+
## ๐จ ์ฃผ์ ์ฌํญ
|
204 |
+
|
205 |
+
- ๋ชจ๋ ๊ฐ์ , ๊ธฐ์ต, ํ๋, ๊ด๊ณ๋ ๊ฐ์ ์นดํ
๊ณ ๋ฆฌ ๊ธฐ๋ฐ ๊ตฌ์กฐ๋ฅผ ์ฒ ์ ํ ๋ฐ๋ฆ
๋๋ค
|
206 |
+
- NPC ๋ด๋ถ ์ํ ๋ณํ๋ ์์ ํ ์ค๊ณ๋ ์ํ๊ตฌ์กฐ (๊ฐ์ โ๊ธฐ์ตโ๊ด๊ณโ์ฑ๊ฒฉโ๊ฐ์ ...)๋ก ๊ตฌํ๋์ด ์์ต๋๋ค
|
207 |
+
- ํจ์๋ช
, ๋ณ์๋ช
์ `npc_base.py`์ ๊ท์น์ ๋ฐ๋ผ ๋ณ๊ฒฝ ๊ธ์ง
|
208 |
+
- ํ์ฌ ๋ชจ๋ ๊ตฌ์กฐ๋ **์ฐ๊ตฌ ๋
ผ๋ฌธ ๋๋ ์ปจํผ๋ฐ์ค ๋ชฉ์ **์ผ๋ก ์ค๊ณ๋จ
|
209 |
+
|
210 |
+
---
|
211 |
+
|
212 |
+
ยฉ 2025 NPC Social Network Simulation Project v2
|
npc_social_network/npc/emotion_config.py
CHANGED
@@ -153,4 +153,23 @@ NEGATIVE_RELATION_EMOTIONS = [
|
|
153 |
COGNITIVE_RELATION_EMOTIONS = [
|
154 |
"compassion", "awe", "attachment", "anticipation", "curiosity",
|
155 |
"nostalgia", "bittersweet", "rumination", "groundedness", "comfort",
|
156 |
-
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
COGNITIVE_RELATION_EMOTIONS = [
|
154 |
"compassion", "awe", "attachment", "anticipation", "curiosity",
|
155 |
"nostalgia", "bittersweet", "rumination", "groundedness", "comfort",
|
156 |
+
]
|
157 |
+
|
158 |
+
# ๊ฐ์ ๋ณ ๊ด๊ณ ์ํฅ๋ ์ ์ (๊ด๊ณ์ ์ํฅ ์ฃผ๋ ๊ฐ์ ๋ง ๋ฑ๋ก, ์ ๊ทํ๋ [-2.0 ~ +2.0] ๋ฒ์ ์์์ ์ ์)
|
159 |
+
EMOTION_RELATION_IMPACT = {
|
160 |
+
"joy": +1.0,
|
161 |
+
"gratitude": +1.2,
|
162 |
+
"love": +2.0,
|
163 |
+
"admiration": +0.8,
|
164 |
+
"pride": +0.7,
|
165 |
+
"calm": +0.5,
|
166 |
+
"sadness": -0.8,
|
167 |
+
"anger": -1.5,
|
168 |
+
"disgust": -2.0,
|
169 |
+
"fear": -1.0,
|
170 |
+
"shame": -1.2,
|
171 |
+
"resentment": -1.5,
|
172 |
+
"regret": -0.9,
|
173 |
+
"hope": +0.9,
|
174 |
+
"comfort": +0.6,
|
175 |
+
}
|
npc_social_network/npc/npc_base.py
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
from .npc_memory import Memory, MemoryStore
|
3 |
from .npc_emotion import EmotionManager
|
4 |
from .npc_behavior import BehaviorManager
|
5 |
-
from .emotion_config import
|
6 |
from .emotion_config import POSITIVE_RELATION_EMOTIONS, NEGATIVE_RELATION_EMOTIONS, COGNITIVE_RELATION_EMOTIONS
|
7 |
from .personality_config import AGE_PROFILE, PERSONALITY_PROFILE
|
8 |
from .npc_relationship import RelationshipManager
|
@@ -313,23 +313,34 @@ class NPC:
|
|
313 |
self.update_emotion(emotion, strength=2.0)
|
314 |
|
315 |
# STEP 2: ๊ด๋ จ ๊ธฐ์ต ๊ฒ์
|
316 |
-
|
317 |
-
# ์์ฝ & ์ฅ๊ธฐ ๊ธฐ์ตํ (3๊ฐ ์ด์์ผ ๋๋ง)
|
318 |
-
if len(matched_memories) >= 3:
|
319 |
-
self.summarize_and_store_memories(matched_memories)
|
320 |
|
321 |
# STEP 3: ํ๋กฌํํธ ์์ฑ
|
322 |
-
prompt = build_npc_prompt(self,
|
|
|
|
|
323 |
|
324 |
# STEP 4: LLM ์๋ต ์์ฑ
|
325 |
npc_reply = query_llm_with_prompt(prompt)
|
326 |
|
327 |
# STEP 5: ๊ธฐ์ต ๊ธฐ๋ก
|
328 |
-
|
329 |
content=f"[ํ๋ ์ด์ด] '{player_input}' โ [NPC:{self.name}] '{npc_reply}'",
|
330 |
importance=6,
|
331 |
emotion=emotion
|
332 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
333 |
|
334 |
return npc_reply
|
335 |
|
|
|
2 |
from .npc_memory import Memory, MemoryStore
|
3 |
from .npc_emotion import EmotionManager
|
4 |
from .npc_behavior import BehaviorManager
|
5 |
+
from .emotion_config import EMOTION_CATEGORY_MAP, EMOTION_DECAY_RATE, PERSONALITY_TEMPLATE, EMOTION_RELATION_IMPACT
|
6 |
from .emotion_config import POSITIVE_RELATION_EMOTIONS, NEGATIVE_RELATION_EMOTIONS, COGNITIVE_RELATION_EMOTIONS
|
7 |
from .personality_config import AGE_PROFILE, PERSONALITY_PROFILE
|
8 |
from .npc_relationship import RelationshipManager
|
|
|
313 |
self.update_emotion(emotion, strength=2.0)
|
314 |
|
315 |
# STEP 2: ๊ด๋ จ ๊ธฐ์ต ๊ฒ์
|
316 |
+
matched_memories = search_similar_memories(self.name, player_input)
|
|
|
|
|
|
|
317 |
|
318 |
# STEP 3: ํ๋กฌํํธ ์์ฑ
|
319 |
+
prompt = build_npc_prompt(cnp=self,
|
320 |
+
user_input=player_input,
|
321 |
+
matched_memories=matched_memories)
|
322 |
|
323 |
# STEP 4: LLM ์๋ต ์์ฑ
|
324 |
npc_reply = query_llm_with_prompt(prompt)
|
325 |
|
326 |
# STEP 5: ๊ธฐ์ต ๊ธฐ๋ก
|
327 |
+
memory = Memory(
|
328 |
content=f"[ํ๋ ์ด์ด] '{player_input}' โ [NPC:{self.name}] '{npc_reply}'",
|
329 |
importance=6,
|
330 |
emotion=emotion
|
331 |
)
|
332 |
+
self.memory_store.add_memory(memory)
|
333 |
+
|
334 |
+
# STEP 6: ๊ฐ์ ๊ธฐ๋ฐ ๊ด๊ณ ๋ณํ ๋ฐ์
|
335 |
+
if isinstance(emotion, dict):
|
336 |
+
delta = 0.0
|
337 |
+
for emo, strength in emotion.items():
|
338 |
+
if emo in EMOTION_RELATION_IMPACT:
|
339 |
+
delta += EMOTION_RELATION_IMPACT[emo] * strength
|
340 |
+
|
341 |
+
if abs(delta) > 0.01: # ์ํฅ์ด ์ถฉ๋ถํ ์์ ๋๋ง ๋ฐ์
|
342 |
+
self.relationships.update_relationship("ํ๋ ์ด์ด", delta=delta)
|
343 |
+
print(f"[๊ด๊ณ ๋ณํ] '{self.name}' โ ํ๋ ์ด์ด: {delta:+.2f}")
|
344 |
|
345 |
return npc_reply
|
346 |
|