3333 event_observe_label ,
3434 event_observe_phrases ,
3535 event_rest_phrases ,
36+ mem_memory_action_map ,
37+ mem_memory_event_action_label ,
38+ mem_memory_event_day_line ,
39+ mem_memory_event_dialogue_label ,
40+ mem_memory_event_recent_label ,
41+ mem_memory_query_action_label ,
42+ mem_memory_query_events_label ,
43+ mem_memory_query_persona_label ,
44+ mem_memory_time_map ,
45+ mem_memory_weather_map ,
46+ mem_teammate_label ,
3647 prompt_memory_tag_by_theme ,
3748 sys_advance_km_arrived ,
3849 sys_advance_km_en_route ,
7182 sys_vote_result_keep ,
7283 sys_you_choose_rest ,
7384)
74- from aotai_hike .world .map_data import get_graph
85+ from aotai_hike .world .map_data import get_graph , get_node_display_name
7586from loguru import logger
7687
7788
@@ -405,15 +416,13 @@ def _apply_decision(
405416 (r .name for r in world_state .roles if r .role_id == world_state .leader_role_id ),
406417 "未知" ,
407418 )
408- node_name = (
409- get_graph (getattr (world_state , "theme" , "aotai" ))
410- .get_node (world_state .current_node_id )
411- .name
412- )
419+ theme = getattr (world_state , "theme" , "aotai" )
420+ lang = _lang (world_state )
421+ node_name = get_node_display_name (theme , lang , world_state .current_node_id )
413422 plan_name = (
414- get_graph ( getattr ( world_state , "theme" , "aotai" )). get_node ( next_id ). name
423+ get_node_display_name ( theme , lang , next_id )
415424 if next_id
416- else " (未选择)"
425+ else ( "(not selected)" if lang == "en" else " (未选择)")
417426 )
418427 ev = f"营地共识:在 { node_name } ,共识路线=去 { plan_name } ,锁强度={ world_state .lock_strength } ,次日团长={ who } "
419428 self ._push_event (world_state , ev )
@@ -627,7 +636,11 @@ def _enter_camp_meeting(
627636 # Very light mock proposal: pick one option (or "stay" if none)
628637 if opts :
629638 pick = self ._rng .choice (opts )
630- dest = get_graph (getattr (world_state , "theme" , "aotai" )).get_node (pick ).name
639+ dest = get_node_display_name (
640+ getattr (world_state , "theme" , "aotai" ),
641+ _lang (world_state ),
642+ pick ,
643+ )
631644 text = sys_camp_proposal_dest (_lang (world_state ), dest )
632645 else :
633646 text = sys_camp_proposal_rest (_lang (world_state ))
@@ -690,7 +703,11 @@ def _auto_camp_meeting(
690703 continue
691704 if opts :
692705 pick = self ._rng .choice (opts )
693- dest = get_graph (getattr (world_state , "theme" , "aotai" )).get_node (pick ).name
706+ dest = get_node_display_name (
707+ getattr (world_state , "theme" , "aotai" ),
708+ _lang (world_state ),
709+ pick ,
710+ )
694711 text = sys_camp_proposal_dest (_lang (world_state ), dest )
695712 else :
696713 text = sys_camp_proposal_rest (_lang (world_state ))
@@ -838,9 +855,6 @@ def _apply_action(
838855 if req .action == ActionType .CONTINUE :
839856 req .action = ActionType .MOVE_FORWARD
840857
841- node = get_graph (getattr (world_state , "theme" , "aotai" )).get_node (
842- world_state .current_node_id
843- )
844858 # UI-only; we keep it empty in the auto-run flow unless we explicitly need a user choice.
845859 world_state .available_next_node_ids = []
846860
@@ -850,7 +864,11 @@ def _apply_action(
850864 kind = "system" ,
851865 content = sys_location_weather_time (
852866 _lang (world_state ),
853- node .name ,
867+ get_node_display_name (
868+ getattr (world_state , "theme" , "aotai" ),
869+ _lang (world_state ),
870+ world_state .current_node_id ,
871+ ),
854872 world_state .weather ,
855873 world_state .day ,
856874 world_state .time_of_day ,
@@ -973,8 +991,10 @@ def _apply_action(
973991
974992 ev = self ._rng .choice (event_arrived_phrases (_lang (world_state )))
975993 self ._push_event (world_state , ev )
976- node_name = (
977- get_graph (getattr (world_state , "theme" , "aotai" )).get_node (next_id ).name
994+ node_name = get_node_display_name (
995+ getattr (world_state , "theme" , "aotai" ),
996+ _lang (world_state ),
997+ next_id ,
978998 )
979999 messages .append (
9801000 Message (
@@ -1068,9 +1088,11 @@ def _apply_action(
10681088 content = sys_at_junction_leader_chose (
10691089 _lang (world_state ),
10701090 leader_name ,
1071- get_graph (getattr (world_state , "theme" , "aotai" ))
1072- .get_node (next_edge .to_node_id )
1073- .name ,
1091+ get_node_display_name (
1092+ getattr (world_state , "theme" , "aotai" ),
1093+ _lang (world_state ),
1094+ next_edge .to_node_id ,
1095+ ),
10741096 ),
10751097 timestamp_ms = now_ms ,
10761098 )
@@ -1153,7 +1175,9 @@ def _apply_action(
11531175
11541176 ev = self ._rng .choice (event_arrived_phrases_start (_lang (world_state )))
11551177 self ._push_event (world_state , ev )
1156- node_name = get_graph (getattr (world_state , "theme" , "aotai" )).get_node (next_id ).name
1178+ node_name = get_node_display_name (
1179+ getattr (world_state , "theme" , "aotai" ), _lang (world_state ), next_id
1180+ )
11571181 messages .append (
11581182 Message (
11591183 message_id = f"sys-{ uuid .uuid4 ().hex [:8 ]} " ,
@@ -1167,10 +1191,10 @@ def _apply_action(
11671191 return f"MOVE_FORWARD:arrive:{ next_id } "
11681192
11691193 left = max (0.0 , world_state .in_transit_total_km - world_state .in_transit_progress_km )
1170- to_name = (
1171- get_graph ( getattr (world_state , "theme" , "aotai" ))
1172- . get_node ( next_edge . to_node_id )
1173- . name
1194+ to_name = get_node_display_name (
1195+ getattr (world_state , "theme" , "aotai" ),
1196+ _lang ( world_state ),
1197+ next_edge . to_node_id ,
11741198 )
11751199 messages .append (
11761200 Message (
@@ -1322,66 +1346,55 @@ def _format_memory_event(
13221346 user_action_desc : str ,
13231347 messages : list [Message ],
13241348 ) -> str :
1325- time_map = {
1326- "morning" : "早晨" ,
1327- "noon" : "中午" ,
1328- "afternoon" : "下午" ,
1329- "evening" : "傍晚" ,
1330- "night" : "夜晚" ,
1331- }
1332- weather_map = {
1333- "sunny" : "晴" ,
1334- "cloudy" : "多云" ,
1335- "windy" : "有风" ,
1336- "rainy" : "雨" ,
1337- "snowy" : "雪" ,
1338- "foggy" : "雾" ,
1339- }
1349+ lang = _lang (world_state )
1350+ time_map = mem_memory_time_map (lang )
1351+ weather_map = mem_memory_weather_map (lang )
1352+ action_map = mem_memory_action_map (lang )
13401353
13411354 action_name = getattr (req .action , "name" , str (req .action ))
1342- action_cn_map = {
1343- "SAY" : "发言" ,
1344- "MOVE_FORWARD" : "前进" ,
1345- "REST" : "休息" ,
1346- "CAMP" : "扎营" ,
1347- "OBSERVE" : "观察" ,
1348- "DECIDE" : "决策" ,
1349- }
1350- action_cn = action_cn_map .get (action_name , action_name )
1355+ action_str = action_map .get (action_name , action_name )
13511356
13521357 day = world_state .day
1353- tod_cn = time_map .get (world_state .time_of_day , str (world_state .time_of_day ))
1354- weather_cn = weather_map .get (world_state .weather , str (world_state .weather ))
1358+ tod = time_map .get (world_state .time_of_day , str (world_state .time_of_day ))
1359+ weather = weather_map .get (world_state .weather , str (world_state .weather ))
13551360 node_name = getattr (node , "name" , "" )
13561361
1362+ pieces : list [str ] = []
1363+ pieces .append (mem_memory_event_day_line (lang , day , tod , weather , node_name ))
1364+ pieces .append (mem_memory_event_action_label (lang ) + action_str )
1365+
13571366 recent_events = world_state .recent_events [- 3 :] if world_state .recent_events else []
1358- recent_events_txt = ";" .join (recent_events )
1367+ if recent_events :
1368+ sep = "; " if lang == "en" else ";"
1369+ pieces .append (mem_memory_event_recent_label (lang ) + sep .join (recent_events ) + "." )
13591370
13601371 dialogue_msgs = [m for m in messages if m .kind != "system" ]
13611372 dialogue_parts : list [str ] = []
1373+ teammate = mem_teammate_label (lang )
13621374 for m in dialogue_msgs [:3 ]:
1363- speaker = m .role_name or m .role_id or "队员"
1364- dialogue_parts .append (f"{ speaker } :{ m .content [:40 ]} " )
1365- dialogue_txt = ";" .join (dialogue_parts )
1366-
1367- pieces : list [str ] = []
1368- pieces .append (f"第{ day } 天,{ tod_cn } ,天气{ weather_cn } ,位置:{ node_name } 。" )
1369- pieces .append (f"动作:{ action_cn } " )
1370- if recent_events_txt :
1371- pieces .append (f"最近事件:{ recent_events_txt } 。" )
1372- if dialogue_txt :
1373- pieces .append (f"关键对话:{ dialogue_txt } 。" )
1375+ speaker = m .role_name or m .role_id or teammate
1376+ dialogue_parts .append (
1377+ f"{ speaker } : { m .content [:40 ]} " if lang == "en" else f"{ speaker } :{ m .content [:40 ]} "
1378+ )
1379+ if dialogue_parts :
1380+ sep = "; " if lang == "en" else ";"
1381+ pieces .append (mem_memory_event_dialogue_label (lang ) + sep .join (dialogue_parts ) + "." )
13741382
13751383 return " " .join (pieces )
13761384
13771385 def _build_memory_query (
13781386 self , world_state : WorldState , req : ActRequest , node , user_action_desc : str
13791387 ) -> str :
1388+ lang = _lang (world_state )
13801389 active = self ._get_active_role (world_state )
13811390 persona = (active .persona if active else "" )[:80 ]
1382- ev = ";" .join (world_state .recent_events [- 3 :])
1391+ sep = "; " if lang == "en" else ";"
1392+ ev = sep .join (world_state .recent_events [- 3 :])
13831393 tag = prompt_memory_tag_by_theme (_theme (world_state ))
1384- return f"{ tag } { node .name } { world_state .weather } { world_state .time_of_day } 动作:{ req .action } { user_action_desc } 事件:{ ev } 人设:{ persona } "
1394+ action_label = mem_memory_query_action_label (lang )
1395+ events_label = mem_memory_query_events_label (lang )
1396+ persona_label = mem_memory_query_persona_label (lang )
1397+ return f"{ tag } { node .name } { world_state .weather } { world_state .time_of_day } { action_label } { req .action } { user_action_desc } { events_label } { ev } { persona_label } { persona } "
13851398
13861399 def _append_chat_history (self , world_state : WorldState , messages : list [Message ]) -> None :
13871400 if not messages :
0 commit comments