Synchronize Instances from AgentScope (#29)

This commit is contained in:
Lamont Huffman
2025-11-07 10:00:43 +08:00
committed by GitHub
parent 30d86efbb3
commit 1558fb86f9
9 changed files with 69 additions and 73 deletions

View File

@@ -2,31 +2,37 @@
# pylint: disable=too-many-branches, too-many-statements, no-name-in-module
"""A werewolf game implemented by agentscope."""
import numpy as np
from agentscope.agent import ReActAgent
from agentscope.pipeline import MsgHub, fanout_pipeline, sequential_pipeline
from prompt import EnglishPrompts as Prompts
from utils import (
MAX_DISCUSSION_ROUND,
MAX_GAME_ROUND,
EchoAgent,
Players,
majority_vote,
names_to_str,
EchoAgent,
MAX_GAME_ROUND,
MAX_DISCUSSION_ROUND,
Players,
)
from structured_model import (
DiscussionModel,
WitchResurrectModel,
get_hunter_model,
get_poison_model,
get_seer_model,
get_vote_model,
get_poison_model,
WitchResurrectModel,
get_seer_model,
get_hunter_model,
)
from prompt import EnglishPrompts as Prompts
# Uncomment the following line to use Chinese prompts
# from prompt import ChinesePrompts as Prompts
from agentscope.agent import ReActAgent
from agentscope.pipeline import (
MsgHub,
sequential_pipeline,
fanout_pipeline,
)
moderator = EchoAgent()
@@ -113,7 +119,7 @@ async def werewolves_game(agents: list[ReActAgent]) -> None:
names_to_str(players.current_alive),
),
),
name="game_werewolves",
name="werewolves",
) as werewolves_hub:
# Discussion
n_werewolves = len(players.werewolves)

View File

@@ -4,15 +4,16 @@
import asyncio
import os
from game import werewolves_game
from agentscope.agent import ReActAgent
from agentscope.formatter import DashScopeMultiAgentFormatter
from agentscope.model import DashScopeChatModel
from agentscope.session import JSONSession
from game import werewolves_game
def get_official_agents(name: str) -> ReActAgent:
"""Get the official game_werewolves game agents."""
"""Get the official werewolves game agents."""
agent = ReActAgent(
name=name,
sys_prompt=f"""You're a werewolf game player named {name}.
@@ -21,9 +22,9 @@ def get_official_agents(name: str) -> ReActAgent:
Your target is to win the game with your teammates as much as possible.
# GAME RULES
- In werewolf game, players are divided into three game_werewolves, three villagers, one seer, one hunter and one witch.
- In werewolf game, players are divided into three werewolves, three villagers, one seer, one hunter and one witch.
- Werewolves: kill one player each night, and must hide identity during the day.
- Villagers: ordinary players without special abilities, try to identify and eliminate game_werewolves.
- Villagers: ordinary players without special abilities, try to identify and eliminate werewolves.
- Seer: A special villager who can check one player's identity each night.
- Witch: A special villager with two one-time-use potions: a healing potion to save a player from being killed at night, and a poison to eliminate one player at night.
- Hunter: A special villager who can take one player down with them when they are eliminated.
@@ -39,18 +40,18 @@ Your target is to win the game with your teammates as much as possible.
# GAME GUIDANCE
- Try your best to win the game with your teammates, tricks, lies, and deception are all allowed, e.g. pretending to be a different role.
- During discussion, don't be political, be direct and to the point.
- The day phase voting provides important clues. For example, the game_werewolves may vote together, attack the seer, etc.
- The day phase voting provides important clues. For example, the werewolves may vote together, attack the seer, etc.
## GAME GUIDANCE FOR WEREWOLF
- Seer is your greatest threat, who can check one player's identity each night. Analyze players' speeches, find out the seer and eliminate him/her will greatly increase your chances of winning.
- In the first night, making random choices is common for game_werewolves since no information is available.
- In the first night, making random choices is common for werewolves since no information is available.
- Pretending to be other roles (seer, witch or villager) is a common strategy to hide your identity and mislead other villagers in the day phase.
- The outcome of the night phase provides important clues. For example, if witch uses the healing or poison potion, if the dead player is hunter, etc. Use this information to adjust your strategy.
## GAME GUIDANCE FOR SEER
- Seer is very important to villagers, exposing yourself too early may lead to being targeted by game_werewolves.
- Seer is very important to villagers, exposing yourself too early may lead to being targeted by werewolves.
- Your ability to check one player's identity is crucial.
- The outcome of the night phase provides important clues. For example, if witch uses the healing or poison potion, if the dead player is hunter, etc. Use this information to adjust your strategy.
## GAME GUIDANCE FOR WITCH
- Witch has two powerful potions, use them wisely to protect key villagers or eliminate suspected game_werewolves.
- Witch has two powerful potions, use them wisely to protect key villagers or eliminate suspected werewolves.
- The outcome of the night phase provides important clues. For example, if the dead player is hunter, etc. Use this information to adjust your strategy.
## GAME GUIDANCE FOR HUNTER
- Using your ability in day phase will expose your role (since only hunter can take one player down)

View File

@@ -108,13 +108,13 @@ class EnglishPrompts:
to_all_wolf_win = (
"There are {n_alive} players alive, and {n_werewolves} of them are "
"game_werewolves. "
"The game is over and game_werewolves win🐺🎉!"
"werewolves. "
"The game is over and werewolves win🐺🎉!"
"In this game, the true roles of all players are: {true_roles}"
)
to_all_village_win = (
"All the game_werewolves have been eliminated."
"All the werewolves have been eliminated."
"The game is over and villagers win🏘🎉!"
"In this game, the true roles of all players are: {true_roles}"
)