Assignment Chef icon Assignment Chef
All English tutorials

Programming lesson

Building a Multi-Agent Deduction Game with Epistemic Logic: A COSI 112a Final Project Guide

Learn how to approach a COSI 112a final project by building a multi-agent deduction game that uses epistemic logic for AI reasoning. This tutorial covers project planning, logic implementation, and evaluation strategies.

COSI 112a final project epistemic logic game multi-agent deduction Kripke model implementation public announcement logic dynamic epistemic logic tutorial AI opponent reasoning modal logic programming Python epistemic logic game AI with logic common knowledge in games possible worlds semantics LLM reasoning comparison interpretable AI gaming COSI 112a project ideas multi-agent systems project

Introduction: Why Epistemic Logic and Games?

As the May 2026 semester winds down, many COSI 112a students are facing the final project—a substantial opportunity to apply modal logic, epistemic logic, and other formal systems to a problem of your choice. One of the most engaging tracks is Track 2: Systems & Applications, which asks you to build an interactive system where logic does real computational work. A multiplayer deduction game where an AI opponent uses epistemic logic to reason about what other players know is a perfect fit. Think of games like Clue or Avalon, where players must infer hidden information. With the rise of AI in gaming—from LLM-powered NPCs to procedural content generation—this project is both academically rigorous and highly relevant.

Project Overview and Scope

Your goal: Build a game where human players and an AI opponent each hold private information (e.g., a secret role or card). The AI must use epistemic logic to model what each player knows, what they know about others' knowledge, and how public announcements change the state of knowledge. This is a classic application of Kripke semantics and dynamic epistemic logic (DEL). The project should include a working interface (command-line or web-based) and a 4–8 page written report.

Step 1: Define Your Game and Logic Requirements

Start simple. A two-player game where each player receives a secret color (red or blue). The AI knows its own color but not the human's. Players take turns making public statements like "I know my color" or "I don't know your color." The AI must update its knowledge based on these announcements. This is essentially the Muddy Children puzzle—a canonical example in epistemic logic.

Formalize the knowledge using possible worlds. Each world is an assignment of colors to players. The AI's knowledge is a set of worlds consistent with its observations. Public announcements eliminate worlds that contradict the statement. For example, if the AI says "I don't know my color," then worlds where the AI's color is uniquely determined are removed.

Step 2: Implement the Epistemic Logic Engine

Use Python (or your language of choice) to implement a Kripke structure. Represent worlds as dictionaries mapping player IDs to colors. Maintain a set of worlds that are epistemically possible for each agent. The key operations:

  • Initialization: Generate all possible worlds consistent with the game rules.
  • Knowledge update: After a public announcement, filter worlds that satisfy the announcement formula.
  • Query: Does agent A know proposition P? Check if P is true in all worlds agent A considers possible.

Here's a minimal Python snippet:

class KripkeModel:
    def __init__(self, agents, props):
        self.agents = agents
        self.worlds = []  # list of dicts
        self.relations = {a: [] for a in agents}  # adjacency list

    def add_world(self, world):
        self.worlds.append(world)

    def add_relation(self, agent, w1, w2):
        self.relations[agent].append((w1, w2))

    def knows(self, agent, proposition, world):
        for w2 in self.relations[agent][world]:
            if not proposition(self.worlds[w2]):
                return False
        return True

This is a simplified version; your actual implementation should handle dynamic updates via public announcement logic using the update function that removes worlds not satisfying the announcement.

Step 3: Design the AI Opponent's Strategy

The AI should not just randomly guess. Use epistemic logic to decide actions. For example, if the AI knows its own color but doesn't know the human's, it might say "I know my color" to reveal information. The AI can also reason about the human's knowledge: "If the human knows my color after my announcement, then I can deduce theirs." This mirrors higher-order knowledge ("I know that you know that I know...").

Incorporate common knowledge: after a public announcement, the fact becomes common knowledge. Your model should automatically update all agents' relations to reflect that.

Step 4: Build the User Interface

For a COSI 112a project, a command-line interface is acceptable, but a web-based UI using Flask or Streamlit makes the project more impressive. The interface should display the current game state, allow the human to make announcements or guesses, and show the AI's reasoning (e.g., "I think you have red because..."). This transparency demonstrates the logic at work.

Step 5: Test and Evaluate

Your evaluation should measure both technical quality and conceptual understanding. Test scenarios:

  • Does the AI correctly update knowledge after announcements?
  • Does it avoid contradictions (e.g., claiming knowledge it doesn't have)?
  • How does performance scale with number of players or colors?

You can also compare your AI against a baseline (random action) to show that epistemic reasoning improves win rate. This empirical evidence strengthens your report.

Connecting to Current Trends

In 2026, LLM-based agents in games are a hot topic. Games like Among Us and Diplomacy have inspired research into multi-agent reasoning. Your project contributes to this trend by implementing explicit logical reasoning rather than black-box neural networks. This is especially relevant as AI companies seek interpretable AI for safety-critical applications. You can mention this in your report's motivation.

Writing the Report

Your 4–8 page report should include:

  1. Introduction: Motivation, related work (e.g., DEL literature, game AI).
  2. Background: Brief review of epistemic logic, Kripke models, public announcements.
  3. Implementation: Describe your code architecture, key algorithms, and UI.
  4. Experiments: Show test results, maybe a table comparing AI vs. random.
  5. Discussion: Limitations (e.g., scalability, assumption of perfect rationality) and future work.
  6. Conclusion: Summary and lessons learned.

Cite at least 2–3 relevant papers, such as van Ditmarsch et al.'s Dynamic Epistemic Logic or Fagin et al.'s Reasoning About Knowledge.

Proposal Tips

Your one-page proposal (due November 14, 2025) should clearly state the track (Track 2), motivation, approach (Python + Flask + Kripke model), deliverables (code + report), and evaluation metrics (e.g., accuracy of AI's knowledge, win rate). Get instructor feedback early to scope properly.

Conclusion

Building a multi-agent deduction game with epistemic logic is a challenging but rewarding COSI 112a final project. It combines theory (modal logic) with practice (coding, UI) and connects to exciting trends in AI and gaming. Start early, test incrementally, and let the logic guide your design. Good luck!