Demo · reinforcement learning
Teach a computer tic-tac-toe
A neural network learns by playing against itself. Nobody tells it the rules. It only gets +1 for three in a row.
Learning
Speed
0games against itself
–takes a win it has
–blocks your threat
–ties a perfect player
takes an open win
blocks a single threat
ties a perfect player
a perfect player scores 100% on all three
Random moves while exploring 100%
The board
Press Start learning to watch it practice, or play the blank network now.
Before each of its moves it shows its predicted reward for every square
You 0 · Network 0 · Ties 0
The model
- In goes the board as 9 numbers, +1 mine, −1 theirs, 0 empty
- Out comes a score for each square, and it plays the highest one
- Two hidden layers of 128 with SiLU, 18,953 weights in all
- It plays both sides, and after each move it nudges its weights toward a better guess
- At first most moves are random so it can explore, and that drops to 10% over 5,000 games
- Everything runs in your browser. Close the tab and it forgets
See the layers, the PyTorch code and how the signal flows through it