Sunday, December 6, 2015

Game AI Research Project

Tech Demo

What is Tactical Analyses?


Tactical analyses is the artificial intelligence technique that is used to make the computer enemy based on the terrain or the location of the enemies. There are two popular types of tactical analyses, influence maps and terrain analysis. The two techniques are somewhat different, but after a while it becomes difficult to tell them apart. According to Millington and Funge, influence mapping is used for squad-based shooters and real time strategy games. While terrain analysis is used by military simulations, this technique is almost identical but is only used for one type of Tactical Anaylses. Contrarily, Pottinger says that terrain analysis is used in real time strategy games, but he used influence mapping as a common terrain analysis tool. So which way is correct? They are basically two sides of the same coin.


Tactical Analyses on Game Genres


Most real time strategy games and shooters use tactical analyses. These games rely so heavily on this technique because the maps can record past history and show the current influence of both the players and the enemies. In games where the AI has to be intelligent, these algorithms are perfect for them. Instead of doing multiple different techniques to achieve a smart AI, the programmers can just make a map to store all information.

Even thought those two genres are the most well known, other games can implement this artificial intelligence technique, such as any game that wants to keep track of past events and predict future events. I can see this technique working with open world sandbox games as well. A mix between terrain analyses and influence mapping could be very helpful. The enemies can fight the player by seeing where the player has his influences, his grenades, traps, turrets, but only attack him when the player started the fights. Then, when the player is out of combat, the enemies can just use terrain map to wander to areas of interest. These areas can be the player's hideout, a lake, or any place the designers said has influence.

Platform Suitability


Tactical Analyses can be used on most platforms. The algorithm can be tweaked to be more complex or simple, and it would still be doing a solid job. The algorithm isn't updated every frame. It is usually updated once a second because each type can store past data, such as enemy attack, defeats, locations. Data such as this can be used to make future AI decisions by doing nothing more than looking at the map.


How to Make an Influence Map


Creating an influence map isn't that difficult, since there is only a couple steps. The first step that one has to do is figure out how he or she wants to represent the map. In my example, I used a simple 2D array because it is easy to implement when I know the size of the map and the size of the tiles. This however, is not the only way. One can use way points or course 2D grids to accomplish the task. Whichever technique one used, he or she has to make sure that the influence and connectivity can be stored.

After creating the 2D array, the next step is to add influence to the map. It can be as simple as adding a tile to the map, or as complex as adding an entire army.


This code was the most basic way to add influence. I use circle to show the user what cell and the influence for the player or enemy. I then changed the 2D array to calculate for this new influence.
The last and most important step is to propagate the influence through the map. The  function shown in the picture is a basic way to spread the influence throughout the map. This function goes though the whole map and finds the neighbors of each cell, and then it calculates the influence number in each cell. An important thing to note is that a buffer should be used so that the calculations don't become corrupted. If you just push the influences calculations into the map, the influence could be incorrect because you are using modified numbers instead of only using new numbers.


Reflection on References


The three resources I referenced really helped me to understand this technique in detail. I highly recommend that a person should check them out, if that person is more curious about tactical analyses. The first reference I used was the textbook for my Game AI class, “Artificial Intelligence for Games”. This brought together the two different types of tactical analyses.  It also shows pseudo-code which is very easy to translate into any coding language someone is fluent in. The second source is an article from AIGameDev, where the author discusses the mechanics of influence mapping. He includes pictures, pseudo-code, and a video to help explain it. The last link is a clean/safe .doc file about the use of terrain analysis in real time strategy games. The article was written by Dave C. Pottinger, who has worked on the Age of Empire series.

Resources:

Artificial Intelligence for Games, 2nd Edition, Millington and Funge, Morgan Kaufman, 2009 (textbook)
The Mechanics of Influence Mapping - AiGameDev
Terrain Analysis in Realtime Strategy Games - Pottinger (