RachelNongyingLI commited on
Commit
9e5dfbf
·
verified ·
1 Parent(s): 4b1997f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +198 -74
app.py CHANGED
@@ -1,3 +1,5 @@
 
 
1
  # ---------- 1) Imports & Config ----------
2
  import os, uuid, json, random
3
  from dataclasses import dataclass, field, asdict
@@ -21,6 +23,34 @@ if NARRATION_BACKEND == "hf":
21
  max_new_tokens=180, do_sample=True, temperature=0.9, top_p=0.95
22
  )[0]["generated_text"]
23
  return out[-600:].strip()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
  # ---------- 2) Data Models ----------
26
  Day = int
@@ -29,15 +59,11 @@ Day = int
29
  class Agent:
30
  name: str
31
  role: str
32
- relations: Dict[str, Dict[str, float]] = field(default_factory=dict) # 【关系维度】喜好、信任等
33
-
34
- name: str
35
- role: str
36
  memory: Dict[str, Any] = field(default_factory=dict)
37
  belief_about_others: Dict[str, Dict[str, Any]] = field(default_factory=dict)
38
-
39
- full_name: str = ""
40
- gender: str = ""
41
  height: int = 170
42
  appearance: str = ""
43
  spirit_root: str = ""
@@ -46,12 +72,37 @@ class Agent:
46
  cultivation: int = 50
47
  willpower: int = 50
48
  face: int = 0
49
- jealousy: int = 0
50
  scandal: int = 0
51
  ####基础信息生成
 
 
52
  #name
53
- SURNAMES = ["李","赵","王","欧阳","慕容","上官","东方","南宫","司马","诸葛"]
54
- NAME_PARTS = ["","","","","","","","","","","澈","寒","月","落","竹","珊"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
  def random_name():
57
  surname = random.choice(SURNAMES)
@@ -60,13 +111,14 @@ def random_name():
60
 
61
  #长相
62
  APPEARANCES = ["清秀","俊逸","冷艳","稚气","邪魅","清冷","英气","娇美","秀雅","潇洒"]
 
63
  SPIRIT_ROOTS = ["金灵根","木灵根","水灵根","火灵根","土灵根","冰灵根","风灵根","雷灵根","混沌灵根"]
64
 
65
  def random_gender():
66
  return random.choice(["male","female"])
67
 
68
  def random_height(gender):
69
- return random.randint(168,190) if gender=="male" else random.randint(155,175)
70
 
71
  def random_appearance():
72
  return random.choice(APPEARANCES)
@@ -148,12 +200,11 @@ class World:
148
  }
149
 
150
  # ---------- 3) Init ----------
151
- ROLES = ["Saintess","Senior","Enforcer","Alchemist","ArrayMaster","Bard","Matchmaker","Shadow","Guest","Head"]
152
 
153
  def init_world(seed=42) -> World:
154
  random.seed(seed)
155
  ags = []
156
- for i in range(10):
157
  role = ROLES[i]
158
  gender = random_gender()
159
  ags.append(Agent(
@@ -242,68 +293,126 @@ def inform(world:World, speaker:str, listener:str, fact_key:str, boost=0.15):
242
 
243
  # ---------- 5) Actions(合欢宗简化版) ----------
244
  def update_relations(world: World, actor: str, target: str, event_type: str):
245
- # 获取当前关系
 
 
 
246
  actor_relations = world.relations.get(actor, {})
247
  target_relations = world.relations.get(target, {})
248
-
249
- # 初始化,如果没有的话
250
- actor_relations.setdefault(target, {"liking": 50, "trust": 50, "rivalry": 0})
251
- target_relations.setdefault(actor, {"liking": 50, "trust": 50, "rivalry": 0})
252
-
253
- # 根据事件类型调整关系
254
- if event_type == "gift":
255
- actor_relations[target]["liking"] = min(100, actor_relations[target]["liking"] + 10)
256
- target_relations[actor]["liking"] = min(100, target_relations[actor]["liking"] + 10)
257
- elif event_type == "confide":
258
- actor_relations[target]["trust"] = min(100, actor_relations[target]["trust"] + 15)
259
- target_relations[actor]["trust"] = min(100, target_relations[actor]["trust"] + 15)
260
- elif event_type == "spar":
261
- actor_relations[target]["rivalry"] = max(-100, actor_relations[target]["rivalry"] - 15)
262
- target_relations[actor]["rivalry"] = max(-100, target_relations[actor]["rivalry"] - 15)
263
- elif event_type == "expose":
264
- actor_relations[target]["rivalry"] = min(100, actor_relations[target]["rivalry"] + 30)
265
- target_relations[actor]["rivalry"] = min(100, target_relations[actor]["rivalry"] + 30)
266
-
267
- # 保存更新
268
  world.relations[actor] = actor_relations
269
  world.relations[target] = target_relations
270
 
271
 
272
- def act_gift(world:World, giver:str, receiver:str, place="藏书阁"):
273
- ev = make_event(world.day, "gift", [giver, receiver], {"place":place,"item":"清心茶"})
274
- world.events[ev.id] = ev
275
- # 当事人记忆
276
- for nm in [giver, receiver]:
277
- ag = next(a for a in world.agents if a.name==nm)
278
- fk = f"gift_{giver}_{receiver}_d{world.day}"
279
- upsert_memory(ag, fk, {"type":"gift","giver":giver,"receiver":receiver,"place":place},
280
- world.day, {"src":"self_participant","cred":0.9}, 0.9)
281
- # 旁观者
282
- obs = sample_observers(world, ev, base_p=0.18)
283
- world.observations += obs
284
- for o in obs:
285
- ag = next(a for a in world.agents if a.name==o.observer)
286
- fk = f"gift_{giver}_{receiver}_d{world.day}"
287
- conf = max(0.2, o.cred*(1-o.noise))
288
- upsert_memory(ag, fk, {"type":"gift_hint","giver":giver,"receiver":receiver,"place":place},
289
- world.day, {"src":o.mode,"cred":conf}, conf)
290
- # 流言上板
291
- if random.random() < 0.25:
292
- publish_public(world, f"gift_{giver}_{receiver}",
293
- {"hint":"有人在藏书阁递了东西"}, world.day, 0.55, "rumor")
294
-
295
- def act_confide(world:World, a:str, b:str):
296
- ev = make_event(world.day, "confide", [a,b], {"topic":"心法共鸣"})
297
- world.events[ev.id] = ev
298
- for nm in [a,b]:
299
- ag = next(x for x in world.agents if x.name==nm)
300
- fk = f"confide_{a}_{b}_d{world.day}"
301
- upsert_memory(ag, fk, {"type":"confide","pair":[a,b]}, world.day, {"src":"private_talk","cred":0.95}, 0.95)
302
- for o in sample_observers(world, ev, 0.12):
303
- ag = next(x for x in world.agents if x.name==o.observer)
304
- fk = f"confide_{a}_{b}_d{world.day}"
305
- conf = max(0.15, o.cred*(1-o.noise))
306
- upsert_memory(ag, fk, {"type":"confide_hint","pair":[a,b]}, world.day, {"src":o.mode,"cred":conf}, conf)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
307
 
308
  def act_expose(world:World, accuser:str, target:str, evidence:str):
309
  ev = make_event(world.day, "expose", [accuser,target], {"evidence":evidence})
@@ -527,14 +636,26 @@ def tick_one_day(world: World):
527
  formatted_events = []
528
  for event in daily_events:
529
  if event.type == "expose":
530
- # 使用 agent 名字和事件描述
531
  formatted_events.append(f"🗣️ <b>{event.actors[0]} 揭发了 {event.actors[1]}</b>!这是关于 {event.payload.get('evidence', '残页证据')} 的丑闻。")
532
  elif event.type == "gift":
533
  formatted_events.append(f"🎁 <b>{event.actors[0]} 送给 {event.actors[1]} 一份礼物</b>,暗示着他们之间的关系发生了微妙变化。")
534
  elif event.type == "spar":
535
  formatted_events.append(f"⚔️ <b>{event.actors[0]} 与 {event.actors[1]} 进行了比试</b>,并且 {event.actors[0]} 获胜!")
 
 
 
 
 
 
 
 
 
 
 
 
 
536
  else:
537
- formatted_events.append(f"🔍 发生了未明确的事件:{event.type},参与者:{event.actors[0]} 和 {event.actors[1]}")
538
 
539
  narration += "\n\n" + "\n".join(formatted_events)
540
 
@@ -621,7 +742,7 @@ def agents_dataframe(world: World) -> pd.DataFrame:
621
  rows.append({
622
  "ID": a.name,
623
  "姓名": a.full_name,
624
- "角色": a.role,
625
  "灵根": a.spirit_root,
626
  "性格": pers,
627
  "黑化?": "✔ 黑化" if getattr(a, "is_darkened", False) else "❌",
@@ -647,9 +768,12 @@ def public_board_pretty(world: World) -> str:
647
  lines.append(f"🤝 <b>{x.actors[0]}</b> 向 <b>{x.actors[1]}</b> 发誓,誓言让他们的关系更加牢固。")
648
  elif event_type == "expose":
649
  lines.append(f"⚠️ <b>{x.actors[0]}</b> 揭发了 <b>{x.actors[1]}</b> 的丑闻!证据:{c.get('evidence', '残页证据')}")
 
 
 
 
650
  else:
651
  lines.append(f"🔍 发生了未明确的事件:<b>{event_type}</b>,涉及人物:<b>{', '.join(x.actors)}</b>")
652
-
653
  return "<br>".join(lines)
654
 
655
 
@@ -713,7 +837,7 @@ def ui_inform_pretty(speaker, listener, fact_key):
713
  theme = gr.themes.Soft(primary_hue="violet", neutral_hue="slate")
714
 
715
  with gr.Blocks(theme=theme, analytics_enabled=False) as demo:
716
- gr.Markdown("## 🌸 合欢宗 · 多角恋八卦模拟(10 Agents, Day-based)")
717
 
718
  with gr.Tab("Dashboard"):
719
  sum_html = gr.HTML(world_summary_html(WORLD))
 
1
+
2
+
3
  # ---------- 1) Imports & Config ----------
4
  import os, uuid, json, random
5
  from dataclasses import dataclass, field, asdict
 
23
  max_new_tokens=180, do_sample=True, temperature=0.9, top_p=0.95
24
  )[0]["generated_text"]
25
  return out[-600:].strip()
26
+ import torch
27
+ from transformers import pipeline
28
+ import time
29
+
30
+ # 检查 GPU 是否可用
31
+ device = 0 if torch.cuda.is_available() else -1
32
+ print(f"Device set to {'GPU' if device == 0 else 'CPU'}")
33
+
34
+ # 加载模型并显示进度
35
+ print("Loading model...")
36
+ start_time = time.time()
37
+ generator = pipeline(
38
+ "text-generation",
39
+ model="tiiuae/Falcon-E-1B-Instruct",
40
+ device=device
41
+ )
42
+ print(f"Model loaded in {time.time() - start_time:.2f} seconds!")
43
+
44
+ # 显示是否在使用 GPU
45
+ if torch.cuda.is_available():
46
+ print(f"Using GPU: {torch.cuda.get_device_name(0)}")
47
+ else:
48
+ print("Using CPU")
49
+
50
+ # 测试生成的输出,确保可以推理
51
+ print("Testing model inference...")
52
+ test_output = generator("Please generate a story.")
53
+ print(f"Generated text: {test_output[0]['generated_text']}")
54
 
55
  # ---------- 2) Data Models ----------
56
  Day = int
 
59
  class Agent:
60
  name: str
61
  role: str
62
+ relations: Dict[str, Dict[str, float]] = field(default_factory=dict) # 存储与其他角色的关系
 
 
 
63
  memory: Dict[str, Any] = field(default_factory=dict)
64
  belief_about_others: Dict[str, Dict[str, Any]] = field(default_factory=dict)
65
+ full_name: str = ""
66
+ gender: str = ""
 
67
  height: int = 170
68
  appearance: str = ""
69
  spirit_root: str = ""
 
72
  cultivation: int = 50
73
  willpower: int = 50
74
  face: int = 0
 
75
  scandal: int = 0
76
  ####基础信息生成
77
+
78
+ ROLES = ["炼气期", "筑基期", "金丹期", "元婴期", "化神期", "合体期", "大乘期"]
79
  #name
80
+ SURNAMES = [
81
+ "", "", "", "欧阳", "慕容", "上官", "东方", "南宫", "司马", "诸葛",
82
+ "龙", "风", "云", "凤", "陆", "沈", "陆", "白", "周", "秦",
83
+ "冯", "段", "朱", "唐", "陆", "花", "凌", "慕", "方", "柏",
84
+ "纪", "萧", "沈", "简", "颜", "祁", "孟", "庞", "苏", "施",
85
+ "夏", "石", "钟", "梁", "丁", "阮", "黄", "唐", "陈", "范",
86
+ "萧", "韦", "何", "冯", "穆", "丘", "薛", "杜", "任", "俞"
87
+ ]
88
+
89
+ NAME_PARTS = [
90
+ "清", "灵", "雪", "尘", "梦", "羽", "轩", "霖", "珏", "婉",
91
+ "澈", "寒", "月", "落", "竹", "珊", "风", "云", "雨", "山", "水",
92
+ "青", "霄", "渊", "瑶", "萧", "璇", "月", "辰", "遥", "瑾",
93
+ "璃", "星", "凝", "寒", "竹", "飞", "悠", "萧", "星", "琴",
94
+ "瑶", "晨", "逸", "岚", "沧", "洛", "晨", "凌", "宸", "熙",
95
+ "鸣", "尧", "洛", "彭", "遥", "兰", "琪", "霖", "思", "尘",
96
+ "璇", "涵", "泽", "涵", "彬", "雅", "泽", "宇", "琪",
97
+ # 新增的2个字名字部分
98
+ "紫霄", "白霜", "千秋", "云霁", "玉瑶", "青兰", "月华", "星辰",
99
+ "秋水", "长风", "天瑶", "暮雪", "寒月", "紫烟", "白月", "流云",
100
+ "醉影", "逍遥", "凌风", "清逸", "皓月", "星云", "红叶", "碧空",
101
+ "天雪", "玄霄", "冰心", "凝烟", "云笙", "水月", "风轻", "夜星",
102
+ "羽瑶", "千尘", "翠烟", "紫电", "空灵", "雪影", "云起", "凌云",
103
+ "独孤", "风华", "清幽", "白兰", "青冥", "羽寒", "天风", "冰澜"
104
+ ]
105
+
106
 
107
  def random_name():
108
  surname = random.choice(SURNAMES)
 
111
 
112
  #长相
113
  APPEARANCES = ["清秀","俊逸","冷艳","稚气","邪魅","清冷","英气","娇美","秀雅","潇洒"]
114
+ #灵根
115
  SPIRIT_ROOTS = ["金灵根","木灵根","水灵根","火灵根","土灵根","冰灵根","风灵根","雷灵根","混沌灵根"]
116
 
117
  def random_gender():
118
  return random.choice(["male","female"])
119
 
120
  def random_height(gender):
121
+ return random.randint(168,200) if gender=="male" else random.randint(155,175)
122
 
123
  def random_appearance():
124
  return random.choice(APPEARANCES)
 
200
  }
201
 
202
  # ---------- 3) Init ----------
 
203
 
204
  def init_world(seed=42) -> World:
205
  random.seed(seed)
206
  ags = []
207
+ for i in range(3):
208
  role = ROLES[i]
209
  gender = random_gender()
210
  ags.append(Agent(
 
293
 
294
  # ---------- 5) Actions(合欢宗简化版) ----------
295
  def update_relations(world: World, actor: str, target: str, event_type: str):
296
+ """
297
+ 更新角色之间的关系,保存好感度、信任度、敌对度和嫉妒心。
298
+ """
299
+ # 获取角色的关系字典
300
  actor_relations = world.relations.get(actor, {})
301
  target_relations = world.relations.get(target, {})
302
+
303
+ # 初始化关系数据(如果不存在)
304
+ if target not in actor_relations:
305
+ actor_relations[target] = {"liking": 0, "trust": 0, "rivalry": 0, "jealousy": 0}
306
+ if actor not in target_relations:
307
+ target_relations[actor] = {"liking": 0, "trust": 0, "rivalry": 0, "jealousy": 0}
308
+
309
+ # 只保存更新后的关系(好感度、嫉妒心等)
 
 
 
 
 
 
 
 
 
 
 
 
310
  world.relations[actor] = actor_relations
311
  world.relations[target] = target_relations
312
 
313
 
314
+
315
+ def act_gift(world: World, giver: str, receiver: str):
316
+ """
317
+ 角色 A 赠送礼物给角色 B,增加好感度并可能引发嫉妒。
318
+ """
319
+ giver_agent = next(agent for agent in world.agents if agent.name == giver)
320
+ receiver_agent = next(agent for agent in world.agents if agent.name == receiver)
321
+
322
+ # 增加好感度
323
+ giver_agent.relations[receiver]["liking"] += 10
324
+ receiver_agent.relations[giver]["liking"] += 10
325
+
326
+ # 检查是否有第三方嫉妒
327
+ other_agents = [agent for agent in world.agents if agent.name != giver and agent.name != receiver]
328
+ third_party = max(other_agents, key=lambda x: x.relations[giver]["liking"] if x.relations[giver]["liking"] > x.relations[receiver]["liking"] else x.relations[receiver]["liking"])
329
+
330
+ # 增加嫉妒心
331
+ third_party.relations[giver]["jealousy"] += 10
332
+ third_party.relations[receiver]["jealousy"] += 10
333
+
334
+ # 发布流言
335
+ if random.random() < 0.25: # 有一定概率发布流言
336
+ publish_public(world, f"gift_{giver}_{receiver}", {"hint": "有人在藏书阁递了东西"}, world.day, 0.55, "rumor")
337
+
338
+ # 更新关系
339
+ update_relations(world, giver, receiver, "gift")
340
+ update_relations(world, receiver, third_party.name, "gift")
341
+
342
+ # 返回事件描述
343
+ return f"{giver} 赠送了礼物给 {receiver},增进了好感度,第三方 {third_party.name} 产生了嫉妒。"
344
+
345
+ def act_confide(world: World, actor: str, target: str):
346
+ """
347
+ 角色 A 向角色 B 倾诉心事,可能会触发三角恋情节
348
+ - 如果角色 A B 表白或倾诉时,可能涉及第三方 C 引发嫉妒等情感纠葛。
349
+ """
350
+ actor_agent = next(agent for agent in world.agents if agent.name == actor)
351
+ target_agent = next(agent for agent in world.agents if agent.name == target)
352
+
353
+ # 判断是否涉及三角恋情节,随机选择第三方角色 C
354
+ other_agents = [agent for agent in world.agents if agent.name != actor and agent.name != target]
355
+ third_party = max(other_agents, key=lambda x: x.relations[actor]["liking"] if x.relations[actor]["liking"] > x.relations[target]["liking"] else x.relations[target]["liking"]) # 第三者选择对两者好感度较高的
356
+
357
+ # 获取被表白者对表白者的好感度
358
+ liking_score = target_agent.relations[actor]["liking"] # B对A的好感度
359
+
360
+ # 表白是否成功,成功几率与好感度相关
361
+ is_successful = random.random() < (liking_score / 100) # 好感度越高,成功概率越大
362
+
363
+ if is_successful:
364
+ # A向B表白并成功,第三方嫉妒
365
+ event_description = f"{actor} 向 {target} 表白成功,二人产生了深厚的情感,而 {third_party.name} 看到后感到嫉妒!"
366
+
367
+ # 更新关系中的嫉妒心
368
+ actor_agent.relations[target]["jealousy"] += 10 # A因得到回应产生更多的情感波动
369
+ target_agent.relations[actor]["jealousy"] += 5 # B因接受表白产生情感波动
370
+ third_party_agent = third_party # C看到表白成功,产生嫉妒
371
+ third_party_agent.relations[actor]["jealousy"] += 20 # C因为插足产生嫉妒
372
+ third_party_agent.relations[target]["jealousy"] += 20 # C因为插足产生嫉妒
373
+
374
+ # 发布流言
375
+ if random.random() < 0.25: # 有一定概率发布流言
376
+ publish_public(world, f"triangle_love_{actor}_{target}", {"hint": "有人偷偷在藏书阁表白"}, world.day, 0.55, "rumor")
377
+
378
+ # 更新关系
379
+ update_relations(world, actor, target, "confide")
380
+ update_relations(world, target, third_party_agent.name, "confide")
381
+
382
+ # 更新角色的记忆
383
+ memory_key = f"{actor}_confides_in_{target}_success"
384
+ upsert_memory(actor_agent, memory_key, {"event": event_description, "target": target, "third_party": third_party.name})
385
+ upsert_memory(target_agent, memory_key, {"event": event_description, "actor": actor, "third_party": third_party.name})
386
+ upsert_memory(third_party_agent, memory_key, {"event": event_description, "actor": actor, "target": target})
387
+
388
+ return event_description # 返回事件描述
389
+
390
+ else:
391
+ # A向B表白失败,第三方窃喜
392
+ event_description = f"{actor} 向 {target} 表白失败,{target} 拒绝了 {actor},而 {third_party.name} 看到后感到窃喜!"
393
+
394
+ # 更新关系中的嫉妒心
395
+ actor_agent.relations[target]["jealousy"] += 20 # A因未被接受产生嫉妒
396
+ target_agent.relations[actor]["jealousy"] += 5 # B因拒绝A表白产生负面情绪
397
+ third_party_agent = third_party # C看到表白失败,窃喜
398
+ third_party_agent.relations[actor]["jealousy"] -= 5 # C因表白失败感到窃喜,嫉妒心降低
399
+ third_party_agent.relations[target]["jealousy"] -= 5 # C因表白失败感到窃喜,嫉妒心降低
400
+
401
+ # 发布流言
402
+ if random.random() < 0.25: # 有一定概率发布流言
403
+ publish_public(world, f"triangle_love_{actor}_{target}_failure", {"hint": "有人偷偷在藏书阁被拒绝了"}, world.day, 0.55, "rumor")
404
+
405
+ # 更新关系
406
+ update_relations(world, actor, target, "confide")
407
+ update_relations(world, target, third_party_agent.name, "confide")
408
+
409
+ # 更新角色的记忆
410
+ memory_key = f"{actor}_confides_in_{target}_failure"
411
+ upsert_memory(actor_agent, memory_key, {"event": event_description, "target": target, "third_party": third_party.name})
412
+ upsert_memory(target_agent, memory_key, {"event": event_description, "actor": actor, "third_party": third_party.name})
413
+ upsert_memory(third_party_agent, memory_key, {"event": event_description, "actor": actor, "target": target})
414
+
415
+ return event_description # 返回事件描述
416
 
417
  def act_expose(world:World, accuser:str, target:str, evidence:str):
418
  ev = make_event(world.day, "expose", [accuser,target], {"evidence":evidence})
 
636
  formatted_events = []
637
  for event in daily_events:
638
  if event.type == "expose":
 
639
  formatted_events.append(f"🗣️ <b>{event.actors[0]} 揭发了 {event.actors[1]}</b>!这是关于 {event.payload.get('evidence', '残页证据')} 的丑闻。")
640
  elif event.type == "gift":
641
  formatted_events.append(f"🎁 <b>{event.actors[0]} 送给 {event.actors[1]} 一份礼物</b>,暗示着他们之间的关系发生了微妙变化。")
642
  elif event.type == "spar":
643
  formatted_events.append(f"⚔️ <b>{event.actors[0]} 与 {event.actors[1]} 进行了比试</b>,并且 {event.actors[0]} 获胜!")
644
+ elif event.type == "confide":
645
+ # For confide events, include success or failure of the confession
646
+ result = "心意已达" if event.payload.get('result') == 'success' else "表白未果"
647
+ formatted_events.append(f"🗣️ <b>{event.actors[0]} 向 {event.actors[1]}</b> 倾诉心事,{result},情感深沉。")
648
+ elif event.type == "rumor":
649
+ # If the event is a rumor, format the details accordingly
650
+ formatted_events.append(f"💬 <b>{event.actors[0]} 传出了关于 {event.payload.get('about', '某人')}</b> 的流言。")
651
+ elif event.type == "oath":
652
+ formatted_events.append(f"🤝 <b>{event.actors[0]} 向 <b>{event.actors[1]}</b> 立下誓言</b>,誓言让他们的关系更深。")
653
+ elif event.type == "sabotage":
654
+ formatted_events.append(f"💥 <b>{event.actors[0]} 对 <b>{event.actors[1]}</b> 进行了破坏</b>,引发了一场风波。")
655
+ elif event.type == "mediate":
656
+ formatted_events.append(f"🕊️ <b>{event.actors[0]} 调解了 <b>{event.actors[1]} 和 {event.actors[2]}</b> 之间的争执</b>,关系暂时恢复平静。")
657
  else:
658
+ formatted_events.append(f"🔍 发生了未明确的事件:<b>{event.type}</b>,参与者:<b>{', '.join(event.actors)}</b>")
659
 
660
  narration += "\n\n" + "\n".join(formatted_events)
661
 
 
742
  rows.append({
743
  "ID": a.name,
744
  "姓名": a.full_name,
745
+ "修为": a.role,
746
  "灵根": a.spirit_root,
747
  "性格": pers,
748
  "黑化?": "✔ 黑化" if getattr(a, "is_darkened", False) else "❌",
 
768
  lines.append(f"🤝 <b>{x.actors[0]}</b> 向 <b>{x.actors[1]}</b> 发誓,誓言让他们的关系更加牢固。")
769
  elif event_type == "expose":
770
  lines.append(f"⚠️ <b>{x.actors[0]}</b> 揭发了 <b>{x.actors[1]}</b> 的丑闻!证据:{c.get('evidence', '残页证据')}")
771
+ elif event_type == "confide":
772
+ # Check if the confession was successful or failed and express it in classical style
773
+ result = "心意已达" if c.get('result') == 'success' else "表白未果"
774
+ lines.append(f"🗣️ <b>{x.actors[0]}</b> 向 <b>{x.actors[1]}</b> 倾诉心事,{result},情感深沉。")
775
  else:
776
  lines.append(f"🔍 发生了未明确的事件:<b>{event_type}</b>,涉及人物:<b>{', '.join(x.actors)}</b>")
 
777
  return "<br>".join(lines)
778
 
779
 
 
837
  theme = gr.themes.Soft(primary_hue="violet", neutral_hue="slate")
838
 
839
  with gr.Blocks(theme=theme, analytics_enabled=False) as demo:
840
+ gr.Markdown("## 🌸 某某宗 · 多角恋八卦模拟(10 Agents, Day-based)")
841
 
842
  with gr.Tab("Dashboard"):
843
  sum_html = gr.HTML(world_summary_html(WORLD))