Development Update 12

Last month, a lot of effort has been put into artificial intelligence (AI). We have somewhat neglected this aspect in Grounds of Glory as you can play against other players. What we have found out, however, is that players like to test their builds against AI players first. Having a decent AI also allows us to shorten the queue times as we plan to add AI players instead of real players for lower levels and ratings where queue times are expected to be longer.

Here is an example of fights versus only AI, 1v1 versus mage and 2v2 as a healer with mage as ally, and fighter and healer as enemies,

Lets first start by saying this will be a very technical development update. The main requirement for our AI players were:

  • the AI system is fast and does not use a lot of CPU nor memory – this is a requirement as AI will be simulated on dedicated servers that are expensive to rent

  • AI players can be used as a replacement for real players, therefore must work as a team with any other player and not just mindlesly hit random targets

  • AI player will move and position itself like normal player – a healer seeks cover when it takes a lot of damage, the mage will keep range from opposing fighter and fighter will try to stick to the target

  • AI players will use most of the abilities so real players can learn from their combinations (and mistakes) – ability sequence will not be predetermined but decided on the fly based on situation (predicted damage taken, health, positioning, resources)

  • AI players must not get stuck as we intend to use it for ranking as well

  • AI players must have more difficulty levels

The first AI system was built using Unreal Engine’s built in Behaviour Trees for spell sequence calculation and Enviormental Query System for positioning. The system worked but could not satisfy all the requirements above. It had problems mostly with performance and movement calculation – this is the reason we chose to implement our own system in C++ with a lot more flexibility. The AI system is split into a few components.

Trackers

System uses per-player trackers that are shared between all AI agents. This represents additional information that is not needed by human players but proves very useful for AI agents. The tracking information is split on per-team and per-player basis. We track:

  • damage dealt

  • damage received

  • healing dealt

  • healing received

Using this data, trackers are able to predict, for example, how much damage a player will take in the next 10 seconds. To predict that, we calculate “smooth” damage average in the last few seconds, and extrapolate this data to next 10 seconds. We can also see which team deals more damage etc.

Scoring Volume

The most important and also most difficult aspect is providing good locations where to move. We split our “navigation mesh” to a discrete grid. In a preprocess, we calculate persistent properties of each grid point. These properties include whether this point is accessible, its visibility information to 16 directions and 3 distances and “exposure” of each point. A visualization of point exposure is shown in the below picture.

HighresScreenshot00084

As you can see, points that are not that accessible from other points are less exposed (blue).

Additionally, we also dynamically calculate team-specific potential for each point, like how much damage can team A deal to each grid point. This is calculated based on player’s position and class type and changes as the game is running. We typically calculate these properties on a certain interval. The following image shows that damage potential for a team is higher around players of that team.

HighresScreenshot00085

AI players then use this information to calculate where it should move; for example, a player might want to move to a location with low enemy damage potential, high ally team healing potential and point with line of sight to a certain player. We can express the end location as a series of weight, like -1 for enemy damage (we do not move somewhere where enemy deals damage), 0.5 for ally healing (we want to move to a location where ally healing is high but this tendency is not as high as avoiding damage) and filter out only grid locations that see a certain other point and are in range. We added a lot more options to filter best point as you can see from the point but they all follow the same pattern.

BestLocation

The preprocess calculation is free as we do it at level load and around destructable meshes upon their destruction. Dynamic properties are updates really fast as we do not need to perform any raytraces, just simple math arithetics in C++.

Spell ranking

All spells are already in a Data table. We did not want to re-enter all spell properties so we just linked an additional table with avaible spells to rank with some additional “AI-specific” properties.

Screenshot 2018-01-12 21.40.21

The spell ranking goes as this:

  • We calculate if spell is possible

  • We calculate its damage, healing, control and movement score

  • We calculate its overall score based on the ranking request (how important each individual spell score is)

  • We add “spell combo” factor (some spells have good combinations, like Conduit -> Projectile)

  • We sort spells by score

The system allows us to specify which spells the AI player will use in a certain mode and find out the best spell in that situation in a very generic way that is reusable by all classes.

SpellRank

All together

We provide implementation of AI agent for each class. Every class has different modes based on its health, resources and target’s properties. For example, healer will go to “Regenerate” mode when low on mana, or to “Aggressive DPS and healing” mode when his allies are on high health and mana is still high. Each mode has a different movement and spell ranking. After all this math, the difference between good and bad AI just depends on how many modes we had anticipated and how well we have calibrated them.

We are quite happy with current behaviours of AI players. They are actually pretty good so we might need to tone them done for beginners. There is a long path still ahead of us but we are fairly optimistic that we will provide interesting AI players for you to fight with and against!