The fear of a robot uprising is real. Terrible fictional creations like the Terminator and HAL are clear proof. But when Artificial Intelligence (AI) is taking a day off from becoming self-aware and attempting to destroy the world, it also plays an important role in contemporary video game design.
AI is not as mysterious as a lot of sci-fi makes it out to be. ‘AI’ is an umbrella term that refers to any device which perceives its environment and takes actions to maximise its chance of success at some goal. At the Institute of Digital Games (IDG, University of Malta), researchers are developing programmes that will build weapons and predict the outcome of battles. Not to help them on their path to world domination, but to find perfect game balance.
Game balance is at the core of ‘good’ game design. A football pitch is perfectly symmetrical with goals of equal size on each side. Increasing the size of one goal post, or narrowing one part of the field, would upset the game’s balance and make it a lot less fun to play. In video games, playing fields involve different weapons, special abilities, and even multiple floors. This increased complexity causes game balance tobecome a bit more tricky.
While game balance is often in the hands of human designers, at the IDG, we are trying to automate some of the process with AI’s help.
Level-designing humans rely on gut feeling, experience, and countless hours of play-testing to produce a balanced level, and could surely use a little help from their machine friends. One method of assistance would be to use neural networks—a specific form of machine learning that progressively improves performance of its task. It is these neural networks that Daniel Karavolos, a Ph.D. student at the IDG, is currently teaching to predict the outcomes of multiplayer first person shooter (FPS) games.
Why is it cool?
Game designers tweak the playing field for game balance, but it is more challenging in the FPS genre because having a perfectly symmetrical open field is not an option. A gunfight on an open field would be about as exciting as drawing straws. The predictive deep learning model that Karavolos is developing could help designers see how changes in the level impact the balance of the match in real time. This would save countless hours of playtesting, while also saving the company from the usual barrage complaints about unbalanced levels. Ultimately, using AI to predict game balance will reduce costs in game development and cut down sales losses. Tragically, however, it will also leave countless chronic complainers on the Internet with nothing to do.
How does it work?
Not all AI is created equal. Researchers like Karavolos have to find the most effective AI for their purpose.
|What are Neural Networks?|
An Artificial Neural Network is a computing system inspired by modes of biological information processing in the brain and nervous system. Instead of having task-specific programming, the system improves progressively thanks to a large bank of similar scenarios that it can reference. For example, an ANN could learn to identify images of cats by analysing a large quantity of images tagged as ‘cat’ or ‘not cat’.
Convolutional Neural Networks are artificial networks which often contain layers to detect various parts of a more complex object. In facial recognition, for example, it might detect pupils, then feed to the next layer that detects the eye, then the next for mouth, and so on, until finally the complex object of the face is recognised. As opposed to conventional neural networks, this architecture makes it explicit that the input is an image. This allows encoding of certain properties in the architecture, making the forward function from one layer to the next more efficient and drastically reducing the parameters in the network.
Generating enough data for a machine to detect a pattern accurately takes time, so choosing the right machine learning algorithm is key. Karavolos tested a large number of different networks, but the most effective networks were the convolutional neural network (CNN) and the fully connected artificial neural network (ANN).
These neural networks were ‘trained’ with over 50,000 3v3 deathmatches across a diverse set of levels created by 39 generators. The levels were spawned with 50 obstacles and weapons like a shotgun, a rifle, a submachine gun, a sniper rifle, and a rocket launcher. Each level varied object size and object placement.
These levels were input as 100×100 pixel images with three colours, allowing the network to distinguish between large objects blocking line of sight, small objects providing cover, and no objects. The neural networks then analysed the parameters of the levels and the weapons, before predicting the outcomes of the games.
Since playing a level 50,000 times is a tall order, even for the most hard-core gamer, AI agents were used to simulate the gameplay and train the neural network. Each agent had unlimited lives, but once 20 kills were achieved, the match ended. The balance was then calculated by the ratio of kills of each team. A match is balanced when the kills of each team are equal, or only have a marginal difference.
After the networks’ training montages were complete, it was time to pit them against each other.
Long versus short range
The ANNs predicted the matches that would result in a balanced kill ratio with 75% accuracy, while the CNNs predicted the advantage of a team with 74% accuracy. Both also had a very low probability of identifying the wrong team to win, meaning that once trained the neural networks are able to predict game balance with about 75% accuracy overall.
Procedurally generated content is created by an algorithm rather than game designers and graphic artists. No Man’s Sky’s procedurally generated worlds generated a lot of buzz, but also distinctly highlighted the gameplay challenges that come with algorithm-generated content—a lack of overarching story or structure that often resulted in aimless wandering and repetitive actions.
To overcome this problem, Ph.D. student Daniele Gravina is looking into procedurally generating balanced weapons with surprising characteristics. These will be used in Unreal Tournament III: an arena FPS focusing on head-to-head deathmatches.
Why is it cool?
Gravina’s algorithm will generate a pair of weapons with unusual and unexpected properties. This should encourage unconventional gameplay but still manage to keep a sense of balance. If the standard weapons favour one player, the duel will be frustrating and boring for their opponent as they struggle uselessly. Using this new algorithm, the weapons can vary greatly, surprising players and encouraging them to adapt their strategy to the specific strengths of the weapon while still maintaining the duel’s balance.
How does it work?
The weapons are generated through a genetic algorithm which uses
characteristics of the original weapons to develop new ones. Parent weapons have 11 parameters such as the rate of fire, spread, speed, damage, and number of bullets per shot. When paired, they make little weapon babies that are an evolutionary product of their parents.
When generating the new baby weapons, the algorithm will pick varied values based on the parent weapons’ parameters. When selecting the values, the probability distribution is skewed away from the middle values, to avoid the weapon babies merely becoming the average of their parents and devoid of any real novelty. Simultaneously, certain thresholds are also put in place to determine balance, effectiveness, and safety, to ensure playability. After all, you cannot bring a nuke to a gunfight.
Now, evolution would not be fun without a few mutations, which is where the ‘heatmaps of death’ come in. Feasible weapons were tested by AI Agents on the Biohazard level of Unreal Tournament III, and the kills were mapped. These heatmaps showed the most common areas where the AI Agents died. To add a dash of surprise to the balanced weapons, the AI searched the heatmap and tried to find ways to deviate from the generated heatmaps of death.
“The extreme diversity of the actions reinforces the illusion that the player is immersed in a different reality”
Given that weapons with certain characteristics have advantages on specific parts of the map—that perfect sniper spot, or that corridor where we can go to town with the grenade launcher—the AI will use that information to adjust the weapon and cause deaths in unexpected locations. Tweaking the weapon so that the kill heatmap is not the same makes the level more dynamic and exciting.
Daniele Gravina: Surprise first weapon Daniele Gravina: Third weapon
Yin and Yang
Without bodily balance, you will fall. Without level balance, a game will fail. Games are often based on a set series of actions within a framework. The extreme diversity of the actions reinforces the illusion that the player is immersed in a different reality. Having designers work extensively on each level and each weapon to ensure this balance limits the player’s options. Even when designers do take the time to do this, mistakes happen and unbalanced weapons find their way into games. Combining procedural content generation with AI balancing tools is the way of the future. It can lead to games where every level is different; where weapons and level structure force you to think up new strategies each time you play.
The time has come for the machines to rock the world of game design by helping it stay balanced. Maybe someday they will take over, but for now they are content making games more awesome, expansive, and cheaper to produce. Step by step, the gaming world is on the cusp of change. Are you game?
Article originally published in THINK Magazine. Re-posting with permission. Original here.