← johnnygoodlad.dev

Othello RL

This is my reinforcement learning project for Othello. August and Nash are two agents trained by self-play.

Play

Can you beat them?

Loading…

About

How they learned

Both August and Nash learned how to play Othello without any human guidance. They started knowing only which moves were legal and improved solely through self-play. They played 1,000,000 games of Othello, slowly developing and improving their own strategies as they played. Each game was played against a copy of themselves. Each of them independently formed their own estimate of how good each move is given the current board state. They will always pick the highest-rated move according to those estimates.

There were two differences between how August and Nash were trained. The first was how they treated their opponent during training. This turned out to be the most significant difference between the two. The other difference was which versions of themselves they would play against during training. This didn't have nearly as much of an impact on their learning as I had expected it to.

August
While she was training, she viewed her opponent as part of the environment. So after each move she made, she waited to see what move her opponent would make before evaluating the outcome of her own move. This way, she learned how her opponents were likely to respond to her moves (I refer to this as the opponent-as-environment target). When she trained, her opponent was sampled from past versions of herself half the time, and the other half was her current self.
Nash
While he was training, he viewed his opponent as another player trying to win. So after each move he made, he assumed his opponent would find the best move according to his estimation, then evaluated his moves based on how good his opponent's best reply could be, and he picked moves that kept it as weak as possible. In other words, he tried to give his opponent the worst possible position at each turn (this is the negamax target). When he trained, his opponent was always his current self.

Nash's negamax target was clearly stronger. Across four training runs of each, the negamax runs took 73% of the points against August's opponent-as-environment runs, playing from the starting position, even though both scored about 90% against a fixed positional heuristic. The August and Nash that you play against are each the strongest of their target's four runs.

With “Show the moves they would pick” on, the board numbers your legal moves by how the agent you're playing rates them from your side: The circled 1 is the move they would play in your place. Moves they rate almost equally share a number because the agent's preference between them often flips from one checkpoint to the next.

Each agent comes in two versions, which you can pick under “Version”. The Original is the agent exactly as it finished training for my class project, and it will never change. You can also play it at earlier stages of its training to see how it improved. The Learning version started as a copy of the Original and keeps training overnight on my laptop, partly on games saved from this page. A new night's version only replaces it if it scores at least 55% against the current Learning version over 400 games. If nothing has passed yet, Learning plays the same as the Original. I left a note under the picker saying when it was last updated.

The purpose of this class project was to explore a part of reinforcement learning that we wanted to learn more about. For me, this was understanding how different self-play strategies affect the strength of the resulting agents. I chose to explore this through Othello, a board game that my family loves to play. Through this project, however, I've learned a lot about target design in reinforcement learning that I didn't expect.

I'm a Nerd

How it works

The game as a learning problem

State
The board from the side to move: its discs, the opponent's, and its legal squares.
Actions
The 64 squares, plus pass when no square is legal.
Reward
+1 for a win, 0 for a draw, −1 for a loss, given only when the game ends.

Training

Two line charts, one per target, of score against the positional heuristic over one million training games. Every condition climbs from about 0.2 to about 0.9 within the first 200,000 games, then levels off.
Score against the positional heuristic over training on the 8×8 board: the mean of two runs per condition, with a band from the lower run to the higher. A is August's target, N is Nash's; naive and pool are who they trained against.

The two targets

Heatmaps of every 8×8 run against every other, with block averages and per-run dots. Rows of runs with the negamax target are blue against the opponent-as-environment runs: 0.62 to 0.65 from the opening bank and 0.68 to 0.81 from the starting position.
Every 8×8 run against every other; blue means the row's run scores more. Top: final checkpoints from 100 opening positions, playing both colors. Bottom: each run's last 5 checkpoints from the standard start. On average, runs with Nash's target (N) score 64% against runs with August's (A) from the openings, and 73% from the start.

Who they trained against

Four heatmaps, one per condition, of each checkpoint against every other checkpoint of the same run. Later checkpoints are blue against earlier ones, and cells near the diagonal are pale.
Each checkpoint against every other checkpoint of its own run (8×8, two runs per condition); blue means the row's checkpoint scores more. Later checkpoints beat earlier ones in every condition, by less and less as training goes on.

Measuring strength

Two line charts over one million training games. Solid lines, score against positional, climb to about 0.9. Dashed lines, score against the previous checkpoint, settle near 0.5.
Self-play can't show progress on its own: against its previous checkpoint (dashed) an agent scores about 50% for most of training, while its score against the fixed positional heuristic (solid) climbs to about 90%.
Two line charts of optimal-move accuracy on 4×4 over 30,000 training games. Both targets rise from chance, 49%, to about 0.75 for the opponent-as-environment target and 0.78 for negamax.
On a 4×4 board every position can be solved, so every move can be checked: the share of moves that are optimal over training (chance is 49.4%). Nash's target (N) ends higher than August's (A).
Two line charts of endgame accuracy on 6×6 over 400,000 training games. Both targets rise quickly from chance, 49%, to above 0.8, negamax slightly higher.
On 6×6, a solver checks moves near the end of the game: the share that are optimal over training (chance is 48.6%). Nash's target (N) is slightly but consistently more accurate.

Why the board shows ranks, not percentages

The agents' move ratings are not win chances, and the two agents show why. August's estimates run high: in the first third of its games against itself, it rates its own chances at about 84% as Black and 85% as White, and both sides can't be that likely to win. Nash's add up: 49% as Black and 50% as White, close to the 47% Black actually scores. Even estimates that add up assume both sides keep playing the way the agent does, so the board shows only the order.

Learning from your games

More info coming soon! Play against the agents to contribute to their learning.

Play with your own program

Have an Othello engine, or a script that picks moves? It can play August and Nash through an API: it starts a game, sends its moves, and the agent replies with its newest Learning version, the same one you can play here. Each key can play up to 102 games a day against each agent: two from the usual starting position, one from each side, and 100 from a different set of openings every day. Every finished game helps train the Learning versions, so a strong program makes a great teacher. Keys are free: email me and tell me a little about what you'll play with.