Spaces:
Sleeping
Sleeping
humanda5
commited on
Commit
ยท
ba4c3a1
1
Parent(s):
abe9cba
error state
Browse files
npc_social_network/README.txt
CHANGED
@@ -168,8 +168,8 @@ GET /run_npc_simulation
|
|
168 |
| 15๋จ๊ณ | ํ๋ ๊ณํ ์์ฑ๊ธฐ (LLM Planner ์ฐ๋) | โ
์๋ฃ | Planner ์ฐ๋์ ์์ ์
|
169 |
| 16๋จ๊ณ | ์ฌํ์ ํ๋กํ์ผ ์์คํ
๋์
| โ
์๋ฃ | ๊ด๊ณ ์ค๋ช
โ ์๊ฐํ ๊ตฌ์กฐ๋ก ํ์ฅ ์์
|
170 |
| 17๋จ๊ณ | ์์ง ๊ธฐ์ต / ๋ํ ๊ธฐ์ต ์์ฑ | โ
์๋ฃ | ์์ง ๊ธฐ์ต ๋ถ๋ฅ/์์ฝ ์์ง ๋ฏธ์คํ
|
171 |
-
| 18๋จ๊ณ | ๊ธฐ์ต ์ฒด๊ณ ํ์ฅ: ์๊ฐ ๋งฅ๋ฝ ๋ถ์ฌ |
|
172 |
-
| 19๋จ๊ณ | ์ฑ๊ฒฉ ๋ณํ ์์คํ
์์ฑ |
|
173 |
| 20๋จ๊ณ | ์ค๊ฐ ํ
์คํธ ๋ฐ ์์ ํ | โณ ๋ฏธ์งํ |
|
174 |
|
175 |
# ์ฌํ์ ์ํธ์์ฉ ์ฌํ (Social Interaction Deepening)
|
|
|
168 |
| 15๋จ๊ณ | ํ๋ ๊ณํ ์์ฑ๊ธฐ (LLM Planner ์ฐ๋) | โ
์๋ฃ | Planner ์ฐ๋์ ์์ ์
|
169 |
| 16๋จ๊ณ | ์ฌํ์ ํ๋กํ์ผ ์์คํ
๋์
| โ
์๋ฃ | ๊ด๊ณ ์ค๋ช
โ ์๊ฐํ ๊ตฌ์กฐ๋ก ํ์ฅ ์์
|
170 |
| 17๋จ๊ณ | ์์ง ๊ธฐ์ต / ๋ํ ๊ธฐ์ต ์์ฑ | โ
์๋ฃ | ์์ง ๊ธฐ์ต ๋ถ๋ฅ/์์ฝ ์์ง ๋ฏธ์คํ
|
171 |
+
| 18๋จ๊ณ | ๊ธฐ์ต ์ฒด๊ณ ํ์ฅ: ์๊ฐ ๋งฅ๋ฝ ๋ถ์ฌ | โ
์๋ฃ | ๊ธฐ์ต์ ์๊ฐ ๋งฅ๋ฝ/๊ณ์ /์๊ธฐ ๋ถ์ฌ ๋ฏธ์๋ฃ
|
172 |
+
| 19๋จ๊ณ | ์ฑ๊ฒฉ ๋ณํ ์์คํ
์์ฑ | โ
์๋ฃ | ์ค์ํ ๊ธฐ์ต(Memory)๊ณผ ๊ฐ๋ ฌํ ๊ฐ์ (Emotion)์ด ๋์ ๋จ์ ๋ฐ๋ผ NPC์ ์ฑ๊ฒฉ(sensitive, stoic ๋ฑ)์ด ์ ์ง์ ์ผ๋ก ๋ณํํ๋ ๋ก์ง์ ๊ตฌํ
|
173 |
| 20๋จ๊ณ | ์ค๊ฐ ํ
์คํธ ๋ฐ ์์ ํ | โณ ๋ฏธ์งํ |
|
174 |
|
175 |
# ์ฌํ์ ์ํธ์์ฉ ์ฌํ (Social Interaction Deepening)
|
npc_social_network/maps/manager/simulation_manager.py
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# portfolio/npc_social_network/map/manager/simulation_manager.py
|
2 |
+
import pickle
|
3 |
+
import os
|
4 |
+
from npc_social_network.npc.npc_manager import NPCManager
|
5 |
+
|
6 |
+
SAVE_DIR = "data/saves"
|
7 |
+
if not os.path.exists(SAVE_DIR):
|
8 |
+
os.makedirs(SAVE_DIR)
|
9 |
+
|
10 |
+
def save_simulation(npc_manager: NPCManager, filename: str = "simulation_state.pkl"):
|
11 |
+
"""
|
12 |
+
[NEW] ํ์ฌ NPC ๋งค๋์ ์ ์ํ๋ฅผ ํ์ผ์ ์ ์ฅํฉ๋๋ค.
|
13 |
+
"""
|
14 |
+
filepath = os.path.join(SAVE_DIR, filename)
|
15 |
+
try:
|
16 |
+
with open(filepath, "wb") as f:
|
17 |
+
pickle.dump(npc_manager, f)
|
18 |
+
print(f"โ
์๋ฎฌ๋ ์ด์
์ํ๊ฐ '{filepath}'์ ์ฑ๊ณต์ ์ผ๋ก ์ ์ฅ๋์์ต๋๋ค.")
|
19 |
+
except Exception as e:
|
20 |
+
print(f"โ ์๋ฎฌ๋ ์ด์
์ ์ฅ์ ์คํจํ์ต๋๋ค: {e}")
|
21 |
+
|
22 |
+
def load_simulation(filename: str = "simulation_state.pkl") -> NPCManager | None:
|
23 |
+
"""
|
24 |
+
[NEW] ํ์ผ์์ NPC ๋งค๋์ ์ ์ํ๋ฅผ ๋ถ๋ฌ์ต๋๋ค.
|
25 |
+
"""
|
26 |
+
filepath = os.path.join(SAVE_DIR, filename)
|
27 |
+
if not os.path.exists(filepath):
|
28 |
+
print("โน๏ธ ์ ์ฅ๋ ์๋ฎฌ๋ ์ด์
ํ์ผ์ด ์์ต๋๋ค. ์๋ก์ด ์๋ฎฌ๋ ์ด์
์ ์์ํฉ๋๋ค.")
|
29 |
+
return None
|
30 |
+
|
31 |
+
try:
|
32 |
+
with open(filepath, "rb") as f:
|
33 |
+
npc_manager = pickle.load(f)
|
34 |
+
print(f"โ
์๋ฎฌ๋ ์ด์
์ํ๋ฅผ '{filepath}'์์ ์ฑ๊ณต์ ์ผ๋ก ๋ถ๋ฌ์์ต๋๋ค.")
|
35 |
+
return npc_manager
|
36 |
+
except Exception as e:
|
37 |
+
print(f"โ ์๋ฎฌ๋ ์ด์
๋ถ๋ฌ์ค๊ธฐ์ ์คํจํ์ต๋๋ค: {e}")
|
38 |
+
return None
|
npc_social_network/maps/manager/village_map.py
CHANGED
@@ -15,14 +15,14 @@ class Building:
|
|
15 |
screen.blit(self.image, (self.x * tile_size, self.y * tile_size))
|
16 |
|
17 |
class VillageMap:
|
18 |
-
def __init__(self, image_loader, tile_size, grid_width, grid_height):
|
19 |
self.image_loader = image_loader
|
20 |
self.tile_size = tile_size
|
21 |
self.grid_width = grid_width
|
22 |
self.grid_height = grid_height
|
23 |
self.tiles = []
|
24 |
self.buildings = []
|
25 |
-
self.npc_manager =
|
26 |
|
27 |
def generate(self):
|
28 |
import random
|
@@ -47,6 +47,13 @@ class VillageMap:
|
|
47 |
elin_path = [[2,3], [3,3], [4,3], [5,3], [5,4], [5,5], [4,5], [3, 5], [2,5], [2,4]]
|
48 |
elin = NPC("Elin", "farmer", elin_path, self.image_loader.load("npc", "default"))
|
49 |
self.npc_manager.add_npc(elin)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
def draw(self, screen):
|
52 |
for x, y, image in self.tiles:
|
|
|
15 |
screen.blit(self.image, (self.x * tile_size, self.y * tile_size))
|
16 |
|
17 |
class VillageMap:
|
18 |
+
def __init__(self, image_loader, tile_size, grid_width, grid_height, npc_manager: NPCManager):
|
19 |
self.image_loader = image_loader
|
20 |
self.tile_size = tile_size
|
21 |
self.grid_width = grid_width
|
22 |
self.grid_height = grid_height
|
23 |
self.tiles = []
|
24 |
self.buildings = []
|
25 |
+
self.npc_manager = npc_manager
|
26 |
|
27 |
def generate(self):
|
28 |
import random
|
|
|
47 |
elin_path = [[2,3], [3,3], [4,3], [5,3], [5,4], [5,5], [4,5], [3, 5], [2,5], [2,4]]
|
48 |
elin = NPC("Elin", "farmer", elin_path, self.image_loader.load("npc", "default"))
|
49 |
self.npc_manager.add_npc(elin)
|
50 |
+
# ํ
์คํธ๋ฅผ ์ํด ๋ค๋ฅธ NPC๋ค๋ ์ถ๊ฐ
|
51 |
+
bob = NPC("Bob", "blacksmith", [[1,1], [1,2], [2,2]], self.image_loader.load("npc", "default"))
|
52 |
+
self.npc_manager.add_npc(bob)
|
53 |
+
|
54 |
+
alice = NPC("Alice", "merchant", [[8,8], [9,8], [9,9]], self.image_loader.load("npc", "default"))
|
55 |
+
self.npc_manager.add_npc(alice)
|
56 |
+
|
57 |
|
58 |
def draw(self, screen):
|
59 |
for x, y, image in self.tiles:
|
npc_social_network/maps/villages/town_hall.py
CHANGED
@@ -1,12 +1,15 @@
|
|
1 |
# portfolio/npc_social_network/maps/villages/town_hall.py
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
def run_town_hall_simulation():
|
4 |
-
# ๋ฉ์ธ ์คํ ํ์ผ
|
5 |
-
import pygame
|
6 |
-
import sys
|
7 |
-
from npc_social_network.maps.manager.image_loader import ImageLoader
|
8 |
-
from npc_social_network.maps.manager.village_map import VillageMap
|
9 |
-
from npc_social_network.maps.engine.game_engine import GameEngine
|
10 |
|
11 |
# ์ด๊ธฐ ์ค์
|
12 |
pygame.init()
|
@@ -20,36 +23,60 @@ def run_town_hall_simulation():
|
|
20 |
clock = pygame.time.Clock()
|
21 |
font = pygame.font.SysFont("malgungothic", 20) # ํ๊ธ ์ถ๋ ฅ์ฉ
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
# ๋ก๋ฉ
|
24 |
image_loader = ImageLoader(tile_size)
|
25 |
-
village = VillageMap(image_loader, tile_size, width, height)
|
26 |
village.generate()
|
27 |
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
31 |
|
32 |
# ๊ฒ์ ์์ง ์ด๊ธฐ ์ธํ
|
33 |
-
engine = GameEngine(screen, font, village, ["์์นจ", "์ ์ฌ", "์ ๋
", "๋ฐค"],
|
34 |
|
35 |
# pygame ๋ฃจํ
|
36 |
runnig = True
|
37 |
while runnig:
|
38 |
-
screen.fill((255, 255, 255))
|
39 |
-
engine.draw()
|
40 |
-
pygame.display.update()
|
41 |
-
clock.tick(10) # ์ด๋น 10ํ๋ ์
|
42 |
-
engine.update()
|
43 |
-
|
44 |
for event in pygame.event.get():
|
45 |
if event.type == pygame.QUIT:
|
46 |
-
|
47 |
-
elif event.type == pygame.MOUSEBUTTONDOWN:
|
48 |
-
engine.handle_click(pygame.mouse.get_pos())
|
49 |
elif event.type == pygame.KEYDOWN:
|
50 |
-
if event.key == pygame.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
engine.clear_selected_npc() # ESC๋ก ์ ํ ํด์
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
|
|
|
|
53 |
pygame.quit()
|
54 |
sys.exit()
|
55 |
|
|
|
1 |
# portfolio/npc_social_network/maps/villages/town_hall.py
|
2 |
+
# ๋ฉ์ธ ์คํ ํ์ผ
|
3 |
+
import pygame
|
4 |
+
import sys
|
5 |
+
from npc_social_network.simulation_manager import save_simulation, load_simulation
|
6 |
+
from npc_social_network.maps.manager.image_loader import ImageLoader
|
7 |
+
from npc_social_network.maps.manager.village_map import VillageMap
|
8 |
+
from npc_social_network.maps.engine.game_engine import GameEngine
|
9 |
+
from npc_social_network.npc.npc_manager import NPCManager
|
10 |
+
from npc_social_network.npc.npc_base import NPC
|
11 |
|
12 |
def run_town_hall_simulation():
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
# ์ด๊ธฐ ์ค์
|
15 |
pygame.init()
|
|
|
23 |
clock = pygame.time.Clock()
|
24 |
font = pygame.font.SysFont("malgungothic", 20) # ํ๊ธ ์ถ๋ ฅ์ฉ
|
25 |
|
26 |
+
# ์ ์ฅ/๋ถ๋ฌ์ค๊ธฐ
|
27 |
+
npc_manager = load_simulation() # ์ ์ฅ๋ ์ํ๋ฅผ ๋ถ๋ฌ์ค๊ธฐ ์๋
|
28 |
+
|
29 |
+
if npc_manager is None:
|
30 |
+
# ์ ์ฅ๋ ํ์ผ์ด ์์ผ๋ฉด ์๋ก ์์
|
31 |
+
npc_manager = NPCManager()
|
32 |
+
# ์ฌ๊ธฐ์ ์ด๊ธฐ NPC๋ค์ ์ถ๊ฐํ๋ ๋ก์ง์ ๋ฃ์ต๋๋ค.
|
33 |
+
# ์์: npc_manager.add_npc(NPC(name="์๋ผ", ...))
|
34 |
+
|
35 |
# ๋ก๋ฉ
|
36 |
image_loader = ImageLoader(tile_size)
|
37 |
+
village = VillageMap(image_loader, tile_size, width, height, npc_manager)
|
38 |
village.generate()
|
39 |
|
40 |
+
if len(npc_manager.all()) == 0:
|
41 |
+
# ๋ถ๋ฌ์จ ๋ฐ์ดํฐ๊ฐ ๋น์ด์๊ฑฐ๋, ์๋ก ์์ํ๋ ๊ฒฝ์ฐ
|
42 |
+
village.generate()
|
43 |
+
print("์๋ก์ด NPC๋ค์ ์์ฑํ์ต๋๋ค.")
|
44 |
|
45 |
# ๊ฒ์ ์์ง ์ด๊ธฐ ์ธํ
|
46 |
+
engine = GameEngine(screen, font, village, ["์์นจ", "์ ์ฌ", "์ ๋
", "๋ฐค"], npc_manager)
|
47 |
|
48 |
# pygame ๋ฃจํ
|
49 |
runnig = True
|
50 |
while runnig:
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
for event in pygame.event.get():
|
52 |
if event.type == pygame.QUIT:
|
53 |
+
running = False
|
|
|
|
|
54 |
elif event.type == pygame.KEYDOWN:
|
55 |
+
if event.key == pygame.K_s: # 'S' ํค๋ฅผ ๋๋ฅด๋ฉด ์ ์ฅ
|
56 |
+
save_simulation(npc_manager)
|
57 |
+
elif event.key == pygame.K_l: # 'L' ํค๋ฅผ ๋๋ฅด๋ฉด ๋ถ๋ฌ์ค๊ธฐ
|
58 |
+
loaded_manager = load_simulation()
|
59 |
+
if loaded_manager:
|
60 |
+
npc_manager = loaded_manager
|
61 |
+
# ๋ถ๋ฌ์จ ๋ฐ์ดํฐ๋ก ์์ง ์ฌ์ค์
|
62 |
+
village.npc_manager = npc_manager
|
63 |
+
engine.npc_manager = npc_manager
|
64 |
+
engine.selected_npc = None # ์ ํ ์ด๊ธฐํ
|
65 |
+
print("์๋ฎฌ๋ ์ด์
์ ์๋ก๊ณ ์นจํ์ต๋๋ค.")
|
66 |
+
|
67 |
+
elif event.key == pygame.K_ESCAPE:
|
68 |
engine.clear_selected_npc() # ESC๋ก ์ ํ ํด์
|
69 |
+
elif event.type == pygame.MOUSEBUTTONDOWN:
|
70 |
+
engine.handle_click(pygame.mouse.get_pos()) # ๋ง์ฐ์ค ํด๋ฆญ์ผ๋ก NPC ์ ํ
|
71 |
+
|
72 |
+
screen.fill((255, 255, 255))
|
73 |
+
engine.update()
|
74 |
+
engine.draw()
|
75 |
+
pygame.display.update()
|
76 |
+
clock.tick(10) # ์ด๋น 10ํ๋ ์
|
77 |
|
78 |
+
# ์ข
๋ฃ ์ ์ ์ต์ข
์ํ ์ ์ฅ
|
79 |
+
save_simulation(npc_manager)
|
80 |
pygame.quit()
|
81 |
sys.exit()
|
82 |
|
npc_social_network/npc/emotion_config.py
CHANGED
@@ -191,9 +191,9 @@ EMOTION_RELATION_IMPACT = {
|
|
191 |
"attachment": 1.7,
|
192 |
"anticipation": 0.7,
|
193 |
"curiosity": 0.6,
|
194 |
-
"nostalgia": 0.
|
195 |
-
"bittersweet": 0.
|
196 |
-
"rumination": 0.
|
197 |
"groundedness": 0.5,
|
198 |
"comfort": 0.6,
|
199 |
}
|
|
|
191 |
"attachment": 1.7,
|
192 |
"anticipation": 0.7,
|
193 |
"curiosity": 0.6,
|
194 |
+
"nostalgia": 0.4,
|
195 |
+
"bittersweet": 0.4,
|
196 |
+
"rumination": 0.4,
|
197 |
"groundedness": 0.5,
|
198 |
"comfort": 0.6,
|
199 |
}
|
npc_social_network/npc/npc_base.py
CHANGED
@@ -378,36 +378,46 @@ class NPC:
|
|
378 |
if not recent_memories:
|
379 |
return
|
380 |
|
|
|
|
|
381 |
# Personality ๋ณํ ๋ฐ์
|
382 |
for mem in recent_memories:
|
383 |
-
if not mem.emotion: continue
|
|
|
|
|
|
|
384 |
|
385 |
# 1. ๊ฐ์ ์ ๊ธ์ /๋ถ์ /์ธ์ง์ ์์ฑ์ ๋ฐ๋ฅธ ์ํฅ ๋ฐฉํฅ ๊ฒฐ์
|
386 |
influence_vector = {"sensitive": 0.0, "stoic": 0.0, "cognitive_bias": 0.0}
|
387 |
-
|
388 |
-
#
|
389 |
-
# ๋
ผ๋ฆฌ์ ์ฌ๊ณ ๊ฐํ๊ฐ ์์ผ๋ฉด ๊ฐ์ฑ์ ์ฌ๊ณ ๊ฐํ๋ ์์ด์ผ์ง
|
390 |
-
# ์ต์ํ MBTI๋ก ๋ถ๋ฅํ ์ ๋๋ ๋์์ผ๋๋๊ฑฐ ์๋๊ฐ? ComplexEmotions ๊ฐ์ ๋ชจ๋ธ์ด ์ ์ ์๋ํ๋์ง ํ์ธ ํ์
|
391 |
if mem.emotion in POSITIVE_RELATION_EMOTIONS:
|
392 |
-
influence_vector["sensitive"] -= 0
|
393 |
-
influence_vector["stoic"] -= 0
|
|
|
394 |
elif mem.emotion in NEGATIVE_RELATION_EMOTIONS:
|
395 |
-
influence_vector["sensitive"] += 0
|
396 |
-
influence_vector["stoic"] += 0
|
397 |
-
|
398 |
-
|
|
|
399 |
|
400 |
# 2. ๋ณํ ๊ฐ๋ ๊ณ์ฐ (๊ธฐ์ต์ ์ค์๋์ ๋์ด์ ๋ฐ๋ผ)
|
401 |
age_factor = AGE_PROFILE.get(self.personality_stage, 1.0)
|
402 |
change_strength = (mem.importance / 10.0) * age_factor
|
403 |
|
404 |
-
# 3.
|
405 |
-
for trait
|
|
|
|
|
|
|
|
|
|
|
406 |
rate = self.personality_change_rate.get(trait, 0.003)
|
407 |
-
delta =
|
408 |
self.personality[trait] = max(0.0, min(1.0, self.personality[trait] + delta))
|
409 |
|
410 |
-
#
|
411 |
base_decay = 0.001
|
412 |
for trait in self.personality.keys():
|
413 |
decay_rate = base_decay * (1.0 + self.personality.get("stoic", 0.0) - self.personality.get("sensitive", 0.0))
|
|
|
378 |
if not recent_memories:
|
379 |
return
|
380 |
|
381 |
+
total_influence = {"sensitive": 0.0, "stoic": 0.0, "cognitive_bias": 0.0}
|
382 |
+
|
383 |
# Personality ๋ณํ ๋ฐ์
|
384 |
for mem in recent_memories:
|
385 |
+
if not mem.emotion or mem.emotion not in EMOTION_RELATION_IMPACT: continue
|
386 |
+
|
387 |
+
# ๊ฐ ๊ฐ์ ์ ๊ณ ์ ํ ์ํฅ๋ ฅ(impact)์ ๊ฐ์ ธ์ด
|
388 |
+
emotion_impact = EMOTION_RELATION_IMPACT.get(mem.emotion, 0.0)
|
389 |
|
390 |
# 1. ๊ฐ์ ์ ๊ธ์ /๋ถ์ /์ธ์ง์ ์์ฑ์ ๋ฐ๋ฅธ ์ํฅ ๋ฐฉํฅ ๊ฒฐ์
|
391 |
influence_vector = {"sensitive": 0.0, "stoic": 0.0, "cognitive_bias": 0.0}
|
392 |
+
|
393 |
+
# ๊ฐ์ ์ํฅ๋ ฅ์ด ์์์ด๋ฉด(๊ธ์ ์ ๊ฐ์ ), ๋ฏผ๊ฐ๋์ ๋ด์ฑ์ ๋ฎ์ถค
|
|
|
|
|
394 |
if mem.emotion in POSITIVE_RELATION_EMOTIONS:
|
395 |
+
influence_vector["sensitive"] -= abs(emotion_impact) / 2.0 # ๊ธ์ ์ ๊ฒฝํ์ ๋ฏผ๊ฐ๋๋ฅผ ๋ฎ์ถค
|
396 |
+
influence_vector["stoic"] -= abs(emotion_impact) / 4.0 # ๊ธ์ ์ ์ธ ๊ฒฝํ์ ๋ด์ฑ์ ์ผ ํ์๋ฅผ ์ค์
|
397 |
+
# ๊ฐ์ ์ํฅ๋ ฅ์ด ์์์ด๋ฉด(๋ถ์ ์ ๊ฐ์ ), ๋ฏผ๊ฐ๋์ ๋ด์ฑ์ ๋์
|
398 |
elif mem.emotion in NEGATIVE_RELATION_EMOTIONS:
|
399 |
+
influence_vector["sensitive"] += abs(emotion_impact) / 2.0 # ๋ถ์ ์ ๊ฒฝํ์ ๋ฏผ๊ฐ๋๋ฅผ ๋์
|
400 |
+
influence_vector["stoic"] += abs(emotion_impact) / 4.0 # ๋ถ์ ์ ๊ฒฝํ์ ๋ด์ฑ์ ์ผ๋ก ๋ง๋ฆ
|
401 |
+
# ์ธ์ง์ ๊ฐ์ ์ cognitive_bias์ ์ํฅ
|
402 |
+
if mem.emotion in COGNITIVE_RELATION_EMOTIONS:
|
403 |
+
influence_vector["cognitive_bias"] += 0.4 # ์ธ์ง์ ๊ฒฝํ์ ๋
ผ๋ฆฌ์ ์ฌ๊ณ ๋ฅผ ๊ฐํ
|
404 |
|
405 |
# 2. ๋ณํ ๊ฐ๋ ๊ณ์ฐ (๊ธฐ์ต์ ์ค์๋์ ๋์ด์ ๋ฐ๋ผ)
|
406 |
age_factor = AGE_PROFILE.get(self.personality_stage, 1.0)
|
407 |
change_strength = (mem.importance / 10.0) * age_factor
|
408 |
|
409 |
+
# 3. ์ด๋ฒ ๊ธฐ์ต์ผ๋ก ์ธํ ์ต์ข
๋ณํ๋ ๋์
|
410 |
+
for trait in total_influence.keys():
|
411 |
+
total_influence[trait] += influence_vector[trait] * change_strength
|
412 |
+
|
413 |
+
# 4. ๋์ ๋ ๋ณํ๋์ ์ฑ๊ฒฉ์ ์ ์ฉ
|
414 |
+
for trait, total_change in total_influence.items():
|
415 |
+
if abs(total_change) > 0.001: # ์๋ฏธ์๋ ๋ณํ๋ง ์ ์ฉ
|
416 |
rate = self.personality_change_rate.get(trait, 0.003)
|
417 |
+
delta = total_change * rate
|
418 |
self.personality[trait] = max(0.0, min(1.0, self.personality[trait] + delta))
|
419 |
|
420 |
+
# 5. ๊ธฐ์ค์ ์ผ๋ก ํ๊ท (ํญ์์ฑ)
|
421 |
base_decay = 0.001
|
422 |
for trait in self.personality.keys():
|
423 |
decay_rate = base_decay * (1.0 + self.personality.get("stoic", 0.0) - self.personality.get("sensitive", 0.0))
|