Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modify werewolf game #11

Merged
merged 4 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/werewolf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ More details please refer to the code of [`DictDialogAgent`](../..
with msghub(wolves, announcement=hint) as hub:
for _ in range(MAX_WEREWOLF_DISCUSSION_ROUND):
x = sequentialpipeline(wolves)
if x.agreement:
if x.get("agreement", False):
break
# ...
```
7 changes: 4 additions & 3 deletions examples/werewolf/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Prompts:
to_wolves = (
"{}, you are werewolves. If you are alone, eliminate a player, else "
"discuss with your teammates and reach an agreement. Response in the "
"following format which can be loaded by python json.loads()"
"following format which can be loaded by python json.loads()\n"
"{{\n"
' "thought": "thought",\n'
' "speak": "thoughts summary to say to others",\n'
Expand All @@ -35,7 +35,7 @@ class Prompts:
"{{\n"
' "thought": "thought",\n'
' "speak": "thoughts summary to say",\n'
' "resurrect": "true/false"\n'
' "resurrect": true/false\n'
"}}"
)

Expand All @@ -44,7 +44,8 @@ class Prompts:
"json format which can be loaded by python json.loads()\n"
"{{\n"
' "thought": "thought", \n'
' "speak": "False or player_name"\n'
' "speak": "thoughts summary to say",\n'
' "eliminate": ture/false\n'
"}}"
)

Expand Down
6 changes: 3 additions & 3 deletions examples/werewolf/werewolf.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
with msghub(wolves, announcement=hint) as hub:
for _ in range(MAX_WEREWOLF_DISCUSSION_ROUND):
x = sequentialpipeline(wolves)
if x.agreement:
if x.get("agreement", False):
break

# werewolves vote
Expand All @@ -56,14 +56,14 @@
{"witch_name": witch.name, "dead_name": dead_player[0]},
),
)
if witch(hint).resurrect:
if witch(hint).get("resurrect", False):
healing_used_tonight = True
dead_player.pop()
healing = False

if poison and not healing_used_tonight:
x = witch(HostMsg(content=Prompts.to_witch_poison))
if "False" not in x.content:
if x.get("eliminate", False):
dead_player.append(extract_name_and_id(x.content)[0])
poison = False

Expand Down