WarPath: Intelligence Design

The first version of WarPath, our simultaneous-turn based iPad game, will have local multiplayer and in a future version we are likely to add online multiplayer.  Players don’t always have people with them to play, or want to practice alone, so we need to add computer players.  This article is all about the AI (Artificial Intelligence) in WarPath and the tactics we have designed.

Simulating intelligence – or at least appearing to – is hard. There are many many techniques out there to try and replicate human levels of intelligence.  In computer games, the situation is quite interesting.  The computer is capable of taking a vast quantity of data and processing it to make the best and most logical solutions. However, where AI struggles is getting the psychological element correct.  Take poker for example, the AI could quite easily calculate the odds of winning the hand, where the challenge would be in poker AI would be trying to bluff, or trying to guess if the opponents are bluffing.

AI in WarPath shares this problem as in theory it has to guess what the other players are thinking and what they plan to do. Luckily for us, we don’t need to do this, we can cheat.

All of the movements of the AI tanks are planned via the AI grid. This is simply the playing area conceptually split up into squares roughly the size of the tank.  It makes everything simpler to calculate, as we can decide if a grid space is occupied with a tank or obstacle, or if any of the boundary of the grids are walls that you cannot pass through.

The AI chooses from a set of behaviours based on the data from the game and the grid.  The behaviors help the AI choose turret direction, mine placement and movement based on the simplified contents of the grid. The set of behaviours are designed to emulate real playing styles and tactics so that the AI plays a realistic and satisfying game.

To decide on the behaviors, I simply played the game and watched other people playing, then asked them why they were making certain decisions.  From observation and questioning, I learn how people play and why they make the decisions they do.  The challenge is to turn all this into a set of rules and behaviors that the AI can follow.

Chasing / Pursuit

The most obvious form of behaviour is to to choose an enemy tank and try and attack it.  The harder part of this is to decide which enemy tank to choose. There are two strategies: choosing by proximity and choosing by the strength of the opponent.

Proximity

It makes sense to go for enemies that are closer as you are more likely to catch them in a turn.  Since the AI will know the path the players have, they can use this to guide them where to go. Although this is information other human players do not have, this technique makes up for not being able to predict the human player’s movements. Without this, the AI becomes far too easy to avoid by simply moving to unoccupied areas on every turn.

Weakest or Strongest Opponent

Depending on the health, sometimes it is better to take out the stronger opponents as the weaker ones are likely to be taken out within a hit or two anyway.  It would probably be better to use the healthiest tank for the strongest opponent, hopefully not take too much damage then being able to take on the weaker enemies.  Exceptions to this are when the AI tank’s health isn’t too good, as going against the strongest will probably mean death.  Taking on a weaker opponent may at least reduce enemy numbers before death.

Movement Strategies

There are a number of other movement and attack strategies I have identified from human players that may be employed by the AI.

Hiding

When a tank is quite weak it is quite beneficial to try and hide from the enemies in the hope they will take each other out before they take you out.  Along with smart positioning of mines en-route this tactic can work quite well.

Random Movement

One thing that always keeps people on their toes is random movement. In this setting it is quite effective as the chance of encountering enemies when there are several is quite high.

Blocking

A smarter group behavior that I have implemented is an attempt to block tanks in.  So when they are in narrow passages or near a wall, a tank or two can work together and move to block the tank’s exit from the location, then work together in killing it.

AI on behalf of gameplay

There are occasions in the game that you might want the AI to act in a particular way for gameplay or user expectation reasons, contrary to the normal behaviours and rules above.  A few examples of these are below.

All out

This behaviour is mainly in place for when all the non-AI players are complete.  We can quickly watch the players finish the game if we desire. The tanks will abandon self-preservation tactics and go completely on the offensive to end the game as quickly and spectacularly as possible.

Campers

This addition was added after extensive play-testing. When there was only one human player if they hid and kept their distance from the other tanks, the AI seemed to generally favour fighting the other AI.  Then the human player would appear at the last minute and win, being the strongest opposition remaining. Although this is a valid tactic it doesn’t really make for fun gameplay.  I added a condition that if a tank or two are to be considered hiding, or moving very little then the AI will be more likely to pursue them.

In conclusion

So all the stuff above is how the first AI will be. Obviously over time we are likely to adjust and improve the AI experience, maybe trying more in-depth forms of AI, but for the sake of getting it out I thought I would keep it fairly simple.

Do you think there are tactics and behavior I have missed out? Feedback and comments welcome as always.

DiggSlashdotDeliciousStumbleUponTechnorati FavoritesTumblrShare
This entry was posted in Development and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>