gitwtfhub

wtf is mafia-a2a?

sujal-maheshwari2004/mafia-a2a — explained in plain English

Analysis updated 2026-05-18

0PythonAudience · developerComplexity · 3/5Setup · moderate

TL;DR

A Mafia (Werewolf) game simulator where AI agents talk, vote, and eliminate each other using a custom agent-to-agent protocol, with a live WebSocket streaming server.

Mindmap

mindmap
  root((Mafia A2A Simulator))
    What it does
      Mafia game engine
      Agent to agent protocol
      Live WebSocket streaming
    Tech stack
      Python
      FastAPI
      LangChain
      OpenAI API
    Use cases
      AI vs AI matches
      Human vs bots
      Stream live games
    Audience
      Developers
      AI agent builders

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Why would anyone build with this?

REASON 1

Run a Mafia game between AI agents to compare heuristic bots against LLM-backed ones.

REASON 2

Play a text-based game of Mafia yourself against bot opponents on the command line.

REASON 3

Stream a live AI vs AI Mafia match to a frontend over WebSocket.

What's in the stack?

PythonFastAPILangChainOpenAI APIWebSocket

How it stacks up

sujal-maheshwari2004/mafia-a2a0xallam/my-recipe0xhassaan/nn-from-scratch
Stars00
LanguagePythonPythonPython
Last pushed2022-11-22
MaintenanceDormant
Setup difficultymoderatemoderatemoderate
Complexity3/52/54/5
Audiencedevelopergeneraldeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you spin it up?

Difficulty · moderate Time to first run · 30min

LLM-backed agents require an OPENAI_API_KEY, heuristic agents need no external service.

Wtf does this do

This project is a simulator for the party game Mafia, also known as Werewolf, built so that AI agents or a mix of AI and rule based bots can play against each other, or a human can join in. The core game logic is written separately from any input or output code, so the same rules can power a text based command line game, an automated match between bots, or a live streaming server, without duplication. The game follows the classic five role version of Mafia: Mafia, Doctor, Detective, and Villager, alternating between a night phase where the Mafia secretly choose a target, the Doctor tries to protect someone, and the Detective investigates, and a day phase where everyone discusses and votes to eliminate a suspect. What makes this project distinct is its custom agent to agent communication protocol. Instead of agents simply picking targets and votes, they can talk to each other the way people do around a table, choosing to broadcast to the whole group, huddle privately with a few players, or whisper to just one person. Other players can still notice that a private conversation happened, even if they cannot see its contents, which mirrors the social suspicion of a real game. Two kinds of agents are included out of the box. One is a simple rule based bot that needs no external service and tracks suspicion using keyword matching. The other is powered by a large language model through LangChain and OpenAI, and requires an OpenAI API key. Both kinds of agents can be mixed in the same game to compare how they behave. The project also includes a small web server built with FastAPI that streams a live game over a WebSocket connection, so a frontend interface could show matches between AI agents in real time. This is an experimental, code heavy project best suited to developers curious about multi agent AI systems or game simulation, and it currently has no stars.

Yoink these prompts

Prompt 1
Explain how the A2A broadcast, multicast, and unicast message types work in this Mafia simulator.
Prompt 2
Help me write a new Agent subclass for this Mafia simulator that plays with a different strategy.
Prompt 3
Show me how to connect a frontend to the WebSocket server in this repo to display a live Mafia game.
Prompt 4
Walk me through running spectate.py with mixed LLM and heuristic agents.

Frequently asked questions

wtf is mafia-a2a?

A Mafia (Werewolf) game simulator where AI agents talk, vote, and eliminate each other using a custom agent-to-agent protocol, with a live WebSocket streaming server.

What language is mafia-a2a written in?

Mainly Python. The stack also includes Python, FastAPI, LangChain.

How hard is mafia-a2a to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is mafia-a2a for?

Mainly developer.

View the repo → Decode another repo

This repo across BitVibe Labs

Don't trust strangers blindly. Verify against the repo.