Home▸AI & Machine Learning▸Territory Capture 2D: Voronoi Partitioning & Lloyd's Algorithm

Territory Capture 2D: Voronoi Partitioning & Lloyd's Algorithm

2D top-down territory-capture lab: mobile agents partition the plane into a live Voronoi diagram, and a Lloyd's-algorithm centroid-pull slider shows decentralized multi-agent coverage control converge or stay chaotic in real time.

AI & Machine Learning2DModerate60 FPS📱 Mobile-adapted⇄ 3D version
2d-territory-capture ↗ Open standalone

The 3D original renders "Territory Capture" as a generic decorative training-lab scene with fabricated reinforcement-learning telemetry and no real territorial mechanic behind it. This 2D companion builds the mechanic the title actually promises: every point on the field is "captured" by whichever of a handful of mobile agents is nearest to it — a live Voronoi diagram recomputed from real agent positions every frame — and a Lloyd's-algorithm centroid-pull slider drives each agent toward the center of mass of the territory it currently owns, the same decentralized coverage-control law used in multi-robot area-division research. Push the gain up and watch the partition relax into a stable, balanced tessellation; add wander noise and watch territory boundaries keep flipping indefinitely instead.

⚙ Under the hood

2D top-down territory-capture lab: mobile agents partition the plane into a live Voronoi diagram, and a Lloyd's-algorithm centroid-pull slider shows decentralized multi-agent coverage control converge or stay chaotic in real time.

voronoi diagramlloyd's algorithmcoverage controlmulti-agent systemsnearest neighborcentroidal tessellation

2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)