Skip to content

让AI-agent玩好狼人杀,主要关于subagent,上下文工程,提示词设计,以及提示词注入攻防

Notifications You must be signed in to change notification settings

2725244134/wolvesback

Repository files navigation

🐺⚔️👨‍🌾 Nine-Player Werewolves Game

This is a nine-players werewolves game example built using AgentScope, showcasing multi-agent interactions, role-based gameplay, and structured output handling. Specifically, this game is consisted of

  • three villagers 👨‍🌾,
  • three werewolves 🐺,
  • one seer 🔮,
  • one witch 🧙‍♀️ and
  • one hunter 🏹.

✨Changelog

  • 2025-10: We update the example to support more features:
    • Allow the dead players to leave messages.
    • Support Chinese now.
    • Support continuous gaming by loading and saving session states, so the same agents can play multiple games and continue learning and optimizing their strategies.

QuickStart

Run the following command to start the game, ensuring you have set up your DashScope API key as an environment variable.

python main.py

Note:

  • You can adjust the language, model and other parameters in main.py.
  • Different models may yield different game experiences.

Running the example with AgentScope Studio provides a more interactive experience.

  • Demo Video in Chinese (click to play):

Werewolf Game in Chinese

  • Demo Video in English (click to play):

Werewolf Game in English

Details

The game is built with the ReActAgent in AgentScope, utilizing its ability to generate structured outputs to control the game flow and interactions. We also use the MsgHub and pipelines in AgentScope to manage the complex interactions like discussion and voting. It's very interesting to see how agents play the werewolf game with different roles and objectives.

Advanced Usage

Change Language

The game is played in English by default. Just uncomment the following line in game.py to switch to Chinese.

# from prompt import ChinesePrompts as Prompts

Play with Agents

You can replace one of the agents with a UserAgent to play with AI agents.

Change Models

Just modify the model parameter in main.py to try different models. Note you need to change the formatter at the same time to match the model's output format.

Further Reading

About

让AI-agent玩好狼人杀,主要关于subagent,上下文工程,提示词设计,以及提示词注入攻防

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages