Skip to content
OPQAI.
Sourced advanced / 💻 Coding

Design AI Conversational Games for Engaging Experiences

Job to be done: Build multi-agent conversational games with LLMs

🇳🇬 Ways to use this in Nigeria

Ideas to get you started, adapt to your situation.

  • Student

    Build an AI-powered Werewolf game with AI players to practice social deduction skills for your next debate club meeting.

  • Entrepreneur

    Create an AI role-playing game for your app that simulates customer interactions to train your sales team.

  • 9-5 employee

    Develop an AI simulation of a team meeting to test different communication strategies before a real project kickoff.

What this is, in plain English

This entry explores how to build complex conversational games where multiple AI models (called LLMs, or Large Language Models) play different roles and interact with each other, and potentially with humans. Unlike simple chatbots, these games aim for a rich user experience and replayability, similar to games like Werewolf.

Building such a system is advanced because standard AI tools are designed for one-on-one chats. Creating a multi-agent game requires custom programming, often called “plumbing,” to manage each AI’s role, memory, and turn in the conversation. This involves careful design of the underlying architecture and the specific instructions (prompts) given to each AI.

The author focuses on the practical challenges of making AI models play well together, avoiding common issues like AI “hallucinations” (when an AI makes up information) or losing track of game rules. The goal is to create an experience that is not just functional, but genuinely fun and engaging for players.

What you can use it for

  • Create engaging story games: Design interactive narratives where AI characters play specific roles and drive the plot forward.
  • Simulate complex social interactions: Model how different AI personalities or roles interact in a group setting, like a debate or a town meeting.
  • Build educational simulations: Create scenarios where users learn by interacting with AI agents that embody historical figures or scientific concepts.
  • Develop AI-powered role-playing games: Allow users to join games like Werewolf or Mafia, with AI players filling out the cast.

Tools you need

  • LLM APIs (e.g., OpenAI API, Anthropic API) (paid): Services that let your code send requests to powerful AI models and receive responses.
  • Python (free): A popular programming language used to write the custom logic for the game.
  • GitHub (freemium): A platform for hosting and collaborating on code, where the author’s project is shared.

How it actually works

Building a multi-agent conversational game starts by understanding that most LLM APIs (Application Programming Interfaces) are designed for a simple back-and-forth between a user and an assistant. To make multiple AIs interact, you need to build custom “plumbing” using a programming language like Python.

This involves creating a system that manages each AI’s identity, its specific role in the game, its memory of past conversations, and how it takes turns speaking. You’ll define the game rules and then craft specific instructions (prompts) for each AI to ensure they follow these rules and contribute to an engaging experience. The author’s project, linked below, provides a full open-source example of this architecture.

To explore this concept, you would typically:

  1. Set up a development environment: Install Python and a code editor on your computer.
  2. Get the code: Download or clone the author’s open-source project from GitHub.

    macOS or Linux

    git clone https://github.com/hiper2d/werewolf-ai-party-game.git
    cd werewolf-ai-party-game

    Windows (PowerShell)

    git clone https://github.com/hiper2d/werewolf-ai-party-game.git
    Set-Location werewolf-ai-party-game
  3. Install dependencies: Install the necessary Python libraries listed in the project’s requirements file.
    pip install -r requirements.txt
  4. Configure API access: Obtain an API key from an LLM provider (like OpenAI or Anthropic) and set it up in the project’s configuration. The author’s project will have instructions on how to do this.
  5. Run the game: Execute the main Python script to start the game and observe how the AI agents interact.

From there, you can study the code to understand how the prompts are structured, how the game loop manages turns, and how the system handles different AI roles and game states. You can then modify the prompts or game logic to experiment with your own ideas.

Words you’ll see, explained

  • LLM (Large Language Model): An AI program that can understand and generate human-like text, used for tasks like writing, summarizing, and answering questions.
  • Hallucination: When an AI generates information that is incorrect or made-up, presenting it as if it were true.
  • Multi-agent system: A setup where multiple independent AI programs interact with each other and potentially with humans to achieve a common goal or play a game.
  • Prompt: The instruction or question given to an AI model to guide its response or behavior.
  • API (Application Programming Interface): A set of rules and tools that allows different software programs to communicate with each other, for example, letting your game code talk to an AI model.

Original source

This concept is based on an article by hiper2d on DEV Community, which details the technical architecture and implementation challenges of making AI models play complex conversational games like Werewolf. The author shares insights from two years of experimentation, focusing on user experience and replayability.

Notes & variations

  • Do you even need this?: If you just want to experience an AI-powered conversational game, the author provides a free live version at aiwerewolf.net that you can play directly without any setup or coding.
  • Free-tier limits: While Python and GitHub have free tiers, building your own multi-agent system typically requires using paid LLM APIs. Some LLM providers, like Google’s Gemini API, offer free tiers for limited usage, which can be a good starting point for experimentation.
  • Common pitfall: A major challenge is preventing AI models from “hallucinating” or losing focus on the game rules, which can quickly ruin the experience. Robust prompt engineering and careful game loop design are crucial.
  • Tip: To get better results, focus on creating very clear and specific rules for each AI agent, and design your “plumbing” to strictly enforce turn-taking and information flow. This helps guide the AI’s behavior and maintain game integrity.

Keep going

More Coding workflows