Project Plan: Genetic Tower Defence
David Fleming
AIM
To design and create an implementation of the Tower Defence game,
playable by a human player and also playable by an AI script created using a
genetic programming system. After this, some testing will be done with
inexperienced human players to get game score results that can be compared
with the scores of the AI’s game. This will allow analysis to observe the
possibility of using genetic programming for human competitive AI in a non-
perfect information game.
BACKGROUND
Human-Competitive AI
Human-competitive AI in games is an ongoing field of game AI
development research. Many believe the best way to attain this is through
machine learning; genetic programming is a form of machine learning that, in
the game development field, is traditionally used for perfect information
games like chess. The possibilities for genetic programming (and genetic
algorithms, a similar concept) in different game types is an area that is
becoming more popular in game AI.
In chess, moves are based on the current situation of the player and the
opposition, and the possible future moves of each. The difference in a game
such as tower defence (and any RTS) is that it is unpredictable which waves
of enemies might come, and in order to defend efficiently almost every
possibility must be given due consideration; the only thing known to the
player is that some enemies will come, of some form, and need to be
destroyed. Other game types that genetic programming has had success with
include Snake (a game with lots of random variation), football (a game where
current circumstances are the most important factor in the game) and
Robocode (a game where coded AI bots fight in an arena – this is different
because it pits genetic AI against genetic AI, so AIs are evolving in order to
counter other evolving AIs). Genetic algorithms have been discussed in terms
of their use for RTS games such as StarCraft, but genetic programming has
not had a significant investigation for its suitability.
Why Genetic Programming?
Heuristic-based machine learning is a heavily explored part of the
game AI area. Especially in RTS games, typical usage is to generate a pre-
optimised AI that can be shipped with the final build of the game. Genetic
Programming is a completely different form of machine learning; for complex
scenarios is can be very computationally expensive, and require a lot of
memory, but at the same time, can find alternative effective strategies in the
game that a heuristic-based system would not typically find (and maybe some
that a human player would not find). It is this that could give it an edge in
terms of creating human-competitive AIs.
SPECIFICATION
Requirements
For an effective evaluation, the tower defence game will need to be
implemented in such a way that the player can be easily substituted with an
AI script. The AI script must be external, such that it can be generated and
stored in a separate file, then read by the game and interpreted. The game
architecture must have a heavy emphasis on the command design pattern; the
best way for an external AI script to control the game is by allowing it to issue
game commands, similar to how network games are best played using
command packets that instruct the game about what the other player is doing.
Commands must be reasonably high level, and must be implemented in such
a way as that the AI generator can identify the fitness for each command;
basically how it influenced the game.
Since the game is progressive; that is, the effectiveness of any given
command depends on the commands given before it, fitness of a particular
command does not only rely on its immediate effect, but the effect on the
commands related to it (an example is if two towers are placed adjacent to
one another; both of their effectiveness will be raised significantly) – this
means that while designing the system for evaluating the fitness of a
particular command, other commands must also be taken into account,
otherwise evolution of particular command groups might break others
completely. It will be decided in the initial implementation stages how this is
to be handled; it could well be so that the nature of genetic programming
itself overcomes this problem, as lower scoring AIs in general have less
breeding opportunity and as such get “phased out”.
An important requirement of the system is that it can be left running
continuously and collect data about a series of games in succession. The entire
architecture will be designed with this in mind; the testing strategy for the AI
is to leave it running for as long as possible (probably overnight, every night
for as long as I have) to collect adequate data and allow for thorough analysis.
In terms of the data being collected, the best thing is to output to a
simple format such as CSV, that can be read by excel, and graph everything
for easier analysis. It will be built into the system that it will output data such
as an AI’s generation, game score, number of towers built, success of each
tower, etc. This data can be analysed by the GP system to create fitness values
for the AI itself and each of its commands, and it can be analysed to give a
comparison against the data collected from the human players.
Final Deliverables
-One implementation of the tower defence game program playable by
a human player
-One implementation of the tower defence game program playable by
an AI script
-A collection of generated AI script files that can be provided to the
game in order to watch the script play the game
-The raw data output from the program
-Final source code of the tower defence game program, including the
AI script generation code and the integration of the chosen GP system
-Report detailing analysis of results and project evaluation
Objectives
The main objective of the project is to provide a clear analysis and comparison
of game results for human players and GP-generated AI players after set
amounts of games. The goal of the project is to use this data to draw a
conclusion as to how the GP-generated AI compares to the player in terms of
learning speed, and final skill.
STRATEGY
Game and Engine Design
The game and engine design will be planned out, including the
technical design of the engine itself, the details of the game design (how it will
be played, specification of different tower types and enemy types, et al), how
the game code will integrate and communicate with the engine code, and how
the project specific code will fit in; that is, the AI script interpreter, the GP
system for generating AI scripts, and the data output system.
Engine Implementation
The game engine will be basic and specific; the main goal is to get it
implemented as quickly and efficiently as possible. C++ is to be used for
programming the entire system, but in order to cut down on development
time, the Simple DirectMedia Layer (SDL) library will be used for all drawing.
This is purely to cut down on development time; programming the game
directly using OpenGL or DirectX would introduce another level of
implementation which is not needed for the project, given the focus on the
genetic programming aspect. The actual engine implementation consists of
parts such as the object system (which will be kept simple, possibly
hierarchical)
Game Implementation
The game itself will be implemented after the engine is finished. First,
the basic game will be implemented for the human player, and will use a
command-based architecture to ease the integration of the AI script system.
After the implementation of the main game is complete, the project-specific
additions such as data output will be added, meaning that human-player
testing can be started whilst implementing the AI part of the system. An
integral part of the game implementation is that it should be able to start a
new game immediately after outputting the data from the last game.
Genetic Programming Implementation
Once the game is able to read and play an AI script (which will be
tested by recording a player’s game as a script and playing it back as a
replay), the chosen GP system will be integrated into the project.
Preparation for Data Gathering
The system will be tested to make sure no bugs are present that could
effect the results, and that the GP-generated AIs actually work. When the
game and AI generator have been finalised, the game will be modified so that
it can play in an infinite loop and output the data of each game, generating a
new AI in-between games and storing the old one along with its data.
Data Gathering and Analysis of Results
Data will be gathered from the system and the results analysed to
produce the final report. The data will be checked as it is collected to make
sure it is not erroneous, and any bugfixes or changes to the game system at
this point will require that the data gathering is started again, to ensure that
the data is valid.
SCHEDULE
Tabulated Project Schedule
The following is the preliminary project schedule, based on a 6 month
development period starting at the beginning of April and ending at the
beginning of October. This corresponds with the included Gantt chart. The
areas marked “basic engine implementation” and “basic game
implementation” refer to the basic systems implementation of each; i.e. basic
rendering and object systems for the engine example, and basic command
issuing and gameplay elements for the game example.
Project Schedule; Genetic Tower Defence
Duration
Tasks Start Date (Days)
Game and Engine Design 01/04/2009 21
Basic Systems Implementation 21/04/2009 7
Engine Implementation 28/04/2009 7
Basic Game Implementation 05/05/2009 21
Game Implementation 28/05/2009 21
Data Output Implementation 21/06/2009 4
AI Script Implementation 21/06/2009 7
Systems Testing 14/06/2009 28
Genetic Programming Integration 01/07/2009 21
AI Script Generation 21/07/2009 7
Preparation for Data Gathering 01/08/2009 10
Data Gathering 14/08/2009 28
Results Analysis 21/08/2009 28
Prototype Report and Evaluation 18/09/2009 12
Gantt Chart
BIBLIOGRAPHY
http://www.ercim.org/publication/Ercim_News/enw64/sipper.html
- Genetic Programming used for AI generation in Robocode
http://www.gamasutra.com/view/feature/1901/using_genetic_prog
ramming_to_.php
- Genetic Programming for a football game, including information about
implementation details and the use of a command based architecture
http://www.gamedev.net/reference/articles/article1175.asp
-Genetic Programming for Snake, including implementation tutorial; this is a
very specific implementation and I will not be using this style.
http://beagle.sourceforge.net/ ,
http://www.cs.ucl.ac.uk/staff/W.Langdon/ftp/weinbenner/gp.html
http://www.cs.nctu.edu.tw/~jylin/lagep/lagep.html
-GPC++, BEAGLE genetic programming library, LAGEP. These are all GP
systems that have already implemented the Genetic Programming specifics,
and can be used to implement the AI generator
http://towerdefencegames.com/ ,
http://www.handdrawngames.com/DesktopTD/Game.asp ,
http://en.wikipedia.org/wiki/Tower_defense
- Tower Defence type games. These can be investigated for game mechanics
research (although the actual game will likely be closer to something like
PixelJunk Monsters). Desktop Tower Defence is one of the best
implementations of the game, plus wikipedia link
http://www.cs.bgu.ac.il/~sipper/papabs/gpgames.pdf
-Paper on GP in games; mainly focuses on perfect information games; chess
and backgammon. Also has more information on Robocode plus specific
implementation information
http://www.gignews.com/gregjames1.htm
-Genetic algorithms in games which presents ideas about the use of genetic
style AI in RTS games, specifically StarCraft.
Genetic Programming IV, John R Koza et al (2003); book advocating
use of genetic programming in human-competitive machine learning AI
Genetic Programming, John R Koza (1992); book with information of
the grounding of genetic programming and its applications