Politically Challenged

Monday, March 15, 2010

Artificial Unintelligence

There is an exciting world, where one turns mathematical equations into machine intelligence. The successful build opponents which challenges humans and creates an atmosphere ingenious enough to surprise the player but easy enough for them to win as they overcome obstacles. Some have the resources of hundreds of engineers and billions of dollars. Others have a basement, themselves and the machine they use for playing games.

Paralleling today's self-centred world, what better to speak about than my personal game project. There is one developer working on the graphics engine and one developing the artificial intelligence. Such a high focus on the artificial intelligence allows for more interesting gameplay, for the only opponent that replaces a human is the computer.

The game consists of a hex map, likely 20x20 to 30x30 in size, with each side using up to 10 units. Each unit takes up a single hex square. Units have a number of action points each turn to move, attack, cast spells or use items. The game is turn based.

In the first iteration, lacking any training data, a learning method would be impractical without sufficient resources. Instead, a coherent and consistent is a fairly reasonable compromise. A player requires only an opponent who generally moves his army forward, attacking enemies in range and casting spells. This is a good first iteration for AI, though unintelligent, makes for an excellent "easy" difficulty. A player who can think better than the general scripts used for army movement can then consistently beat an easy AI opponent.

The next iteration requires a set of training data. Usually this consists of a number of played games, with the moves of each side recorded. The victor is considered to have the "better" moves. A large number of games creates enough information to both determine what "to do" and what "not to do", to hand-tune a number of features to look for to calculate the value of a particular move. In this case, the use of simple perceptrons would be useful for calculating a weighted value of the different features. An easy class structure to swap features and an automated training tool can train a "normal" difficulty. This AI is capable of making better short-term (turn to turn) choices for each unit.

In order to build training data there are two methods. The first method is automated, where the AI is made to play against itself. The moves are determined through the slow method of building a decision tree, where all probabilistic values are assumed to be their average value to overcome the stochastic nature of the problem. A pathfinding algorithm is used to determine the optimum move each turn. This training data can then be used to code the next "learning" iteration of the AI. After the AI has been improved, then the training must be run again with the improved AI. As well, different AI seeds should be used and run against one another to avoid bias.

The second method is to use human players to play against one another, or against the computer opponent. Then again, the victor and loser is recorded along with all their moves. With sufficient data, this can be similarly used for the automated training system.

The last iteration to introduce a major component of the AI, the "hard" difficulty would be long-term planning. Again, the same training data from before can be used, but the automated training system would have to look at different features to determine what best for the AI to do overall, with a coherent plan for the whole army. In this way, the AI would no longer simply be greedy, it would attempt to determine the best path with a good ability to estimate the value of any present move. So rather than simply determining the best move for the turn, it determines the best move for a specific goal.

A possible training method could involve the AI playing the same battles repetitively with different battle plans. Then repeating the same battles, even with the same battles, the victor and loser is recorded. Features are then handcrafted based on the data to determine a good battle plan. A genetic algorithm may be a reasonable method to formulate a battle plan (a "solution") while a perceptron is used to determine the value of a particular solution.

Perhaps after years of development work, the full AI can be built with all of these complex components included.

-Ultrapunk

0 Comments:

Post a Comment

<< Home