Inspiration
Chess engines are basically unbeatable now, and the reason is simple: chess is predictable. Every piece always moves the same way, so computers can calculate everything.
So we asked a dumb question: what if we took away the one thing that makes chess chess? What if no piece knew how it was going to move until its turn started? And then an even dumber one: what if the AI playing against you didn't know the rules either?
What it does
Schrödinger's Chess starts like a normal chess game, but with three changes:
- At the start of every turn, each piece randomly gets a movement type: pawn, knight, bishop, rook, queen or king. Your queen might move like a pawn. Your pawn might jump like a knight.
- There is no king to checkmate. Each player has one secret piece, and you win by capturing your opponent's secret piece. You don't know which one it is.
- You click a piece to see how it can move this turn.
You play against an AI that starts with zero knowledge of the rules. It doesn't know how pieces move or what the goal is. It learns by playing against you, and it gets better during the match.
How we built it
We're a team of four, so we split the project into parts: one person on the board UI, one on the game engine, and two on the AI.
The frontend is built with HTML, CSS and JavaScript. The board is rendered in the browser, and clicking a piece highlights where it can move this turn along with a label like "moves like a knight".
The game engine assigns movement types at the start of each turn and generates legal moves for each piece based on its current type. Sliding pieces get blocked like in normal chess, knights jump. The engine is the only part that actually knows the rules.
The AI is the main part, and it learns in two layers:
- Learning the rules. The AI proposes moves, and the engine accepts or rejects them. From this feedback it builds a model of which move patterns are possible for a piece with a given movement type. At the start it tries a lot of illegal moves. Over the game it learns which shapes of movement actually work.
- Learning strategy. For each legal move it considers, the AI runs quick Monte Carlo simulations of possible next turns, with random movement types, and estimates how good the result is. After every turn it updates its move evaluations based on what happened, so captures, losses and dangerous positions shape how it plays next.
The reason this is hard: every turn, each of the 16 pieces can get one of 6 movement types, so the number of possible configurations per turn is
$$6^{16} \approx 2.8 \times 10^{12}$$
That's too many to search, so the AI has to sample and estimate instead of calculating everything like a normal chess engine. Instead of the classic minimax, it works with expected values, because there is no single "best answer" from the opponent when the dice decide half the game.
Challenges we ran into
- Normal chess logic doesn't work here. Checkmate means "the king can't escape next turn", but when moves are random, you can't know what next turn looks like. We had to replace checkmate with capturing the secret piece.
- Making the AI learn fast enough to actually show progress during one game, not after thousands of games. Early versions spent most of their time trying illegal moves, so we had to make it reuse what it learned about one piece for other pieces with the same movement type.
- Pawn-type moves broke for black at first, because "forward" means the opposite direction for the other side. A piece that randomly became a pawn would happily walk backwards.
- Balancing the Monte Carlo simulations: more simulations made the AI smarter but made it think too long, so we had to find a number that keeps it playable in real time.
Accomplishments that we're proud of
We made an AI that starts out playing completely random moves and visibly improves during the game. You can watch it go from trying illegal moves to actually going after your pieces. We're also proud that the game is genuinely fun to play, even though it makes no sense.
What we learned
- Games with randomness need a different way of thinking: you can't plan for the best case, you have to plan for the average case.
- Online learning is very different from training a model in advance. When the AI has to learn during one match, every bit of feedback matters and you have to squeeze as much as possible out of it.
- Splitting work between four people in a few hours only works if you agree on how the engine and the AI talk to each other early on.
What's next for Schrödinger's Chess
- Online multiplayer with provably fair randomness, so nobody can cheat on the dice.
- An AI that tries to guess which of your pieces is the secret one based on how you protect them.
- Probably nothing, because this game should not exist.
Log in or sign up for Devpost to join the conversation.