add asyncio

This commit is contained in:
bridge
2025-09-02 22:16:03 +08:00
parent 0f9f5f35f7
commit bd28da21f5
7 changed files with 90 additions and 28 deletions

View File

@@ -60,8 +60,8 @@ class Avatar:
在Avatar创建后自动初始化tile和AI
"""
self.tile = self.world.map.get_tile(self.pos_x, self.pos_y)
# self.ai = LLMAI(self)
self.ai = RuleAI(self)
self.ai = LLMAI(self)
# self.ai = RuleAI(self)
def __str__(self) -> str:
"""
@@ -91,7 +91,7 @@ class Avatar:
raise ValueError(f"未找到名为 '{action_name}' 的动作类")
def act(self):
async def act(self):
"""
角色执行动作。
实际上分为两步决定做什么decide和实际去做do
@@ -101,7 +101,7 @@ class Avatar:
if self.cur_action_pair is None:
# 决定动作时生成事件
action_name, action_args, event = self.ai.decide(self.world)
action_name, action_args, event = await self.ai.decide(self.world)
action = self.create_action(action_name)
self.cur_action_pair = (action, action_args)