Dev blog 24 March 2017

Current progress and some behind the scenes on bots

What we've been doing in the last couple of weeks:
  • Midfield bot attacking
  • Basic customisation and inventory system (item drops etc)
  • Showing your character much more during a match so you can see all the cool stuff you have
  • Integration of all bot types into the matchmaking system
What's coming up next:
  • Beta testing before next release
  • Next steps of customisations (chests/keys, exchanging items)
  • Local botmatch
  • Bot/player substitution

We have 27th March as our feature-freeze date for the next release. There is usually a week or so of testing and bugfixing before we have something suitable for release. There are some big changes in this update, so I expect that pattern to continue.

I've been thoroughly entrenched in bot-code for the last couple of months, and the midfield bots have by far been the hardest. 

The keeper and defenders are, for the most part, reactive. Meaning that they can fulfil their duties by simply reacting to the current state around them. The keeper checks to see if the ball is heading towards the goal and moves to the interception point. A defender moves to a defined defensive location based on the current position of the attacker.

A good midfielder needs to predict what will happen, evaluate the attacking potential of those around them and act accordingly. The midfield bots are the only ones which look both at what they are doing, but also what their teammates are likely to do.

For humans, predicting the future is relatively easy. For bots, it's hard and involves a lot of maths. For example, I'm pretty proud that I've managed to get the bots to do volley shots:

This involves:
  • Predicting the path of the ball using the laws of ballistic trajectory, so that the bot knows where the ball will be in the future.
  • Calculating whether or not the bot will be able to move to that location in the time available.
  • Decide that if the bot took a shot from the location, would the ball make it to the goal unimpeded and quickly?
  • Selecting a target and aim at it.
  • Move to the predicted location with an offset vector based on the angle to the goal.
  • Calculate if the ball is within the gun kick range/angle.
  • Determine if the volley opportunity has passed using the current velocity/location of the ball (so the bot doesn't hang around forever waiting for a volley that will never happen).
  • Actually kick the ball!
I also get the occasional reminder that despite the rocket-science stuff above, I get things wrong a lot of the time as well. Case in point: the first rules I defined for going back to defend after an attack failed translated roughly as "when the enemy team has the ball, move to the nearest unmarked enemy player and stand between them and our goal". Logical, right? I set up a test, and after the team lost the ball all the midfield bots immediately ran over to mark the enemy goalkeeper, who promptly KO'd them. Doh!