This project simulates the classic social deduction game "Werewolf" using LLM (Large Language Model) agents. Each player is controlled by an LLM (mocked by default), and the entire game process is recorded, including role assignment, speeches, voting, and deaths.
main.py- Entry point, sets up and runs the gamegame_engine.py- Game engine and flow controlplayer_agent.py- Player and LLM agent logicroles.py- Role definitionslogger.py- Structured game loggingllm_api.py- LLM API interface (自行修改base_url和api_key)requirements.txt- DependenciesREADME.md- Project documentation
- Make sure you have Python 3.7+ installed.
- (Optional) Install dependencies:
pip install -r requirements.txt
- Run the game:
python main.py
- After the game finishes, check
game_log.jsonfor the full game log.
- To use a real LLM API, implement
call_llm_apiinllm_api.pywith your provider (e.g., OpenAI, Qwen, etc.). - You can adjust the number of players and role distribution in
main.py. - Extend roles and actions in
roles.pyandgame_engine.pyfor more complex gameplay. - The log structure is JSON and can be used for visualization or analysis.
MIT