What would chess look like with the guardrails off? I wanted to find out, so I designed Anarch Chess and built a rules engine and AI for it.
- Playable demo (my RUN.world october game jam entry): https://w.run/retroblade892/anarch-chess
- Source code and self-hostable build (the original implementation): https://github.com/Azizham66/anarchy-chess
My laptop is at repair which restricts me from writing code myself, so I decided to leverage AI coding agents. I used AI tools for a lot of the implementation, so most of my own work went into the rules, the spec and the testing. That is what this post is about.
The rules in 60 seconds
- A piece can move like another piece type if you still have a living ally of that type. A Rook can move like a Bishop only while you still have a Bishop.
- Pieces can only emulate pieces of equal or lower value, so a Rook can never move like a Queen.
- Sliding pieces can jump over one of their own pieces, destroying it. Enemy pieces can never be jumped.
- Pawns can step diagonally onto empty squares, or trample a friendly piece straight ahead.
- There is no checkmate. You win the moment you capture the King.
- Only standard moves can attack or capture the King. Emulated moves, jumps and tramples never can.
That sounds simple. It produced four rules bugs I did not see coming.
Note: for more details on the rules, read Anarch chess rulebook
Bug 1: "check is optional" contradicts "no self-check"
My first draft said you do not have to answer a check, and also that you can never make a move that leaves your King in check. Those two sentences cannot both hold.
The fix was to define legality around worsening your danger, not around the current state:
// Simplified sketch of the rule, not the repo's exact code
function isLegal(state, move) {
const next = apply(state, move);
// 1. Never worsen your own King's danger
if (newAttackers(state, next, me).length > 0) return false;
// 2. Non-standard moves may never create a new check
if (move.kind !== "standard" && newAttackers(state, next, enemy).length > 0) return false;
return true;
}
Ignoring a check is legal, but your opponent just captures the King on their turn, so in practice you lose. The rules stay consistent and nobody needs a special checkmate case.
Bug 2: two definitions of "attack"
If emulated moves could give check, an engine needs two notions of attack: one for moves, one for check. I removed that by defining check using standard attacks only. Emulation never defines check, and an emulated move can never deliver one.
Bug 3: the same move reachable several ways
A Queen emulating a pawn step forward is just a normal Queen move. Castling and a King emulating a Rook that slides two squares land on the same square. The engine needs a tie-break, so moves are deduplicated by (from, to) with a priority: standard first, then emulation, then jump, then trample.
Bug 4: the King with nowhere to go
In normal chess, a King in check with no escape is checkmate. In a game won by capturing the King, declaring that a draw by stalemate felt wrong. The rule I chose: if your King is in check and you have no legal move, you must still move a King one step, even into attack. The opponent captures it. If you are not in check and have no moves, it is a plain stalemate draw.
Teaching the AI to win
My first AI only counted material. In endgames it kept promoting pawns into queens and never finished the game, because by its own scoring it was already winning.
The evaluation needs terms that match the win condition: pressure on the squares around the enemy King, how few escape squares the King has, and pieces moving closer to it. Once you are far ahead, extra material should barely matter, or the engine just collects queens forever. Standard chess evaluations are wrong for a game where the King is just another piece you can take.
The AI runs as an alpha-beta search in a web worker, so the UI stays responsive, and the rules, search and analysis all run in the browser with no server needed to play.
Testing a variant with no reference engine
There is no Stockfish for a brand-new variant, so the tests have to come from the rulebook itself. I wrote a set of small reference positions where the expected result follows directly from the rules: a jump that is legal except where it would give check, a Rook that loses its Knight emulation the moment the last Knight is trampled, and a Rook whose Bishop-style slide stops one square short of the King. The game exports also annotate emulated moves, jumps and pawn steps, so you can replay a full game against the rules engine and check every move.
What is next
I want to generate self-play games, label the positions, and train a small neural evaluation to plug into the search. The lesson from this project is that when you change the rules, you have to rebuild your idea of what good play looks like.
Try the demo and tell me what breaks. If you like it, vote through the link in the game.













