Docsity

Creating Engaging AI Characters for Fighting Games using Genetic Programming, Thesis of Microcomputers

Toggle sidebar
bg1
1943-068X (c) 2016 IEEE. Personal use is permitted, but republication/redistribution requires IEEE permission. See http://www.ieee.org/publications_standards/publications/rights/index.html for more information.
This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI 10.1109/TCIAIG.2016.2642158, IEEE
Transactions on Computational Intelligence and AI in Games
1
Creating AI Characters for Fighting Games using
Genetic Programming
Giovanna Mart´
ınez-Arellano, Richard Cant and David Woods
Abstract—This paper proposes a character generation ap-
proach for the M.U.G.E.N. fighting game that can create engaging
AI characters using a computationally cheap process without
the intervention of the expert developer. The approach uses a
Genetic Programming algorithm that refines randomly generated
character strategies into better ones using tournament selection.
The generated AI characters were tested by twenty-seven human
players and were rated according to results, perceived difficulty
and how engaging the gameplay was. The main advantages of
this procedure are that no prior knowledge of how to code the
strategies of the AI character is needed and there is no need
to interact with the internal code of the game. In addition, the
procedure is capable of creating a wide diversity of players with
different strategic skills, which could be potentially used as a
starting point to a further adaptive process.
Index Terms—Genetic programming, AI, character, fighting
games.
I. IN TRO DUC TIO N
THE development of AI characters has played an im-
portant part in the continual evolution of more realistic
gaming environments. A main goal of these characters is
to provide human-like behaviour that can lead to engaging
and challenging games [1], [2], [3], which in turn leads to
commercial success. One of the main aspects that has been
studied in the last decade to improve the gaming experience is
the incorporation of adaptive behaviour into the characters. It
has been reported that characters that can adapt to the players
level, personalising the game, are more satisfying to play than
characters that are unbeatable or too easy to beat [4].
The AI of most commercial games is based on a number of
very well established techniques, which are simple and pro-
cessor efficient, such as manually coded Finite State Machines
(FSM) [5]. In fact many game developers rely exclusively
upon these. This is a major limitation due to their deterministic
nature. Buro et al [2] provide insight into the relative lack of
sophistication of current generation AI methods used, stating
that most companies create titles under severe time constraints
and do not have the resources and the incentive to engage
in AI research. However, the authors also acknowledge that
multi-player games often do not require high AI performance
in order to become a commercial success as long as there
are enough human players interested in playing the game
online. The competitive environment online, nevertheless, can
be seen as a deterrent to participation for new players. To
overcome the limitations of FSM approaches, there has been
some work on the use of machine learning techniques such
The authors are with the School of Science and Technology, Not-
tingham Trent University, Clifton Lane, NG11 8NS, UK (e-mail: gio-
as Reinforcement Learning [6], Artificial Neural Networks
(ANN) [7] and Markov models [8] to improve the AI char-
acters strategy in real-time. Until now, little effort has been
made to incorporate these into commercial games. The idea
of using nondeterministic approaches is something the game
industry is still approaching slowly.
Although the adaptive methods mentioned previously have
shown progress on the development of more engaging game
play, the time and resources taken to create such AI structures
is not commensurate with the level of improvement they bring
to the game as a whole. A general drawback of this kind of
approach is that at the early stages of the game, characters
may have a very erratic behaviour, needing a certain amount of
time to develop into challenging players. A more “intelligent”
character at the early stages of the game could certainly
overcome this shortfall. However, as is well known, creating
these characters will depend on the time and expertise of the
game developer.
In this paper, an approach for the creation of AI characters
using Genetic Programming (GP) is presented. GP is used as
a refinement process of the character fighting strategies which
are initially created by a random process. The fitness (ELO
rating) of the characters is estimated according to a set of
matches played using the M.U.G.E.N. engine as framework.
The main objective is to be able to build AI characters that are
interesting to play without the need of the expert developer.
These would be created in an offline process and, additionally,
they could be used as a starting point of a possible online
adaptation of the same evolutionary approach.
II. R ELAT ED WORK
The widely used state machine is itself a result of progres-
sion within the field of gaming AI. According to Kehoe et
al, the initial gaming AI creations were rule-based systems,
the most basic form an intelligent system can take [9]. Games
such as Pac-Man are an example of rule-based AI systems,
where the four pursuing “ghosts” make navigational decisions
based upon simple rules and the position of the player [10],
[11]. Kehoe presents FSM as a development of rule-based AI
systems, as a FSM can evaluate many rules simultaneously and
factor in the current state of the AI. Each “state” can have
a completely different set of rules to determine behaviour,
with the transitions managed by the state machine itself.
The author suggests that the next step is the creation of an
adaptive AI. An adaptive AI is defined as an AI which takes
into account past interactions in determining future behaviour,
either via gathered historical data or real-time evaluation of
the success/failure of randomly chosen actions.
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Creating Engaging AI Characters for Fighting Games using Genetic Programming and more Thesis Microcomputers in PDF only on Docsity!

Transactions on Computational Intelligence and AI in Games 1

Creating AI Characters for Fighting Games using

Genetic Programming

Giovanna Mart´ınez-Arellano, Richard Cant and David Woods

Abstract—This paper proposes a character generation ap- proach for the M.U.G.E.N. fighting game that can create engaging AI characters using a computationally cheap process without the intervention of the expert developer. The approach uses a Genetic Programming algorithm that refines randomly generated character strategies into better ones using tournament selection. The generated AI characters were tested by twenty-seven human players and were rated according to results, perceived difficulty and how engaging the gameplay was. The main advantages of this procedure are that no prior knowledge of how to code the strategies of the AI character is needed and there is no need to interact with the internal code of the game. In addition, the procedure is capable of creating a wide diversity of players with different strategic skills, which could be potentially used as a starting point to a further adaptive process.

Index Terms—Genetic programming, AI, character, fighting games.

I. INTRODUCTION

T

HE development of AI characters has played an im- portant part in the continual evolution of more realistic gaming environments. A main goal of these characters is to provide human-like behaviour that can lead to engaging and challenging games [1], [2], [3], which in turn leads to commercial success. One of the main aspects that has been studied in the last decade to improve the gaming experience is the incorporation of adaptive behaviour into the characters. It has been reported that characters that can adapt to the players level, personalising the game, are more satisfying to play than characters that are unbeatable or too easy to beat [4]. The AI of most commercial games is based on a number of very well established techniques, which are simple and pro- cessor efficient, such as manually coded Finite State Machines (FSM) [5]. In fact many game developers rely exclusively upon these. This is a major limitation due to their deterministic nature. Buro et al [2] provide insight into the relative lack of sophistication of current generation AI methods used, stating that most companies create titles under severe time constraints and do not have the resources and the incentive to engage in AI research. However, the authors also acknowledge that multi-player games often do not require high AI performance in order to become a commercial success as long as there are enough human players interested in playing the game online. The competitive environment online, nevertheless, can be seen as a deterrent to participation for new players. To overcome the limitations of FSM approaches, there has been some work on the use of machine learning techniques such

The authors are with the School of Science and Technology, Not- tingham Trent University, Clifton Lane, NG11 8NS, UK (e-mail: gio- [email protected]).

as Reinforcement Learning [6], Artificial Neural Networks (ANN) [7] and Markov models [8] to improve the AI char- acters strategy in real-time. Until now, little effort has been made to incorporate these into commercial games. The idea of using nondeterministic approaches is something the game industry is still approaching slowly. Although the adaptive methods mentioned previously have shown progress on the development of more engaging game play, the time and resources taken to create such AI structures is not commensurate with the level of improvement they bring to the game as a whole. A general drawback of this kind of approach is that at the early stages of the game, characters may have a very erratic behaviour, needing a certain amount of time to develop into challenging players. A more “intelligent” character at the early stages of the game could certainly overcome this shortfall. However, as is well known, creating these characters will depend on the time and expertise of the game developer. In this paper, an approach for the creation of AI characters using Genetic Programming (GP) is presented. GP is used as a refinement process of the character fighting strategies which are initially created by a random process. The fitness (ELO rating) of the characters is estimated according to a set of matches played using the M.U.G.E.N. engine as framework. The main objective is to be able to build AI characters that are interesting to play without the need of the expert developer. These would be created in an offline process and, additionally, they could be used as a starting point of a possible online adaptation of the same evolutionary approach.

II. RELATED WORK

The widely used state machine is itself a result of progres- sion within the field of gaming AI. According to Kehoe et al, the initial gaming AI creations were rule-based systems, the most basic form an intelligent system can take [9]. Games such as Pac-Man are an example of rule-based AI systems, where the four pursuing “ghosts” make navigational decisions based upon simple rules and the position of the player [10], [11]. Kehoe presents FSM as a development of rule-based AI systems, as a FSM can evaluate many rules simultaneously and factor in the current state of the AI. Each “state” can have a completely different set of rules to determine behaviour, with the transitions managed by the state machine itself. The author suggests that the next step is the creation of an adaptive AI. An adaptive AI is defined as an AI which takes into account past interactions in determining future behaviour, either via gathered historical data or real-time evaluation of the success/failure of randomly chosen actions.

Transactions on Computational Intelligence and AI in Games 2

A first step towards adaptive AI in commercial games was the release of the Virtua Fighter 4 game for the Sony Playstation 2. The game allows for an “AI Construct” to be trained by the player via imitation. This approach in practice proved unpopular. It took excessive amounts of time for a player to teach the AI its basic capabilities, and further hours spent watching the game play itself. Even so, it did not yield compelling gameplay. The feature was then removed on the following release, and has not re-emerged in any other commercial fighting game. Most of the research carried out on adaptive AI characters has been done using independently coded fighting games, which, with some exceptions [12], do not adequately replicate modern commercial fighting games. Danzi et al developed an adaptive AI using reinforcement learning in an attempt to develop adaptable difficulty levels. They implemented their own fighting game, Knock’em, which is more representative of commercial games than other research implementations, as it allows for a wider range of moves. To allow the adaptation of the characters, positive reward is given if the AI character has more health that the human player. Prior to the evaluation, the AI character was trained against a random fighter in 500 fights. According to their experimental results, their adaptive characters were able to match other standard AI characters despite losing most matches. Graepel et al applied reinforcement learning to find near optimal policies for agents acting in a Markov decision process (MDP) [8]. They used the commercial game Tao Feng as a test bed. This game, based on a non-deterministic finite- state machine, provides a wide diversity of fighting characters and styles and has over 100 different actions available to the player. They used two types of reward functions depending on the change in health of both combatants. Their results successfully demonstrated that from a starting random policy, agents could change their behaviour to adapt to the built-in AI and expose/exploit gaps in the rule-based built-in AI. Ricciardi et al also studied the possibility of adaptive tech- niques for generating functional fighting AI using an enhanced MDP [13]. Their idea was to have the AI adapt to varying strategies carried out by the human player in real-time. This was challenging due to limited availability of training data. The AI characters were provided with only a few negative rules about the game to eliminate a large empty area of the search space, but given no further information to the character. The adaptive characters were tested using a simplified facsimile of a commercial fighting game and it was observed that the AI could gradually improve as it gathered more data from human opponents. The characters were also tested to recognise human player patterns according to past player models, in order to offer a better starting position for the AI. Despite achieving good results against static AI characters, no conclusions could be made when playing against human players, as the human players changed tactics too frequently to allow the AI to create a consistent model. Ortiz et al propose an adaptive character with a three subagent architecture that can adapt to the level of the user using reinforcement learning [6]. Positive reward is issued at the end of each round when the difference in health between

the AI character and the human player is small and negative when it increases. This type of measure allows the algorithm to identify how closely match both players are. The closer they are, the more engaging the game is. This reward strategy is different from the one implemented by Danzi, who focused on rewarding those characters with higher health. Ortiz et al carried out a set of experiments involving 28 human players who were asked to play between 15 and 30 rounds against a set of AI players (both static and adaptive). Although the authors argued that the adaptive players had the least negative results, the most positive reviews were given to a strong static player. Another platform that has been created as a test bed for fighting games AI is the FightingICE platform, which was first introduced in [14] and further used in [15]. This platform was created as a tool for game competitions allowing students to test their codes. Yamamoto et al, who created the platform, later presented an AI of their own that uses the k-nearest neighbour algorithm to predict its opponent’s attack action and devise an effective countermeasure against the predicted attach. The authors tested their AI against winners of previous FightingICE competitions and demonstrated the strength of their AI, beating all other AI characters. Despite their encour- aging results, there was no experimentation carried out with human players, and hence no conclusions can be made about how engaging their AI characters are. An alternative approach to AI improvement in fighting games was constructed by Thunputtarakul et al [16], utilising an emulated version of a commercial title in the Street Fighter series. This approach involved the construction and training of a “Ghost” AI, an AI structure that could rapidly observe actions taken by a player and assess their priorities, yielding as a result an AI which could reproduce its creator’s playing styles even when the training time was short. Despite the successful results, there were some limitations to the technique such as “unlearning” styles previously encountered, rendering the AI vulnerable to a human player who simply altered their tactics. Further work in this area was developed by Saini [17], who, unlike Thunputtarakul, designed a k-nearest neighbour solution using in-game parameters, which are driving factors for the behaviour and strategies exhibited during the match. In order to gather data from the player being mimicked, the suggested approach observes the human player and records its movements and the parameters of the game. This enables it to understand under what circumstances each strategy is used. The data is analysed in an offline mode and a strategy is selected using the k-nearest algorithm or a data-driven FSM. The data capture phase is critical in this approach, as one needs to make sure the human strategies can be captured, needing a certain number of matches to record the human player moves. Saini tested both of his proposed strategies against a human player and used human observers to evaluate the moves of the AI. According to those observers, both strategies were capable of mimicking human strategies. A main limitation of these approaches is that they rely on the strategic play of human players. This was an evident limitation when the human player changed strategies back and forth frequently. Also these methods require the human player to spend time in

Transactions on Computational Intelligence and AI in Games 4

pressed button 1, perform the move associated with move 1” or logical triggers such as “If the player has been knocked over, pressing button 1 will not execute a move, they must wait until their character stands up”. These triggers form the core of the control mechanism of the game. A custom AI within the engine either replaces or adds to the triggers within each move’s change state, allowing for automated behaviour to occur. For example, a logical trigger “If the opponent is within 100 pixels, then perform move associated with button 1” could be added to the single input trigger. Each action a character can take could then possess a single input trigger and many logical triggers. It should be noted that the flaws observed in a fighting game AI are easily attributable to imperfect implementations of a FSM; lack of adaptability, state transitions impossible for a human player, perfect reaction times. In order to adequately implement the GP approach, certain requirements were defined as an attempt to mitigate some of the FSM limitations. First, characters must adhere to all of the limitations and constraints applied to a human player of the game. It must not be possible for an AI to utilise a move or tactic which a human player could not physically recreate. Second, characters must not possess faster reaction times than would be possible for a human player. The implementation of the GP approach would need to incorporate these requirements in order to evolve valid solutions.

IV. IMPLEMENTATION OF THE GP APPROACH

Genetic Programming [27] is a biologically inspired com- putation technique based on the evolution of individuals (i.e. programs) over time, through events such as crossover and mutation. Each of these programs represent a set of instruc- tions to solve a specific problem. In a typical GP implemen- tation, solutions are coded in a binary tree structure where interior nodes represent functions/logical operators and leaves represent terminals (data on which functions are applied). In the case of the M.U.G.E.N. AI, each program (character) is composed of a set of sequential blocks that represent the fighting strategy. In our approach, these blocks form the genetic code that underlies the evolutionary process. The binary representation was therefore replaced by a sequential one, where each node represents a block or move which can be randomly mutated over time. The components of the genetic algorithm were implemented within the M.U.G.E.N. system as follows:

A. Creation of Initial Population

In order to create valid characters for the initial population of the evolutionary process, it is necessary to randomly gener- ate valid groups of triggers to place within the change states of a character. To do this, a template version of a state definition must be created. This template retains all of the change states present in the original functional character, but removes any input triggers and replaces them with dependency upon an AI variable (a flag variable that renders the character unresponsive to player input and grants sole control to the AI).

In order to be able to apply the genetic operators upon the generated AI, it was necessary to define the “terminals” or potential actions that an AI could perform, which would be manipulated by later genetic operators. The structure of the M.U.G.E.N. engine custom AI made this a relatively simple process. Each move available to the character is already isolated into a unique block of code. The default character provided within the M.U.G.E.N. engine possesses 34 such terminals, each relating to either a move (punch, kick, throw, sweep, etc) or an action (run forward, jump, run backwards). Thus if suitable randomly selected triggers were to be placed within each of these terminals, a functional AI would be generated with full access to all the moves a player of that character would have. This fulfils the first requirement stated previously regarding the incorporation of only human feasible moves into the AI character. Each of these blocks of code would then contain between one and four trigger points; triggers that when combined, represent one instance where the move can be performed. Within each trigger point, it was necessary to generate a trigger or combination of triggers which would cause the AI to perform the change state. A full list of the triggers recognised by the internal workings of the M.U.G.E.N engine is provided externally by the creators of the engine [28]. There are 113 in total. We removed the triggers that are purely intended as system functions or those irrelevant to the character used for testing (AILevel, ParentDist, IsHelper and others). The triggers that were retained consist only of information visible to a human player examining the screen. They are as follows:

  1. P2BodyDistX, P2BodyDistY: these return the relative position of the opponent on the screen in the X and Y directions. Inclusion of these triggers potentially allows an AI to see where its opponent is and act accordingly.
  2. GuardDist: this trigger returns true if the opponent has entered an attacking state and the AI is within distance to guard it. By including this trigger, the AI can potentially become aware that it is currently being attacked.
  3. P2MoveType, P2StateType: these evaluate the current state the opponent of the AI is in, in terms of both movement (crouching, standing, jumping) and state (at- tacking, idle, being hit). These triggers allow the AI to react based on the current actions of the opponent in a wider context than the earlier GuardDist trigger.
  4. MoveContact, MoveGuarded: these return true when the AI has either connected with an attack move, or has successfully blocked an attack move by the opponent. The former allows an AI to detect when it has gained an advantage and potentially follow up successful ag- gression with extra actions. Conversely, the latter allows it to detect when it has successfully defended against an attack and enact retaliation. These seven triggers form the basis of the observation ability of the generated AI within the game world. While much smaller than the full list, this is enough to allow an AI to observe and react, forming a randomly generated “strategy” that it would use to play the game. The game engine reads the change states within the AI

Transactions on Computational Intelligence and AI in Games 5

code sequentially and halts when one is activated, so terminals located at the end of the file would be less likely to be checked by the engine, reducing the probability that their moves will be performed. This means that the order in which the terminals are placed is important, not just their content. Therefore, both the contents and the order of the terminals should be randomised. Every character is coded in a .cmd file which contains a general header, a set of five fixed terminals and then the randomised terminals. Each terminal consists of the specification of the action to be carried out when it is activated followed by a list of triggers. The list of triggers is effectively a standard sum of products anded with some overall conditions. The game engine checks change states approximately every 1/60th of a second. If conditions arise whereby a change state would be activated, it will occur and be enacted with a time far shorter than a human player could achieve. In order to increase these AI reaction times, each trigger group within a terminal needs to include a random chance of activation. Introducing a 50% chance of activation does not mean that the move is used only half of the time it is appropriate. Given the frequency that the engine checks every state, it means that on average the time taken for the engine to enact that change state under suitable conditions is increased by 50%, simulating a reaction time element. Furthermore, these random number checks were subject to further random variation; a high probability of success would mean the move would be used more quickly and frequently, while a lower chance would mean the move was available, but often neglected in favour of alternatives. Randomising these factors in an AI has numerous benefits with regards to AI quality. If the character can favour moves, it can be seen to have a “play style”, and if it has variation in its timing, it can be seen as more “human” in its ability to react to the game world.

B. Definition of a fitness function

In order to evaluate whether a generated AI is performing well, a fitness function must be defined. The system chosen would need to be robust, designed to provide a comparative evaluation of ability and be capable of functioning in an envi- ronment where new entities are added or removed frequently. It should also allow for variance in individual performance, producing results over many matches rather than relying on a single Boolean win/loss performance condition as the basis of its rankings. This is due to the fact that testing a fighting game AI character for competence is a more difficult process than simply applying the results of a deterministic equation. The matches themselves are not solely dependent upon the actions of one player; the reactions of the second player also heavily contribute to success or failure. In addition to this, the actions of the characters are randomised and so each bout between any given pair of characters will be different. For the reasons stated above, the ELO system was selected. This ranking system is currently used by the United States Chess Federation (USCF) for worldwide ratings of player skill. It has also been adopted by many popular competitive multiplayer games such as Backgammon, Go and Scrabble,

and to videogames across several genres, including but not limited to League of Legends, Counterstrike and Pokemon, with some variations in their implementations. The ELO system works upon the principle that the performance of a given player in any given match is a random variable within a normal distribution, and that the overall rating of a player needs to take into account the skill of the opponent as well as whether a win or lose outcome is reached. An equation is applied to current ratings to predict the probability of one player securing a win against the other. The results of this equation are then used to calculate how many points will be added to the rating of the winner and how many will be subtracted from the rating of the loser. In order to calculate the expected score of a player the following formulas are used:

EP 1 =

1 + 10(RP^2 −RP^ 1)/^400

EP 2 =

1 + 10(RP^1 −RP^ 2)/^400

P1 and P2 corresponding to player one and player two and R and R2 to their corresponding current ratings. After a match is played between the two players, the ratings are adjusted by an amount proportional to the difference between the expected score and the actual result. The formula used is:

R

′ P 1 =^ RP^1 +^ K(SP^1 −^ EP^1 )^ (3) where K is a factor that controls the strength of the adjustment and S is a Boolean indicating a win or a loss. These are the standard ELO formulae. We have used a K factor of 50 which is accepted as a reasonable value when the ratings are not already well established. The initial score given to all characters after creation is set to 1000. Next, a set of matches is carried out to find their actual ratings. A ranking of 1000 would remain the average rating regardless of how many matches were played. The stronger AI characters would be expected to achieve a rating above 1000 whilst the weaker ones would be below 1000. For each of the generations of the evolutionary process, this process is repeated but any characters that are retained unchanged will start from their existing rating. In order to define how many matches a character should play in order to arrive to a realistic score in comparison to other characters within the same generation, a set of experiments were carried out. First an initial population of 30 individuals was created, setting their initial ranks to 1000. A round robin tournament was then performed, each individual playing a total of 29 matches. The change in the rank is shown in Figure 2. It can be observed that after the first 5 matches, is difficult to identify good players from poorly performing ones. Somewhere between match 10 and match 15 a consistent pattern starts to emerge. After the first round robin, two more round robins were performed to observe if there were any further changes in the scores. Results are shown in Figure 3. As it can be seen, most of the individuals show a reasonably stable score after 30 matches, with some exceptions. A second experiment was carried out by taking only two individuals

Transactions on Computational Intelligence and AI in Games 7

Initialisation

Evolution

Fig. 5. Illustration of the GP implementation and its interaction with the M.U.G.E.N. engine.

is achieved by extracting and carrying the good aspects of current individuals into future generations. The crossover is performed by selecting genetic material from two individuals and combining them to generate a new one. For this applica- tion in particular, the terminals, which correspond to the blocks or moves of the characters, are selected randomly from each of the parents. For example, a first child could be created from two parents with four terminals each by randomly selecting terminals 1, 2 and 4 from the first parent and terminal 3 from the second. Conversely, the second child would possess terminals 1, 2 and 4 from the second parent and terminal 3 from the first. As mentioned previously, the order in which terminals are located in the file will impact the performance of the AI. For this reason, the implementation of the mutation was carried out by taking the newly generated individual and randomising the order of the terminals. As in any other application of GP, mutation is a parameter to be determined experimentally. although the general approach is to set it to a small value. The next section will present more detail on this aspect. Because of the way these genetic operators work neither the number of terminals nor their internal complexity can increase. Consequently the common problem that exists in genetic programming of overcomplex solutions cannot arise here. An illustration of the GP approach for AI character creation is given in Figure 5. It can be observed that there is a continuous interaction between the GP and the game engine as information is gathered from every match in order to calculate the fitness of each individual at each generation. The process stops after a fixed number of generations.

V. EXPERIMENTS AND DISCUSSIONS

The implementation described in the previous section had two main objectives. First, to be able to construct AI characters using an evolutionary approach, where the expertise of the game developer was not needed. The creation of AI that could beat the default AI provided by the M.U.G.E.N. engine would be considered a success. The second objective was to develop

TABLE I GP PARAMETERS WHICH WERE USED FOR THE INITIAL SET OF EXPERIMENTS

Parameter value Number of Matches for ELO Rating 30 Number of Divisions and Size 3 divisions, 33% of the population each Elitism 5% New Individuals by Crossover 90% New Random Individuals 5% Mutation Probability 3%

an AI character that could demonstrate some level of strategy that could be engaging and satisfying for the human player.

A. Initial Validation of the Technique As in other machine learning techniques, the quality of the results of the GP approach and the speed with which they are produced may be affected by the values of the input parameters. Given the random nature of the process it is also possible that a particular set of results could be good or bad by pure chance. The initial choice of parameters is based on previous experience of similar systems and the need to produce results in a reasonable time. A size of 100 characters was established as a starting number that could be further changed if needed depending on the results. To ensure that the results were repeatable, five runs using this size were executed for 30 generations, with a starting mutation rate of 3%. The rest of the parameters that were set for all runs are shown in Table I. From these initial runs, it was important to make sure that the evolutionary process was actually creating characters with better performance than the ones created randomly at the start of the process. Our ELO system cannot be used to judge the performance of one generation versus another. This is because all the newly generated players are injected into the system with an initial default rating of 1000, thus pulling the average rating of the whole generation back towards that value. To ascertain how the performance was changing from one generation to another, another run was made, but this time all new characters of each generation (excluding the ones that survived from previous generations) were matched up against a constant set of 30 elite players obtained from the final generation of the original runs. These matches were completely separate from the matches played by the characters to calculate their ELO as part of the evolutionary process, and did not affect that process. Figure 6 shows the average percentage win rate of new characters through time when matched against the same group of elite players. The figure shows how there is an immediate increase of the winning percentage in the first few generations up to genera- tion 8. Then the population average win rate increased more slowly, reaching a maximum average of 48% at generation

  1. These results indicated that fitter characters were being created by the process. To allow multiple runs to be made in parallel we used standard university laboratory personal computers, which are available in large numbers. On these machines runs with 100 individuals take on average 75 minutes per generation. This means that a 30 generation would take

Transactions on Computational Intelligence and AI in Games 8

20%

25%

30%

35%

40%

45%

50%

5 10 15 20 25 30

Average Win Percentage [%]

Generation Fig. 6. Average win percentage of new players of each generation matching them against the same “elite” group.

around 37 hours to complete and a 100 generation run would take approximately 125 hours. Once the evolutionary process was proved to be working well with our initial set of parameters, further runs were made with different population sizes (100 and 300), number of generations (30 and 100) and mutation rates (0%, 1%, 3%, 6%, 15% and 20%). Initial testing of the characters generated from populations of 300 did not show any siginificant improvement. Since these runs were very time consuming we decided not to pursue the larger populations further and hence they are not included in the results presented here. The best performing characters from the final generation of each run then formed the set that were taken forward for further testing against manually created AI characters and human players. There are several types of result that could be established.

  1. How good a player each of these characters was in absolute terms against other AI characters.
  2. How effective these characters were in terms of their ability to win against a human opponent.
  3. How these characters were perceived by a human oppo- nent in terms of difficulty and satisfaction.
  4. The extent to which these results depend on the param- eters used for the genetic algorithm process. To this end we ran the following tests:
  5. Round robin tournaments between our AI characters and the standard AI characters mentioned earlier.
  6. Human tests, involving a group of students who ex- pressed an interest in playing fighting games. The total number of students participating was 27. These players were of varying abilities, which may have affected their results and perceptions. However we did not have a large enough number to segregate them on that basis and still retain a statistically significant result.

B. Testing Against standard AI Characters

We assessed the playing abilities of the various AIs using round robin tournaments. These were all assessed using win percentage rather than ELO. In a full round robin there is no

0

10

20

30

40

50

60

70

80

0 10 20 30 40 50 60 70 80

Result for 15x Round Robin

Result for Single Round Robin

GA CharactersKFMStd KFMCapComKFMVism WeakKFM

Fig. 7. Average win percentage of GA players and manually generated players in a 15x round robin tournament plotted against their win percentage in a single round robin.

advantage in using ELO, and indeed it has the disadvantage that the results can be affected by the order of the matches. Some trial tournaments were held to determine the choice of characters to be used for the human testing and to obtain some initial information about the effect of different parameter choices. Subsequently the characters that had been chosen for human testing were given a more exhaustive test by repeating the complete round robin 15 times and accumulating the results. The set of characters used for this test consisted of 41 GA characters plus the following four manually created characters: Kung Fu Man (KFMStd) which is the default AI provided by the engine. Capcom Kung Fu Man (KFMCap), which possesses all the abilities of KFMStd as well as new ones which are present in a variety of Capcom games such as power charge, fireballs, knee kick super combo. The V- ism variant (KFMVism) which is also based on KFMStd but has one extra ability, the custom combo attack, which is performed much faster than in regular gameplay. Finally the Weak Kung Fu Man (WeakKFM) is a character that performs a very defensive strategy against any player. The choice of these players was determined by the following considerations:

  1. To maintain objectivity we should use only AIs that had been generated by others.
  2. The AIs should not have abilities such as super fast reactions that can make a player impossible to beat. In other words they should obey similar constraints to those that we set ourselves when setting out the framework for generating the GA characters. This also has the advantage that such players would not stand out too obviously under human testing. The GA characters used had a variety of different mutation rates (from 1% to 20%). Some characters were created over 30 generations whilst others used 100 generations. The results of this exercise are shown in Figure 7. The results of the multi-round robin are plotted on the y axis against the single round robin on the x axis. This test shows a convergence towards the mean for all of our GA generated

Transactions on Computational Intelligence and AI in Games 10

TABLE II RANDOM SIMULATION METHOD

Experimental Data Student 1 Student 2 Student 3 AI Sc Df St AI Sc Df St AI Sc Df St 1 0.1 3 2 1 0 2 2 1 0.2 4 2 2 0.2 4 4 2 0.1 2 4 2 0.3 4 2 3 0.15 4 2 3 0.2 5 3 3 0.1 5 5 4 0.4 4 1 4 0.2 5 1 4 0.6 5 2 Randomised Simulation 1 Student 1 Student 2 Student 3 AI Sc Df St AI Sc Df St AI Sc Df St 2 0.1 3 2 4 0 2 2 4 0.2 4 2 3 0.2 4 4 2 0.1 2 4 3 0.3 4 2 4 0.15 4 2 3 0.2 5 3 1 0.1 5 5 1 0.4 4 1 1 0.2 5 1 2 0.6 5 2 Randomised simulation 2 Student 1 Student 2 Student 3 AI Sc Df St AI Sc Df St AI Sc Df St 3 0.1 3 2 3 0 2 2 3 0.2 4 2 4 0.2 4 4 1 0.1 2 4 4 0.3 4 2 2 0.15 4 2 2 0.2 5 3 1 0.1 5 5 1 0.4 4 1 4 0.2 5 1 2 0.6 5 2 AI: ID number of the AI that was tested Sc: Score of the AI against the human opponent Df: Perceived difficulty St: Satisfaction

TABLE III SCORE, DIFFICULTY RATING AND SATISFACTION RATING FOR THE VARIOUS AIS RELATIVE TO KFMSTD

Result No. of Score Difficulty Satisfaction for results (p value) (p value) (p value) GA Av.* 263 0.19 (0.0) 1.31 (0.0) 1.40 (0.0) KFMCap 16 0.019 (0.42) 0.55 (0.065) 0.75 (0.0047) KFMVism 18 0.0037 (0.49) -0.18 (0.32) -0.11 (0.37) Weak kfm 10 -0.033 (0.38) -0.33 (0.25) 0.25 (0.31) GA 01 14 0.29 (0.00077) 1.09 (0.0051) 1.41 (0.00022) GA 02 32 0.19 ( 0.002) 1.39 (0.0) 1.71 (0.0) GA 03 17 0.17 (0.017) 1.01 (0.0017) 1.47 (0.00002) GA 04 17 0.32 (0.00005) 1.51 (0.00001) 1.53 (0.00001) GA 07 14 0.21 (0.016) 0.96 (0.0063) 0.66 (0.016) GA 08 14 0.19 (0.027) 1.41 (0.00007) 1.13 (0.00005) GA 17 17 0.16 (0.037) 1.63 (0.0) 1.26 (0.00001) GA 45 13 0.26 ( 0.0028) 1.63 (0.00004) 0.96 (0.001) GA 46 13 0.24 (0.0059) 1.60 (0.00003) 1.19 (0.0001)

  • A grand total of 41 GA created characters were tested. The number of tests varied, most being tested 3 or 4 times. The results for characters tested 10 times or more are shown explicitly. The average quoted here is taken over all of the characters but is weighted to give equal significance to each test. ** In these cases the random process did not succeed in finding an event that matched or beat the measured data so p has an upper bound of approximately 0.00001.

a separate AI column for each student volunteer. For each result we counted the number of times, within the 100, simulations, for which the value was more extreme (ie further away from the expected average value) than the actual result. It is this count, expressed as a fraction of 1, that is reported as the p value in the results that follow. The scores, perceived difficulties and satisfaction ratings for the various AIs are shown in Table III. Note that because KFMStd has been used as a fixed point to normalise all the other AIs it is not shown in the table. The original raw values for KFMStd were: Win rate 0.028, Difficulty 1.84,

TABLE IV MUTATION RATE AND NUMBER OF GENERATIONS USED TO CREATE THE VARIOUS AIS PRESENTED IN TABLE III.

Character Mutation No. of Generations GA 01 0.03 30 GA 02 0.03 100 GA 03 0.03 100 GA 04 0.03 100 GA 07 0.01 100 GA 08 0.01 30 GA 17 0.06 100 GA 45 0.15 100 GA 46 0.20 100

TABLE V SCORE, DIFFICULTY RATING AND SATISFACTION RATING FOR THE VARIOUS AIS RELATIVE TO KFMCAP

Result Score Difficulty Satisfaction for (p value) (p value) (p value) GA Av - KFMCap 0.17 (0.012) 0.77 (0.0093) 0.65 (0.0072) GA 02 - KFMCap 0.17 ( 0.034) 0.84 (0.016) 0.96 (0.003 ) GA 04 - KFMCap 0.30 (0.0033) 0.97 (0.015) 0.78 (0.018) GA 07 - KFMCap 0.19 (0.026) 0.42 (0.14) -0.089 (0.38) GA 17 - KFMCap 0.14 (0.082) 1.09 (0.0041) 0.51 (0.063)

Satisfaction 2.19. As with the AI versus AI test, the GA generated characters comfortably beat the standard AI on all categories and the associated p values are all below the commonly used threshold of 0.05. Detail of the parameter setting for the creation of these AI are presented in Table IV. Of the manually created AIs, only the Capcom character scored well enough to be a noticeable improvement on KFM- Std. Given the p values it is apparent that even this advantage is only really valid in the satisfaction category. However, since its scores are higher than those for KFMStd we have also calculated relative scores and p values of the best and worst GA characters versus KFMCap. As can be seen from Table V most of the GA characters are better than KFMCap on most categories. The main exception was GA07 which was inferior on satisfaction, although that result is not statistically significant. A few other results have p values which are too high for a conclusion to be drawn with confidence. These are GA17 on satisfaction, GA07 on difficulty and GA17 on score. Thus the results show that in general terms the GA created characters are superior to the manually coded AIs that were tested. It is interesting to consider whether score, perceived diffi- culty and satisfaction are all effectively measuring the same thing. To determine this we calculated the correlations between score, perceived difficulty and satisfaction. This was done twice, once for all the characters and then again with only the GA characters included. The results are shown in Table VI. When all the characters are included the results show a strong correlation between all three quantities. However when only GA characters are included, the correlations are weaker and the correlation between score and satisfaction is espe-

Transactions on Computational Intelligence and AI in Games 11

TABLE VI CORRELATION BETWEEN SCORE, DIFFICULTY AND SATISFACTION

Measured All Characters GA Characters only Correlation (p value) (p value) Score vs Difficulty 0.75 (0.0) 0.56 (0.003) Difficulty vs Satisfaction 0.79 ( 0.0) 0.52 (0.008) Score vs Satisfaction 0.6 (0.001) 0.28 (0.11)

  • In these cases the random process did not succeed in finding an event that matched or beat the measured data so p has an upper bound of approximately 0.00001.

cially weak and consequently not statistically significant. Our interpretation of this is that the students disliked very weak players but when evaluating players of roughly equivalent strength other factors came to the fore. When considering GA players only it seems that some students equated score with difficulty (correlation 0.56) whilst others associated difficulty with satisfaction (correlation 0.52). However relatively few can have made both associations because otherwise the correlation between score and satisfaction would have been greater than the recorded value of 0.28.

D. Impact of Genetic Algorithm Parameters

The final issue that we considered was the question as to whether the parameters used in the genetic programming algorithm would have an effect on the performance of the characters against human players. The convergence towards the mean observed in Figure 7 suggests that we may not be able to establish such a connection. However we have analysed our data to see whether the differences between different GA characters are big enough for these effects to be observable.

We therefore calculated the difference between the score of each individual GA character and the mean of all the remaining GA characters. The results are shown in Table VII.

The first thing to note is that in most cases the difference from the mean is clearly not statistically significant. However there are a few cases that have low enough p values to require discussion. Only one score difference has a low p value, that is 0.03 for GA04. In the difficulty category all the p values are too high for any statistical significance. In the satisfaction category GA07 appears to be below average with a low p value. GA45 is also below average, with a p value that is marginal, whilst GA02 is above average with a similar p value. These values do seem to be significant, however there are not enough of them to support a further analysis of the effect of the GA parameters. In addition, we must also be cautious because these instances have been located by searching through a group of 10 candidates and hence one would expect at least one p value of around 0.1 to arise from pure chance every time. To make sure of this result we did calculate the correlations between the GA parameters and the human test results. None of the correlations had a magnitude greater than 0.1 and all of the p values were clearly above the generally accepted threshold of 0.05 for a result to be considered statistically significant.

TABLE VII DIVERGENCE FROM THE MEAN OF DIFFERENT GA CHARACTERS

Result Score Difficulty Satisfaction for (p value) (p value) (p value) GA 01- GA Av. 0.1 (0.12) -0.23 (0.27) 0.0081 (0.5) GA 02- GA Av. -0.005 (0.48) 0.09 (0.36) 0.35 (0.06) GA 03- GA Av. -0.03 ( 0.36) -0.32 (0.14) 0.07 (0.4 ) GA 04- GA Av. 0.14 (0.03) 0.22 (0.24) 0.14 (0.32) GA 07- GA Av. 0.016 (0.43) -0.37 (0.15) -0.8 (0.004) GA 08- GA Av. -0.008 (0.48) 0.1 (0.4) -0.29 (0.16) GA 17- GA Av. -0.035(0.34) 0.34 (0.15) -0.15 (0.29) GA 45- GA Av. 0.07 (0.22) 0.34 (0.19) -0.46 (0.06) GA 46- GA Av. 0.05 (0.28) 0.30 (0.22) -0.22 (0.23)

VI. CONCLUSION

We have shown that genetic programming can be used to create AI characters for the M.U.G.E.N fighting game. Minimal human intervention is required in the process and unlike other techniques the method does not require any modification of the game engine itself. Testing the resulting characters in terms of performance against publicly available hand coded AI characters showed that the characters produced by the evolutionary process were significantly better than hand coded ones. KFMCap was the only one that achieved a result near to that of our GA characters. Further testing with human players showed that, although the GP characters were only able to win a few matches, they still outperformed the hand coded AI in terms of wins and were also rated more highly for perceived difficulty and user engagement. The correlation observed between satisfaction and perceived difficulty scores among all AI characters suggest that, in general, human players tend to dislike very weak AI characters. However, when they are presented with characters that are roughly equivalent in strength, their perception varies. This suggests that there are other factors that may determine the perception of the human player. All of these results were seen to be insensitive to the population size and mutation parameters of the algorithm. The analysis of the results suggest that the performance of the characters is determined by the choice of triggers and responses used in the creation process and that any additional randomness in the evolutionary process (e.g. new random characters, mutation operator) does not affect the effectiveness of the algorithm. The practical implications of applying a GP approach to generate AI are that substantial savings could be made in AI generation by utilising GP to ’grow’ AI characters for games rather than directly implement them by hand. Another advantage is that the method automatically produces a large set of different characters. Future work will be focused on carrying out more extensive experimentation with human players and investigating if new adaptations to the GP approach could improve the present results by, for example, changing the natural selection rules or the tournament design. Increasing the range of triggers will also be studied to assess its impact on how quickly a more complicated logic can emerge.