Live, in your browser

Sword Fighters

A small neural network that taught itself to duel, starting from random weights, by fighting millions of rounds against copies of itself. Every fight below is being played right now, on your device, by the trained network. Starting positions are random, so no two rounds are the same.

Champion 0 – 0 Baiter 0 draws 20.0 s left

Line: the champion's own prediction of how this round ends, from +1 (it wins) to −1 (it loses), re-estimated at every decision. Dashed outline: where the champion sees its opponent. Like a human, it sees 0.2 s into the past.

Inside the champion's network

The real activations, recomputed at each of its 15 decisions per second.

How it learned

Nobody told it how to fight. The only feedback it ever got was +1 for a win, −1 for a loss and 0 for a draw. Everything else, including keeping its distance, dodging, timing and punishing, it found by trial and error.

1 · The yardsticks

It beat the simple bots in minutes. The baiter took longer.

A quarter of its training matches were against three hand-written bots. The rusher and the random bot fell fast. The baiter dodges and punishes every whiffed swing. For six minutes the network won a quarter of its rounds against it at best. Then, about seven minutes in, it cracked it.

Show as a table
2 · Generations

Every generation against every other

A snapshot of the network was saved throughout training. Here, each one fought each other one in 600 fresh rounds. A row is the fighter and a column is its opponent. Blue means the row wins more than it loses, red the opposite.

3 · What it actually learned

Where it swings, and which way it steps

This is the network itself, queried live. Put the champion in the middle of the arena, facing right. Place the opponent at each point around it, facing the champion, and ask the network what it would do. The shading is how likely it is to start a swing. The arrows are where it would step.

untrainedchampion
0%50%100%

White outline: what its swing can actually reach. Arrows: the step it would take with the opponent standing there. Pointing away from the centre means closing in, pointing back toward it means backing off.