Beaten by bots – training AI for first-person shooter games

When you first stare down that tough opponent in a videogame (think Big Daddies in Bioshock or Striders in Half-Life 2), it can seem impossible to beat the computer-controlled character you’re facing. But come the end of the game and you’re often ploughing through computerised enemies with ease – the…

Qhmk7thv-1355700739
Tough enemies tend to become easier by the end of a game, normally because you learn and they don’t. Robots image from www.shutterstock.com

When you first stare down that tough opponent in a videogame (think Big Daddies in Bioshock or Striders in Half-Life 2), it can seem impossible to beat the computer-controlled character you’re facing.

But come the end of the game and you’re often ploughing through computerised enemies with ease – the bots are no longer the insurmountable challenge they were when you first saw them.

What’s happened is you’ve gone through a process of learning and training as the game progressed, and your character might have gotten stronger too.

Meanwhile, computer-controlled enemies (or “bots) will often stay at a particular skill level throughout the game – even if it’s the game’s hardest difficulty – and they normally stick to a series of rules. That is, they don’t learn.

But what if they could?

FPS and bots

Research in artificial intelligence in videogames (AI) is becoming increasingly popular as we realise the advantages of using games as simulation test-beds.

First-person shooter (FPS) games are among the most popular type of game in today’s market and are known for their combative nature and fast-paced action. Players of these games will take on computer-controlled enemies across different maps, using different weapons, and collecting different items as they go.

The bots are non-playable characters with the ability to move around an environment, avoid obstacles, aim, shoot, change weapons, pick up items, sprint and crouch.

Creating bots with human-like behaviour is one way we can use videogames to research AI techniques. We can then transfer these insights to the fields of physical robotics and real-life simulations in things such as military training simulations.

Researching the creation of interesting behaviours, such as combat strategies, may also help the videogames industry develop more realistic and entertaining characters to play against.

So, what are we doing here?

In researching game AI, my PhD supervisor, Dr Marcus Gallagher and I decided to use a machine-learning algorithm to get bots to learn how to play an FPS. Machine-learning is a branch of AI that enables a machine to learn through experience.

We used reinforcement learning (RL), which allows a bot to learn a problem by interacting with its environment. The environment provides a reward or penalty based on how the bot is performing. These values are used to build a map telling the bot which action is good to perform in the current state of the environment. In our game, the bot receives a reward if it collects an item or kills an enemy. If the bot dies, it gets a penalty.

Our training tool

Screenshot of the interactive training tool software. Michelle McPartland

Our training tool lets the bots roam in a space and interact with each other. As the bots play out a game, users can reward or penalise the bot’s actions to modify their learning and enforce positive behaviours, such as picking up ammo or shooting other bots on sight.

The user can direct the bot by choosing any of seven guide actions. These actions are ranged attack, melee attack, wander, collect health, collect ammo, dodge and hide.

The experiment

We knew that the training system could create bots with different personality types such as a haphazard, beginner style bot and an aggressive, sharpshooter style bot. But we wanted to test the tool on commercial game designers to check its viability for industry use.

Five different designers used the tool to train a bot. We then threw the trained bots into a custom-built free-for-all FPS game to play against each other.

Visual representations of the behaviour mappings from the five user-trained bots. Red values are highly positive actions, black values are highly negative actions. Michelle McPartland

Training results showed that two of our five users (User 3 and User 5) trained bots with unique behaviours. The other three users (User 1, User 2 and User 4) trained similar types of bots:

  • User 1 created a bot that was good at collecting health items.
  • User 2 made a bot whose strength was in collecting ammo items.
  • User 3 created a bot notable for health-collection and combat.
  • User 4 made a bot that was okay at item collection and combat.
  • User 5 created the bot best at combat.

    Video of User 3’s bot versus User 5’s bot.

    Our research shows that interactive training is a viable option for creating FPS bots. Different types of bots were created using the same underlying code and, excitingly, the people training the bots could see their behaviour changing in real-time while they played the game.

    Interactive training can be used by designers during the development of the game to create different types of enemies. The underlying algorithm can also be used during the game to learn different strategies against the player.

    So, what lies ahead?

    We want to implement the tool in a commercial game or engine along with some new features of the tool based on the user testing feedback.

    We will add the ability to pre-define behaviours of a bot prior to training, for example, making the bot collect health when its health is low.

    Multiple controllers that run in parallel will be added. One controller will act as the high level decision maker – “who should I attack?” The other controller will control the movement – “where should I go?” This will allow more complex combat strategies to emerge.

    We believe the training tool has the potential to aid game designers in creating challenging and stimulating FPS bots – bots that can learn on the job and give gamers a real run for their money.

  • Sign in to Favourite

    Want to follow The Conversation?

    Sign up to our free newsletter to get the day's top stories in your inbox each morning, with a special wrap on Saturday.

    Spinner
    Help evidence based journalism become the norm and donate

    Join the conversation

    22 Comments sorted by

    1. Kim Peart

      Researcher & Writer

      Being active in the virtual worlds, I have become aware of the use of robots that can learn through communication.

      We have been preparing to include a bot in our virtual space program, able to answer questions and learn through communication, which may also be able to have a presence on our website.

      Rather than instruments of combat, I wonder of the learning bots can be applied to the more fundamental challenge of human survival in the cosmic setting.

      Naturally, we humans must first decide…

      Read more
    2. Sean Manning

      Physicist

      Nice work indeed. I am however shocked that this has not already been done. Would you be able to elaborate on why you think this is?

      report
      1. Michelle McPartland

        PhD Candidate, School of Information Technology and Electrical Engineering at University of Queensland

        In reply to Sean Manning

        Hi Sean, I can't say definitively why interactive training hasn't been used before, but from what I have observed I suspect there are at least a few issues at play:

        1) The games industry is still unsure of machine learning techniques, mainly due to their (usually) non-deterministic nature.

        2) While the amount of academic research in computer games has increased over the last five to ten years, it is still early days for translating these AI techniques into the often very complex virtual worlds…

        Read more
      2. Stephen Pritchard

        Researcher, cognitive science

        In reply to Sean Manning

        Learning bots would consume more processing power, which is at a premium when designing games to run on ageing home computers. Far less processing power needed to create much simpler bots that just obey a series of rules.

        For first-person shooter games in particular, the advent of multiplayer online gaming has greatly diminished the need for skilled bots. If you want a challenge against a competent enemy, you play multiplayer, not bots. If you are more interested in single player, then you are probably there for the story and experience, and increasingly hard bots are not really necessary (or even get in the way of you proceeding through the story), beyond having a few levels of difficulty which are achieved by giving the bots more powerful weapons and more health.

        report
    3. Stephen Pritchard

      Researcher, cognitive science

      To be good opponents for humans in an FPS,, bots need to play like humans. Human play can be contrasted with bot play along two broad factors:
      1. When an enemy is present, it takes a finite amount of time for a human to perceive, aim at, and fire, due to human sensing and perception, thinking and motor control. Humans also miss due to these human skills being imperfect/ time constrained. In contrast, bots can detect, aim at, and headshot in an instant, even at long range. Their "senses" are simplistic…

      Read more
      1. Anthony Nolan

        Ruminant

        In reply to Stephen Pritchard

        "How do you model the learning of perception ... etc"

        Have sex. Have babies. Raise children. Be a human.

        Make love, not war.

        report
      2. Michelle McPartland

        PhD Candidate, School of Information Technology and Electrical Engineering at University of Queensland

        In reply to Stephen Pritchard

        Hi Stephen

        There is a lot of research in AI in games on exploiting map terrain and enemy behaviour, but it is not the only research. We have a good understanding of the reaction times of human perception so modelling this is relatively easy (delays in reaction to sounds and vision, accuracy modelling etc.). Human decision making is less understood and although there are many models for it, there is no simple formula that just works. Our work is investigating using teachers to aid the bots learn…

        Read more
      3. Stephen Pritchard

        Researcher, cognitive science

        In reply to Michelle McPartland

        Hi Michelle, thanks for the reply.

        Perception isn't simply a reaction time issue. Consider the problem of a bot perceiving another player standing in front of them. Maybe you would implement a reaction time and action time delay of (making numbers up) 0.4 seconds before the bot could notice, aim at and fire at the player.

        But how does that reaction time for perceiving and reacting to another player change with these conditions:
        1. All other encounterable players are enemies
        2. Some players…

        Read more
    4. Ian Flynn

      High School Teacher

      @Michelle I just wanted to say how awesome I think you are for using Daleks as your bot model :D

      report
    5. Anthony Nolan

      Ruminant

      Fantastic! I love that you totally and uncritically accept the militarisation of leisure time and are obviously hoping for a military development contract. I can soooo see how this sort of intellectual work is going to benefit humanity. Humanless wars? Yep. Low intelligence policing? Ooops, we already got that. But hey, heaps of peaceful, beneficial applications, I'm sure.

      report
      1. Stephen Pritchard

        Researcher, cognitive science

        In reply to Anthony Nolan

        "militarisation of leisure time"

        hyperbole. Its a game involving tactics, strategy and reflexes. People enjoy such games.

        Does "militarisation of leisure time" also apply to chess?

        You can put different themes or "skins" on chess. Chess can be played with traditional pieces, or realistic medieval pieces or The SimpsonsTM chess, or little soldier and tank figurines or on a computer with animated pieces that attack each other, whatever theme you want. Same with FPS.

        You could make an FPS with teddy bears running around throwing love hearts at each other, or giving hugs when up close.

        You could make an FPS with kids throwing water balloons.

        The popularity of violent "skins" in media including games is much broader than this research, and researching strategy/tactics/AI while obviously relevant to the military, is not exclusive to the military, and shouldn't be avoided just because it might be relevant to the military.

        report
      2. Dale Bloom

        Analyst

        In reply to Anthony Nolan

        Personally, I find video games boring beyond all belief, and I am fed up with real wars.

        Perhaps there could be a video game on how to disarm your enemy.

        Or, a video game on how to convince your enemy to disarm.

        report
      3. Stephen Pritchard

        Researcher, cognitive science

        In reply to Anthony Nolan

        Hi Dale,

        I learned the basic rules of chess when I was about 7. Shortly afterwards, I decided chess was boring, and avoided it for over 20 years. Then, when I was about 30, a flatmate bought chessmaster software, that included many hours of tutorials. We started playing chess against each other, and doing the tutorials to learn better strategy and tactics. At that point, I realised that when I had known the basic rules, and had played a bit, and had concluded chess was boring, I didn't actually know how to play. There is so much more to chess than its superficial rules.

        The same applies to "video games".

        For starters, the types of video game out there, the themes, play styles, depth, multiplayer vs single player vs cooperative play etc are so diverse, that to say something like "video games are boring beyond belief" makes about as much sense as saying "reading is boring beyond belief" because you read and were bored by a copy of New Idea.

        report
      4. Kim Peart

        Researcher & Writer

        In reply to Anthony Nolan

        Should war break out between China and the US, we may be thankful for frontline troops wearing exoskeletons ~ and the exoskeletons would in fact be robots.

        The skills of the human and the machine would then merge and network across a grid, supported by packs of robodogs and drone-bot swarms for each exodigger.

        We may then be thankful that gaming skills were developed that enabled young soldiers to defend our nation.

        The training of exodiggers may happen in the virtual worlds, as amazingly…

        Read more
      5. James Wookey

        Paramedic

        In reply to Anthony Nolan

        Anthony,

        I'm not entirely sure what your point is or why you've chosen what is an interesting article on the Bots in FPS games to try and make it. There are both military and non-military FPS games, nobody is forcing the "militarisation of leisure time".

        I've seen a few of your comments on similar matters and they often remind me of a piece by Dave Grossman called "On Sheep, Wolves and Sheepdogs".

        report
      6. Kim Peart

        Researcher & Writer

        In reply to Anthony Nolan

        Dale Bloom ~

        In my document ~ 'Creating A Solar Civilization' ~ found on my website ~ I explore how the way to achieve peace on Earth and send war into history, is through expansion beyond Earth.

        I found that there were feedback loops that come into play, once we begin expanding into the celestial realm.

        To achieve this future and therefore peace on Earth, will require considerable effort and challenge our imagination to the hilt.

        We will need to inspire a critical number of people on…

        Read more
      7. Kim Peart

        Researcher & Writer

        In reply to Anthony Nolan

        James Wookey ~

        An excellent article, that 'On Sheep, Wolves and Sheepdogs' by Dave Grossman. ~ The Conversation is quite an education.

        Reference to "honour" for Australia must be in the context of the great power we follow, as a vassal state.

        Our "moment of truth" arrived in 1962 and we lost it.

        There was a simple honour in preparing the Papuans of western New Guinea for independence and we had been working with the Dutch since 1957 to achieve this, with many of our people on the ground…

        Read more
    6. Comment removed by moderator.

      1. Luke Bennett

        logged in via Twitter

        In reply to Michelle McPartland

        Like Kate, I am a RPG kinda guy. These are specifically tabletop RPGs (akin to DnD, Call of Cthulhu etc) but I do play MMOs when I need a distraction from real life.

        I've recently started mucking around with a set of game engine software, specifically because I am getting bored with the robotic nature of most NPC AIs.

        For instance, in Fallout3, I got bored with the kamikaze nature of some of the AIs, when it came to combat. One after another they would just charge in. No sneaking about, no tactical withdrawal, no leaving a PC alone as they were too tough to crack.

        The potential for AIs to start stupid, and slowly learn from interaction with players is, to be honest, beguiling. Work like yours is potentially of great interest to me.

        AIs that act intelligently, are not predictable, and can adapt their in-game interaction with both the game world and the players.... now *that* would make for interesting gameplay.

        report