← Back to Blog

Dev Blog · June 13, 2026

Robot Arena: Chasing Bots and Collision Headaches

Robot Arena

Robot Arena is structurally similar to Zombie Survival — survive in a confined space while enemies chase you — but the "robot" framing led me down very different implementation paths. It also exposed the weakest part of my game code: collision detection. I thought I understood how to handle AABB collisions until I had six rectangular bots all trying to occupy the same space at the same time, and everything broke spectacularly.

When the Bots All Ended Up in the Same Spot

The first version of the bot AI was naive: each bot moved directly toward the player by normalizing the vector between its position and the player's position, then adding a speed component each frame. This worked fine with one or two bots. With four or more, they converged into a single superbot — a tight cluster that moved as one entity and killed the player the instant it made contact. The problem was that bots ignored each other entirely. I added basic bot-to-bot separation: if two bots were within a certain radius of each other, they'd apply a repulsive force away from the mutual center. This caused bots to spread out organically and approach the player from genuinely different angles. It was a relatively small code change but it transformed the feel of a multi-bot encounter from "wall of death" to something that felt like you were being surrounded, which is exactly the right feeling for an arena game.

The Collision Detection Rewrite

My original collision system checked every entity against every other entity every frame — O(n²) with zero optimization. At four bots plus the player, that was twenty-five checks per frame, which was fine. When I added a wave mechanic that introduced up to ten bots at once, the check count jumped and the frame rate visibly stuttered on weaker hardware. The right fix was spatial partitioning — dividing the arena into a grid and only checking collisions between entities that shared a grid cell. I implemented a simple uniform grid with cells sized to the largest entity. It cut the average collision checks per frame from over a hundred to around fifteen, and the stutter disappeared. I should have built it that way from the start, but I genuinely didn't anticipate the entity count growing as much as it did. Now I always start with spatial partitioning even for small counts.

Making the Bots Feel Like Robots, Not Zombies

I wanted Robot Arena to feel mechanically distinct from Zombie Survival even though the core threat — enemies chasing the player — was the same. The main difference I landed on was movement style. Zombies move fluidly, continuously updating direction. Robots recalculate their heading every 400 milliseconds, then commit to that direction until the next recalculation. This creates a slightly jerky, mechanical gait that reads as robotic rather than organic. It also creates gameplay opportunities: a sharp direction change by the player between recalculations leaves the bot momentarily heading the wrong way, giving a skilled player a brief window to escape. That 400ms commitment window became the skill ceiling of the game — can you predict when a bot will recalculate and use that moment to slip past it? It's a small thing but it gives Robot Arena its own identity.

Browse All Games