← All solutions

Reinforcement learning

Your first RL project

Train a small agent, put it in a competitive environment and observe the decisions it makes. Territory Playground gives this experiment a visible outcome: neural networks and programmed bots compete for cells on a live board.

What reinforcement learning does

In reinforcement learning (RL), an agent learns a policy: how to choose an action from an observation. It acts in an environment, receives a reward and uses that experience to update its policy. The objective is to increase expected cumulative reward over time. A move with a small immediate benefit can be useful if it leads to a better outcome later.

For a territory game, observations can describe the board and nearby opponents; actions determine the next move. The reward is a separate design choice. Survival, expansion and winning are possible objectives, but the exact reward must be defined by the training model. A larger training return does not automatically mean a stronger agent against new opponents.

The project: Territory Playground

The live project runs autonomous agents in the browser. Each has a body made of cells and chooses one move per tick. Its included neural networks are small: the project describes 16 hidden neurons and approximately 250 weights. The agent list includes an untrained network, networks from different training rounds, and programmed bots. This makes it possible to compare learned behaviour with explicit strategies.

The board shows territories, a ranking of the largest agents and wins during the current session. Pause the match to inspect a position, change playback speed or start a new match. Select which agents participate in the next match to compare specific checkpoints and opponents.

RuleWhat changes
SplitWhen an ageing bridge cell disappears, the smaller disconnected territory is lost. Narrow connections become a liability.
AttackAn agent can take a neighbouring enemy cell when it has stronger local support.
StrikesAgents accumulate charges and spend them on attacks that penetrate enemy territory.
LandCells visited by a moving body become owned land. There is no decay; opponents can take that land.

These are environment variants, not guarantees that a checkpoint has been trained for every rule. Keep the rules fixed when comparing agents. The game identifies the last surviving agent as the winner and territory ownership as a goal.

Run your first experiment

  1. Establish a baseline. Open the live version, choose a rule set and select an untrained network plus a small, fixed set of opponents. Watch several matches.
  2. Compare trained checkpoints. Keep opponents and rules unchanged. Add a trained network and inspect expansion, survival and wins across multiple matches. A single win is not sufficient evidence of improvement.
  3. Train a compatible model in Weei. Obtain a Territory-compatible WASM model and its experience package manifest. In Workspace, select the package, set the final training round and units per assignment, then create the job. Connect and invite participants before starting distributed training. See RL requirements for inputs, auxiliary weights and generated evaluation.
  4. Export and test. Download a checkpoint and load it through Territory’s Add a network tab. The project accepts a compatible Territory .weei-checkpoint or raw float32 weights in .weights or .f32 format. Arbitrary model checkpoints are not interchangeable.
  5. Evaluate again. Use the same rules and opponent selection. Compare behaviour and repeated-match results with the baseline, alongside the training model’s evaluation metrics.

Territory is the arena for running and comparing agents; Weei Workspace runs the training job. Opening the arena does not train a new network. The game also supports adding a JavaScript bot, which provides a useful baseline without training a policy.

Modifications to explore

Start with the controls already available: rules, opponent selection and checkpoint choice. For experiments that change how the agent learns, modify the model or environment and retrain:

  • Reward design. Compare rewards for survival, territory growth and final outcomes. Check whether the agent exploits a reward without improving the game objective.
  • Observations. Explore local versus wider board information, opponent proximity or the age of owned cells. Keep the observation format compatible with the policy.
  • Opponent diversity. Evaluate against different programmed bots and checkpoints. Earlier-policy opponents are an option for a model that declares checkpoint-based auxiliary weights.
  • Policy size and training settings. Change one factor at a time. A new architecture requires matching weights and an arena adapter that understands it; more rounds alone do not guarantee a better policy.

Record the checkpoint round, rule set and opponents for each comparison. Choose a small experiment with an observable success criterion before increasing model size or distributing more work.

Project controls and file formats were checked against the current live version. Reward and architecture changes above are experiment ideas, not controls claimed to exist in the arena.

Territory Playground ↗ · Current live version ↗ · Weei RL API documentation ↗

Open training workspace · Open Playground