Make a Board Game With AI: Rules First, Opponent Last
To make a digital board game with AI, write your rules as a numbered sheet and have your AI treat that sheet as the boss. Build two people sharing one screen first, and leave the computer opponent until the very end.
What does a table do that a program cannot?
Around a real table, people quietly fix the rules. Someone says "oh, you can't go there", someone else remembers whose turn it is, and when nobody can move, you all laugh and agree on something.
A program has none of that. Every one of those small human repairs has to become an exact decision.
Imagine your game is about rival canal builders on a seven-by-seven board. You take turns placing lock gates so water reaches your own town. Simple to explain, and it hides these questions:
- May a gate touch the board's edge?
- If water reaches both towns on one move, who won?
- What if a player has gates left and nowhere legal to put them?
If your rules do not say, your AI will pick an answer, and you may never learn which one it picked. The code here is short. The rules are what have to be complete.
What is the smallest real version?
The whole game, on a small board, for two people on one screen. Board games do not shrink the way other genres do, because one missing rule breaks the game. So keep every rule, and cut the extras: no computer player, no animations, no online play, no fancy pieces.
Which steps come in which order?
Start with rules.md, numbered, in plain sentences. Then the board and pieces, stored apart from how they look, so a rule can be checked with no picture on screen.
Next comes the most useful single feature in the genre: click a piece and see where it may go. It teaches your rules to new players, and it shows you at a glance when a rule was understood wrongly.
After that, add whose turn it is, winning and drawing, and what happens when a player has no allowed move. The turn-based combat blueprint has useful thinking about turn order, even with no fight in sight. Then add undo and saving.
The computer opponent comes last. Begin with one that picks any allowed move at random, because even that lets you play alone.
What kills a digital board game?
Building the opponent too early. A clever opponent is the biggest job in the project, and it leans on every rule. Change one rule and it starts making silly moves, so you spend your evenings repairing the opponent instead of improving the game.
The quieter killer is rule drift. Over a long chat, your AI rewords a rule slightly, and the game changes without anyone deciding it. That is why the sheet is the boss.
Paste this to your AI
I want to turn my own board game idea into a digital game for two people sharing one screen. Ask me for my rules, then write them as numbered plain sentences in rules.md. From then on rules.md is the boss, and you never reword a rule by yourself.
Next, draw a turn as a state machine in a Mermaid diagram: pick a piece, show allowed moves, move, apply effects, look for a win or draw, next player, no allowed move. Play one whole game through it on paper and show me the moves. List every situation rules.md does not decide.
Only then build it, with no computer opponent yet. When I pick a piece, highlight where it may go.
When you say a move is or is not allowed, quote the rule number. If no rule decides it, tell me you do not know, and wait for my answer.
Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP
How to check it worked
- Try every illegal move you can think of. Each one should be refused, and the rule behind it should be clear.
- Read rule 7 and try to break it. Then do the same for each rule on the sheet.
- Corner yourself. Play until a player has no allowed move. The game should know what to do.
- Play a full game with someone. Every argument you have is a missing rule.
- Undo a big move. The board should return exactly to how it was.