AI Game Design: How to Write Rules AI Can Follow
AI Game Masters can run almost anything — but they need well-structured rules to do it well. Whether you're adapting a classic party game or inventing something entirely new, this guide walks you through writing game rules that an AI can understand, enforce, and bring to life.

Why AI Game Design is Different
Human game masters improvise. They fill gaps in the rules, interpret ambiguous situations, and adjust on the fly when something doesn't work. AI can do much of this too — but it performs dramatically better when the rules are explicit from the start.
Think of it this way: a human host reads between the lines. An AI reads the lines. If your rules say "players vote to eliminate someone," a human knows that means one vote per player, majority wins, ties require a revote. An AI needs you to spell that out.
The upside is that AI handles creativity brilliantly. Give it clear structure — phases, roles, win conditions — and it'll generate compelling narration, manage complex state, and produce believable AI characters that bring the game to life. Your job is to build the skeleton. The AI adds the flesh.
Core Building Blocks
Every AI-compatible game needs four foundational elements. Get these right and the AI Game Master can handle the rest.
Roles
Define every role in the game: its name, its team alignment (if applicable), what information it starts with, and what abilities it has. Be specific. Instead of "the Spy can investigate," write "the Spy chooses one player each night and learns their team alignment (Loyal or Rebel)."
Phases
Break the game into discrete phases with clear transitions. A typical structure might be: Setup → Night → Day Discussion → Day Vote → Resolution → repeat or end. For each phase, define what happens, who can act, and what triggers the transition to the next phase.
Win Conditions
State exactly how each team or player wins. Avoid vague conditions like "the good guys win when they figure it out." Instead: "The Loyalists win when all Rebels have been eliminated. The Rebels win when they equal or outnumber the Loyalists."
Information Asymmetry
Define what each role knows and doesn't know. This is the engine of most interesting games. Who knows the identities of their teammates? Who has access to investigation results? What is public versus private? The AI enforces these boundaries strictly, so you need to define them precisely.
Writing Clear Rules
The difference between a game that runs smoothly and one that confuses the AI often comes down to how the rules are written. Here are the principles that matter most.
Be Explicit About Phase Transitions
Don't assume the AI knows when one phase ends and another begins. State the trigger clearly: "Day Discussion lasts 3 minutes or until a player calls for a vote. When a vote is called, transition to Day Vote immediately."
Define What Players Can Do
For each phase, list the actions available to players. During Night, can they send messages? To whom? During Day, can they whisper privately or only speak publicly? Can they abstain from voting? Spell it out.
Tell the AI What to Narrate
AI Game Masters excel at narration, but they need direction. Specify the tone and what information to reveal: "At the start of each Day, the Game Master announces who was eliminated during Night and reveals their role. Use a dramatic tone." Read more about how the AI engine works to understand what it can handle.
Common Mistakes
After reviewing hundreds of custom game designs, certain patterns emerge. Here are the mistakes that trip up most first-time designers.
Ambiguous Win Conditions
"The Detective wins by solving the mystery" sounds clear but isn't. What counts as solving? Naming the killer? Naming the killer and the motive? Getting a majority vote on the correct suspect? Define the exact mechanism.
Too Many Special Cases
Every exception you add is a potential point of failure. If your game has a role that "on the third night, if exactly two players have been eliminated, gains the ability to..." — simplify. Great games have simple rules with emergent complexity, not complex rules with predictable outcomes.
Not Playtesting
The fastest way to find problems is to play the game. Run a session with AI filling every seat and watch what happens. Does the AI get confused at any point? Does the game end too quickly or drag on? Iterate based on what you observe, not what you imagine.
Forgetting Edge Cases
What happens if there's a tied vote? What if a player disconnects? What if a role's target is already eliminated? The AI needs instructions for these situations. If you don't provide them, it'll improvise — and improvisation is only as good as the context you've given it.
Example: Designing a Simple Spy Game
Let's walk through creating a custom game from scratch — a simple spy game for 5–8 players.
Step 1: Define the Concept
A space station crew suspects infiltrators. Most players are Crew; one or two are Saboteurs. The Crew wins by identifying and ejecting all Saboteurs. The Saboteurs win by surviving until only two Crew remain.
Step 2: Define Roles
- •Crew (majority) — knows only their own role. Goal: eject all Saboteurs.
- •Saboteur (1–2) — knows all Saboteur identities. Goal: survive until Crew ≤ 2.
- •Engineer (1) — Crew-aligned. Each night, can scan one player to learn their role.
Step 3: Define Phases
Night: Saboteurs privately choose one player to "sabotage" (eliminate). The Engineer chooses one player to scan. The Game Master reveals results privately.
Day Discussion: The Game Master announces who was sabotaged and reveals their role. All players discuss for 3 minutes. Public chat only.
Day Vote: Each player votes to eject one player or abstains. Majority ejects; ties result in no ejection. Ejected player's role is revealed.
Step 4: Test and Iterate
Start a session on TextGame.ai with AI players and observe. In our testing, we found that the Engineer is too powerful with nightly scans, so we changed it to every other night. Small adjustments like this make the difference between a broken game and a great one.
Advanced Techniques
Once you've mastered the basics, these techniques can take your custom games to the next level.
Branching Narratives
Instead of a fixed phase loop, define conditional branches: "If a Saboteur is ejected, the next Night phase includes a Saboteur recruitment attempt." This creates dynamic game arcs that feel different every time.
Dynamic Role Reveal
Not all roles need to be assigned at the start. You can define trigger conditions for new roles to emerge mid-game: "When the first Crew member is eliminated, one surviving Crew member becomes the Captain and gains a double vote."
AI Personality per Game
You can specify the tone and personality of the AI Game Master itself. A horror game might call for ominous, terse narration. A comedy game might want exaggerated, playful commentary. Include a style directive in your rules: "The Game Master narrates in the style of a noir detective novel."
For more on how AI characters develop personality, see our deep dive on how AI characters think. And if you're curious about the broader trajectory of AI in gaming, read our take on the future of AI gaming.
Frequently Asked Questions
Do I need coding skills to create a custom AI game?
No. You write game rules in plain language — roles, phases, win conditions — and the AI Game Master interprets and runs them. No programming required. If you can explain a board game to a friend, you can design an AI game.
How many roles should my game have?
Start simple. Two or three roles are enough for a compelling game. You can always add complexity later. The best designs have few roles with deep interactions, not many roles with shallow ones.
Can I share my custom game with others?
Yes. On TextGame.ai, custom games can be published to the game library where other players can discover and play them. The best community-created games get featured on the homepage.
What if my game rules have a bug?
The AI will do its best to interpret ambiguous rules, but results may be unpredictable. The fix is simple: playtest with AI players, identify where the game breaks down, update your rules, and test again. Most designers get to a solid version within two or three iterations.
Create Your Own AI Game
Ready to bring your game idea to life? Write your rules and let the AI Game Master handle the rest — no coding required.
Start Creating