Skip to content

Commit

Permalink
Merge pull request #12 from ZiTao-Li/zitao/game_dev
Browse files Browse the repository at this point in the history
Checkpoint bug fixed and change magic pot to realistic concept
  • Loading branch information
ZiTao-Li authored Jan 18, 2024
2 parents 680f0fc + da4beff commit f3532b5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion examples/game/customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def visit(self):
# return (
# np.random.binomial(
# n=1,
# p=min(10 / 100, 1.0),
# p=min(self.friendship / 100, 1.0),
# )
# > 0
# )
Expand Down
12 changes: 7 additions & 5 deletions examples/game/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import random
import argparse
from loguru import logger
from typing import Optional

import agentscope
from agentscope.message import Msg
Expand Down Expand Up @@ -32,7 +33,7 @@ def invited_group_chat(
invited_customer,
player,
cur_plots_indices,
):
) -> Optional[int]:
logger.debug("\n---active_plots:" + str(cur_plots_indices))
if len(invited_customer) == 0:
return cur_plots_indices
Expand Down Expand Up @@ -140,7 +141,7 @@ def one_on_one_loop(customers, player):
break
send_pretty_msg(msg)
send_chat_msg(
"【系统】请输入“做菜”启动魔法锅,它会按所选定食材产生菜品。" " (对话轮次过多会使得顾客综合满意度下降。)",
"【系统】请输入“做菜”启动做菜程序,它会按所选定食材产生菜品。" " (对话轮次过多会使得顾客综合满意度下降。)",
)
msg = player(msg)
if len(msg["content"]) == 0 or "[TERMINATE]" in msg["content"]:
Expand Down Expand Up @@ -259,6 +260,7 @@ def main(args) -> None:
done_plots=done_plots,
customers=customers,
invited_customers=invited_customers,
visit_customers=[],
)

# set current plot and done plots
Expand Down Expand Up @@ -296,7 +298,7 @@ def main(args) -> None:
)
logger.debug("---active_plots:", active_plots)
checkpoint.cur_plots = active_plots
checkpoint.done_plots += [done_plot_idx]
checkpoint.done_plots.append(done_plot_idx)
next_active_roles = set(next_active_roles)
for c in checkpoint.customers:
if c.name in next_active_roles:
Expand All @@ -310,12 +312,12 @@ def main(args) -> None:
for c in customers
if c.name not in checkpoint.invited_customers
]
visit_customers = one_on_one_loop(rest_customers, player)
checkpoint.visit_customers = one_on_one_loop(rest_customers, player)
checkpoint.stage_per_night = StagePerNight.MAKING_INVITATION
elif checkpoint.stage_per_night == StagePerNight.MAKING_INVITATION:
# ============ making invitation decision =============
# player make invitation
invited = invite_customers(visit_customers)
invited = invite_customers(checkpoint.visit_customers)
checkpoint.stage_per_night = StagePerNight.INVITED_CHAT
invited_customers = [c for c in customers if c.name in invited]
checkpoint.invited_customers = invited_customers
Expand Down
5 changes: 3 additions & 2 deletions examples/game/ruled_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def cook(self):
if sel_ingr in ["结束", "**结束**"]: # For gradio
if len(cook_list) > 0:
break
send_chat_msg("【系统】你的魔法锅空空如也。")
send_chat_msg("【系统】你没有选中任何食材。")
elif sel_ingr in ["清空", "**清空**"]: # For gradio
cook_list.clear()
elif sel_ingr not in ingredients_list:
Expand All @@ -171,7 +171,8 @@ def cook(self):
# food = random_quality + food

send_chat_msg(
f"【系统】魔法锅周围光芒四射,你听到了轻微的咔哒声。当一切平静下来,一道《{food}》出现在你眼前。",
# f"【系统】魔法锅周围光芒四射,你听到了轻微的咔哒声。当一切平静下来,一道《{food}》出现在你眼前。",
f"【系统】你开始撸起袖子、开启炉灶。。。。当一切平静下来,一道《{food}》出现在客人眼前。",
)

return food
2 changes: 2 additions & 0 deletions examples/game/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ def __init__(
cur_plots: list,
done_plots: list,
invited_customers: list,
visit_customers: list,
):
self.stage_per_night = stage_per_night
self.customers = customers
self.cur_plots = cur_plots
self.done_plots = done_plots
self.invited_customers = invited_customers
self.visit_customers = visit_customers


def save_game_checkpoint(
Expand Down

0 comments on commit f3532b5

Please sign in to comment.