日本語

← Back to the game

Home › Dev Diary

#2 Why Our Bots Can Only Turn 500 Degrees per Second

· HammyTurf dev team

In the first entry we mentioned that bots have a cap on how fast they can turn, and promised the details later. Here they are: why a cap was needed, why it is 500 degrees, and the two alternatives we decided against.

The problem: only the bots could spin around instantly

In HammyTurf, bots fill the seats that people leave empty. For a while after launch, fighting a bot at close range was nearly unwinnable. You would dive at its trail, and in that very instant it would flip straight back and escape, or cut across your trail instead.

The cause was simple. The server computes everyone's position 20 times a second, once every 50 milliseconds. A bot can rewrite its target on every one of those steps, so it can complete a 180-degree reversal in 50 milliseconds.

People cannot. Changing direction takes a physical motion: moving a mouse or sliding a finger. A slight correction is instant, but turning to face directly behind you means moving a fair distance, and that takes time. In other words, a human turn gets slower the larger the angle. The bots paid none of that cost.

What we did: cap the turn rate

We left the bot's brain (the part that decides where to go) alone and added one layer behind it. The layer takes the brain's destination as an intention, and lets the actual heading rotate only so far from where it was pointing on the previous step.

ItemValue
Turn rate cap500 degrees per second
Rotation allowed per step (50 ms)25 degrees
Time for a 180-degree reversalabout 0.36 seconds
Distance covered meanwhile (speed is 10 cells per second)about 4 cells

Small course corrections within 25 degrees still apply immediately, as before. People are quick at fine cursor adjustments too, so we matched that. A full reversal, on the other hand, now spans eight steps, and the bot travels about four cells along an arc while it turns. Those four cells are the opening a human can use.

The one exception is the moment a bot enters the board: it simply faces the way it first wants to go. People also point their cursor where they want to go before they start. And human input does not pass through this layer at all, so nothing about how the game feels to play has changed.

Rejected option 1: delay every reaction

Our first idea was to delay bot reactions by 0.3 seconds. People have a lag between seeing and moving, so it sounded natural.

But that produces a bot that starts late and then still reverses in an instant. The instant reversal, the very thing that made the bots move in a way no human could, would remain. It also charges the same 0.3 seconds for a big reversal and a tiny correction, which is the opposite of the human pattern where bigger turns are slower. We dropped it.

A narrower version, adding a short delay of 0.1 to 0.25 seconds only when a bot switches decisions in response to an opponent (attacking or retreating), is on hold. The agreement was to add it if the bots still moved in ways no human could after the turn cap. So far it has not been needed.

Rejected option 2: give everyone inertia

The other idea was to add inertia to everyone, humans and bots alike. The same rule for all looks fair.

Thinking it through, though, humans would carry inertia on top of the slowness of their own hands, while bots would keep their advantage in how fast they issue commands. The unfairness would stay and only the human controls would get heavier. Much of the fun of this game is that the hamster follows your finger or mouse right away, and we were not willing to give that up.

Why 500 degrees

The number did not come out of a formula. The idea was to make a turn to face backward take about as long as a person needs to flick a mouse or a finger. We picked a value on that basis and then checked it by fighting bots at close range, over and over. A lower number makes the bots sluggish, a higher one makes them sharp. At 500, the feel was that a bot sometimes gets away, but you can take it down when you read it correctly, so we settled there. It has been live since September 12.

Put as a tip for players: bots cannot turn on a dime. Go for the trail from the side or from behind at an angle and you are more likely to reach it before the bot finishes turning. Chase it head-on at a shallow angle and it will correct its course immediately.

What we learned

Looking back, the good decision was not to weaken the bots by making them less smart, but to give their bodies the same constraint a human has. Their judgment is unchanged: they still go for your trail, and they still head home when things look dangerous. Their movement simply became an arc. That alone made losing to one feel a lot more fair.

Because the mechanism lives in a single layer, the same constraint applies to both bot brains, which are separate for solo play and Team Battle. When we revisit how the bots play, we expect to leave this layer untouched.

Next time we plan to write about how we chose the network format: we measured the options and ended up with the plainest one. Feedback and requests are welcome through the contact page.

← All Dev Diary entries