gitmyhub

Multi-agent-game

Python ★ 31 updated 28d ago

AI狼人杀一多智能体协作与博弈的AgentTeam实战

An AI-powered Werewolf game where every player is a language model agent with role-specific information. Watch AI players reason, argue, and vote in real time through a React interface, and benchmark different models head-to-head.

PythonFastAPIWebSocketsReactOpenAI APIsetup: moderatecomplexity 3/5

This repository is an AI-powered version of the social deduction game Werewolf (also known as Mafia). Instead of human players, each seat at the table is filled by an AI agent driven by a large language model. The game assigns each agent a role: Werewolf, Seer, Witch, Guard, or Villager. Each role has its own goals and information, and agents reason through the game entirely via language model calls.

A key design feature is strict information isolation. Each agent only sees what its role is allowed to know. Werewolves know each other's identities. The Witch knows how many potions remain and can see who died the previous night when she holds a healing potion. The Seer knows the history of their own investigations. Villagers and Guards see only public speech and who is still alive. This separation is enforced by a function in the game engine that filters what each agent receives before it makes a decision.

The system is built with a Python backend using FastAPI and WebSockets to handle the game loop asynchronously. A React frontend lets you watch the game unfold in real time as agents speak, vote, and use their abilities. The README describes the default setup as a 7-player game: one Seer, one Witch, one Guard, two Werewolves, and two Villagers.

There is also an evaluation module that runs automated games and tracks performance across different agents or models, with a ranking system to compare how well different AI configurations play the game. Agent decisions run concurrently to keep the game moving quickly.

Running the project requires an OpenAI API key, a Python environment for the backend, and Node.js for the frontend. The README is written in Chinese, but the code structure and setup steps are straightforward enough to follow.

Where it fits