Teaching the computer to play: how the Hard bot got better

A bar chart of the new Hard bot's win rate against the old Hard bot at 2 to 5 a side, all between 84 and 96 percent

The computer players in Bump Soccer come in three levels: Easy, Normal and Hard. You meet them in Practice, in rooms where the host adds them, and in Casual when a match is not full after a minute. You never meet them in Ranked.

Until November 15, Hard thought the same way Normal does, with a bigger search and one rough guess of the other team's kick. On November 15 I asked for it to be way better and more strategic, and set a bar: the new Hard has to win 85% of its matches against the Hard we had, without taking much more time to think. This is how that went, with the real numbers.

How a bot thinks in a game where everyone moves at once#

A bot cannot react to you. Nobody can: everyone aims in secret and launches together. So a bot does what you do. It imagines a bunch of possible shots, plays each one out in the game's own physics, and picks the one that leaves its team in the best spot.

"Best spot" is the hard part. Since November 12 the bots score each imagined outcome with soccer sense: how far the ball moved toward the other goal, goals for and against, own goals, whether someone is covering the goal, who will reach the ball first, keeping some space between teammates. They also share a plan as a team: one goes for the ball, one keeps the goal while the ball is in their half, the rest support.

How much each of those things matters is not something I typed in. The weights were learned by the bots playing against themselves, over and over, keeping whatever won more.

That first round already made Normal and Hard better than before. But Hard still had a blind spot.

The blind spot: everyone else standing still#

When the old Hard tried a shot in its head, it imagined the other team standing still. It only checked its best few ideas against one rough guess of a kick at its own goal.

But the other team is never standing still. Their nearest player is going for the ball too. So Hard kept finding beautiful shots that were ruined the moment the real defender arrived.

The fix: guess what they will do#

The new Hard first works out who on the other team will go for the ball, then predicts that player's kick by running a quick search from their spot, the way the Normal bot would think. Then every shot Hard tries is played out against that predicted kick. It meets the ball where it is going to be, blocks the shot that is coming, and aims past the defender who is coming to block.

That one idea, alone, took Hard from winning 50% against the old Hard to 93%, 85% and 76% at 2, 3 and 5 a side.

There was a price. Each imagined shot now has a moving ball and a moving opponent, so it costs more to think through. To stay fast, Hard now tries fewer kick strengths (four instead of six) and fewer targets (five instead of seven). Tested at the full size, the bigger search was not stronger anyway.

What did not work#

Most ideas did not. A few of the ones that failed:

  • Guessing several kicks for the other team (toward the middle of the goal and both posts) instead of one: 35 to 55%. Worse than one good guess.
  • Hand-tuned "danger" features without the prediction: 50 to 59%. The guess is what made the difference, not the scoring.
  • Predicting only for the best few shots, to save time: 44 to 64%. To find the shot that beats their kick, you have to know the kick for every shot.
  • Predicting your own teammates too: anywhere from 40 to 92% at 2 a side, depending on how, and worse at 3 and 5.

And one funny side effect. Against an opponent who never moves, the new Hard got slower to score: it kept expecting the defender to clear the ball, and the defender never did. Alone against a defender who just stands there, the old Hard scored in 2.2 turns; one version of the new Hard needed 5.3. So at 2 and 3 a side Hard now keeps a small hedge for "what if they do nothing", which brings that down to 3.7 turns.

The final numbers#

On November 16 the prediction got sharper (a search between Normal's and Hard's, which guesses the real kick more closely: the ball ends within 2 metres of where the predicted kick says in 70% of test positions, against 59% before). At 2 and 3 a side, Hard's supporting players also follow where their own team's kick will send the ball.

Then the test league, 300 matches per size, on random starts none of the tuning had seen. The new Hard's share of the decided matches:

A bar chart of the new Hard bot's win rate: 95.5% at 2 a side, 86.5% at 3, 84.8% at 4 and 84.0% at 5 against the old Hard
  • against the old Hard: 95.5% at 2 a side, 86.5% at 3, 84.8% at 4, 84.0% at 5;
  • against Normal: between 95.7% and 99.3% at every size;
  • against itself: exactly 50%, as it should be.

So 2 and 3 a side clear the 85% bar, and 4 and 5 a side sit right on it (84 to 89% across different sets of test matches, within the noise). It costs about 1.4 times the old Hard's thinking time at 5 a side: around 13 milliseconds a decision.

My favourite number: when the new Hard plays itself at 2 a side, 112 matches out of 300 run to the turn limit. Each side keeps covering the shot it knows the other is about to take.

What it means for you#

  • Practice vs Hard is now a real challenge, and a good warm-up before the Solo Cup.
  • Casual fills empty seats with Normal bots, so Quick play did not get harder.
  • Ranked has no bots at all, as before.

Want to test yourself? Start a practice match, pick Hard, and good luck.

Play Bump SoccerFree, in your browser. No download.

All posts · What's new