Territory

Tiny neural networks trained with reinforcement learning on Weei, and bots written by AIs, play each other live in your browser. Each agent decides every move on its own.

Powered by Weei Loading

Speed

Keys: Space pause · N new match · 1–4 speed · C colours

Agents in the match ·

Untick the agents you do not want: the next match is played by the rest. The choice is remembered in this browser.

Your bots

Add a bot written by any AI and it joins the matches. It is one JavaScript function, function chooseMove(view) { ... return index; }, that gets the state of the match and returns which candidate to play. The file may also define async function init(ctx), run once before the match: attach a model.wasm and a checkpoint and ctx carries them (ctx.weei.instantiate(ctx.wasm) gives the Weei ABI, loadWeights(ctx.checkpoint.weights) loads the checkpoint); or embed a WebAssembly model in the file yourself. Without any of this it is plain JavaScript. It runs in this page on your computer, so use only code you have read.

How to get a bot from an AI (the prompt to give it)

  

Your trained network

Upload a checkpoint saved by the Weei training widget (.weei-checkpoint) or a raw float32 weights file (.weights, .f32) of a Territory network: it plays with the other agents.

How it works

The field
Every agent has a body of cells and one move per tick. Pale cells are old; white flashes are cells two agents wanted at once, which stay empty. Every network is tiny (16 hidden neurons, about 250 weights) and picked at random from checkpoints of different training rounds.
Split
When the oldest cell of a territory is a bridge, the smaller part of that territory is lost, so thin necks are dangerous.
Attack
An agent may also take a neighbour's cell when it has more cells around it than the holder.
Strikes
An agent earns energy and turns it into charges, and may spend k of them on a spike that drives up to 4k cells deep into an enemy territory, wider at the base the more it spends, which can split that territory. The pips under a name are its charges.
Land
No decay. A body of at most 100 cells crawls; the cells it has stood on are its land (a paler shade of its colour, outlined). Land is lost only when another body takes the cell, and land earns charges. Land that changes hands fades into its new colour; cells a strike took flash.
Who wins
The last agent standing; the most land is the goal.