Every grid cell is "captured" by whichever agent is nearest to it (Euclidean distance) — that is a Voronoi diagram: the plane partitioned into regions of nearest-neighbor dominance. Each agent's territory is exactly its own Voronoi cell, computed fresh every frame from live agent positions.
The centroid pull slider implements Lloyd's algorithm: each agent moves toward the centroid (average position) of the grid cells it currently owns. This is the same decentralized coverage-control law used in multi-robot area coverage — with enough gain and no noise, the partition relaxes toward a centroidal Voronoi tessellation where every agent sits at the center of mass of its own territory and the system stops changing (drift → 0).
Wander noise adds a random perturbation to each agent's motion, working against convergence — raise it to see territory boundaries keep flipping indefinitely instead of settling, exactly like real coverage-control agents fighting sensor or actuation noise.
Equations. Coverage cost (quantization energy) H(p) = Σcells c |xc − powner(c)|² · Acell (shown per unit area, in map-height²). Lloyd step: pi ← pi + k (Ci − pi), with Ci = Σ xc / Ni. Each full step (k = 1) can only lower H, because the centroid minimises the sum of squared distances in a cell, and re-assigning cells to the nearest agent lowers it again.
Self-check. With the map in view, the sim verifies (a) Lloyd with k=1 and no noise never raises H, and (b) one agent's centroid equals the map centre (analytic). Result is shown in the "Self-check" box.
Honest simplifications. Territories are sampled on a grid (not exact polygons), so shares carry about 1/Ncells quantisation error; agents are points with no speed limit other than the gain; the domain is a flat rectangle with walls. It is a game-AI coverage toy, not a robot controller. Drag any agent with the mouse or finger to move it.
- Flip rate — grid cells that changed owner in the last second; near zero once the tessellation stabilizes.
- Balance σ — standard deviation of territory shares; low means agents hold roughly equal territory, high means one agent dominates.
- Centroid drift — average distance each agent still has left to travel to reach its own territory's centroid; the convergence signal for Lloyd's algorithm.