Introduction to Learning in Games

      English Doc 2005-3-4 21:55
By Geoff Howland

To create a fun and successful game you need to be able to challenge your players. They need to feel that they are overcoming something by beating your game. One way to achieve this is to have your game learn from their actions. Have it analyze what they are doing and try to come up with counter attacks to provide a challenge and to create the illusion of more intelligent opponents.

Pattern Matching

There are a lot of legitimate artificial intelligence algorithms to finding patterns in data and finding patterns in reactions to them based on different success requirements. However, for the purposes of game design a lot of these are currently over kill, and more importantly, not tuned to the scope of the problem.

You are not interested in creating a perfect reactionary machine in a game enemy, you are interested in provide a challenge for the player. Any game already has a big plus for you as the designer, since it is your creation and you know the limits of the game. You can therefore build your own pre-made patterns and test for them by checking the player's input or different aspects of how they are playing.

For instance, in a fighting game such as Street Fighter 2, the player has six buttons they can choose from. By capturing when the player hits these buttons and the distance of the enemy or if the enemy is in the air, you can find certain patterns of play. The player may often try to punch and then move in for a throw when they are close enough. The player may always try to do an uppercut when their enemy has jumped. By recording different input and game information at the time of input you can create a map of possible actions that you can use for the game's AI. In doing so you can "learn" the players moves and then try to counter them.

Real-time strategy (RTS) games have a much more complex system of attack, because the input of mouse clicks are irrelevant. To try to learn what your player is attempting to do in an RTS game you will have to abstract the data of the player's actions to find a common pattern. This is a totally game dependent process, but as an example let's use Command & Conquer (C&C).

In C&C the objective of an average mission is to build troops and a base to defend yourself, then destroy the enemy and their base. There are two necessary points of learning: how the player interacts with enemy units and how the player builds his base. To keep this example in focus we will only explore the first learning objective although the second would be crucial for counter-attacks.

Contact between C&C's units is very limited, when they are close enough together then they will begin to fight each other. The first type data you will need to search on is the player's preferred unit types. The player may prefer doing tank rushes; in this case, you will need to build defenses that specialize in defeating tanks. If they prefer making mini-gunner units then you will adjust your defenses against that type of attack.

The player could have a preference of attacking the harvesters versus attacking the base directly. This can be recorded and used so that you can send out troops to guard the harvesters or build more protection around the main base. To create a good learning system you need to find the most common methods of attack and then figure out how you can determine if they are occurring.

Storing and Searching

A learning system, as with any kind of database, is only as good as it's ability to find useful information. The actual content of any learning system is game dependent but there are some basics to small databases that are universal.

When you search for a pattern, you want to search on either one or more criteria. In order to do this you should save your data in a way that you can easily access data quickly. This requires that at the time you save your data you need to plan for the way the data will be accessed. If you wish to save each occurrence of data as a separate element you will need to save them in an order that is quickly searchable. To use the C&C example you can save them starting with unit type. By creating a table for each unit type you will short cut the need to search through all the records and collect the records that contain the appropriate types of units.

Another method is to store all the data in one table of ratios. The ratio of attacks to harvesters versus attacks to the base for instance. The ratio of using one type of unit over another. This would make a good in-game search method, as there are no records to retrieve and analyze. Single entry records could still be saved and analyzed outside the game. You could also weight the latest actions to represent them as more important than previous actions as an attempt to cover for any change in tactics.

Overview

Creating learning methods, like any other type of game AI, is going to take a lot of sitting down and thinking of situations. It will also take a lot of play testing. Players will come up with methods of play that you can't be obligated to think of beforehand, so you need to build your learning database flexible enough to add in more situations.

Learning the player's styles and preferences is not a key to creating an unbeatable opponent or the ultimate AI; it is a method for creating a challenge for your players. By never letting them develop a tactic that will constantly work against the computer, you will ultimately extended the life of your game and keep it fresh and challenging.
标签集:TAGS:
回复Comments() 点击Count()

回复Comments

{commentauthor}
{commentauthor}
{commenttime}
{commentnum}
{commentcontent}
作者:
{commentrecontent}