On the subject of Artificial Intelligence (AI) a lot has been written within the context of academic research. But for the industry of (video) games, a proper, structured and complete work on how well known game studios ‘do AI’ in their best-selling commercial titles has been missing for ages. I believe that Ian Millington’s book “AI for Games” gives you a very good insight into the normally hidden world of AI programming common practices for commercial (video) games.
In this third edition of “AI for Games”, the author Ian Millington has added even more content, like for example a full chapter on procedural content generation. The author gives a good representation of how AI is approached and handled in the game industry, without being in subjective favor of a specific implementation language or certain algorithm approaches. He just tells you how programmers from good selling video game titles have found effective ways to tackle common AI problems like movement, decision making, strategy and learning.
Academic versus game AI
On one end, there’s a great distinction between academic AI and AI for games. For example, when I myself work with generating Artificial Intelligence models for Marketing Automation at large corporate clients, I have a wide array of academic data science and machine learning models and techniques and tools available. Within a research setting environment, it is a viable option for me to code and construct AI-solutions that easily take hours of computational time and may consume vast amounts of disk space and internal memory.
But for the AI you want in games, you want the agents (characters) to make decisions fast: you are hugely constrained by code execution time (1/60th of a second) and by the memory limit of regular consumer hardware (like smartphones or budget laptops). The trick of the trade is to make the AI in your game make look smart enough to be able to slightly outwit the player in most of the cases. So game AI is a matter of perception, rather than arriving at the best, but complex, solution to the problem the AI has to solve.
On another end, as a reader, I felt greatly familiar with the concepts originating from the academic world when going through the chapters on Techniques. There’s a great similarity with Stuart Russell’s and Peter Norvig’s academic book “Artificial Intelligence: A Modern Approach”, and for a reason! Behavior trees, Naïve Bayes classifiers, Deep Learning, Representation systems and Learning mechanisms… I have seen that before in another setting!
The last chapter called ‘AI Based Game Genres’ has the most direct link with true academic AI, with the remark that most video games don’t require this topic on teaching (game) characters. For most games, like shooters, racers, sports, role playing games and real time strategy, teaching can be reduced to just learning not to fall into the same player-set trap repeatedly.
The objective of the game AI you will implement in your game is to keep it simple, easy to tweak and debug. A Nobel Prize for coming up with a complex but innovative AI solution for your video game is definitely not needed, if you want to succeed in creating a challenging game with virtual agents.
Content and subject matter
I found myself reading the book in the following order: Part I, then Part III (Supporting Technologies), back to Part II (Technologies) and finally Part IV (Designing Game AI). Reading in this order helped me a lot to understand the main concepts of “AI for Games” and read through the pages while keeping enough connection with my own progress of implementing AI in the webgame ‘GeekTrains’ that I’m developing. I would suggest you to read the parts in more or less this order.
For me, the AI engine model and the supporting technologies were the most important new discoveries to take from this book: “How do I implement AI in a good and definite, constructive way into my game?” I then take the list of techniques from Part II, iteratively select feasible techniques and with that continuously upgrade the AI system that I am building. Before my game AI can become ‘smart enough’, I have to become smarter and more experienced as well by implementing the pseudo code. Creating a good enough challenge for your players that fits your specific game is something that evolves over time.
What I like about Millington approach is that he repeatedly dissects the Techniques into common attributes: A description and application of the technique (including the problem it is trying to solve), some pseudo-code for the technique, data structures and implementation notes. Also each time the performance and the ability to ‘debug’ the technique is mentioned. Furthermore, as the chapters progress, most techniques can be stacked upon the next one, as if it were a more advanced and complex solution for the former. So you can really start easy, and gradually build up the complexity of your AI until it reaches a level of satisfaction.
In the book, lots of (black and white) images and illustrations are found, that quickly make clear what the problem is that a certain technique is trying to cover, and how the proposed solution works in visual concept. There’s also some math to be found – mostly 2D, but also some algebra for 3D vector computations. Though a reader doesn’t need to know too much about mathematics, as long as you known how to translate a pseudo code command into the specific programming language or game engine you are using (e.g. what is the function name for computing a dot product of 2 vectors).
Milligton gives you the core architecture for your game AI engine in the second chapter called ‘Game AI’. When you make sure that you cover each component of this core architecture by implementing at least some of the techniques from the book, you’ll do more than fine at being a successful AI programmer.
From study to practice
You’ll definitely need to practice the learned material for a year or so, in my opinion. Well, maybe “AI for Games” core concepts fits into a college course semester of 3 or 6 months? There’s some exercises in the book as well for you to do. But either way, if you really want to get acquainted with making AI for your game, practice makes your player’s perception of the AI you create perfect enough.
The funny thing is that in the perception of your player, when you ask them, players think that tactics and strategy is the part to focus on in order to create challenging AI. But in truth, the agent’s intelligence (or stupidity) is mainly revealed to the player while moving around (or physically getting stuck) in the game world. The moving around part is more often than not the most challenging part to code from an AI programming perspective.
Perhaps this is something for you as a reader to take advantage of. When you are learning your game agents to make proper decisions based on their perception of the game world, you are learning yourself about the perception the game player has when seeing the game AI at work during gameplay.
Trying out techniques, tweaking its parameters, and discovering what works, until your AI engine becomes smart enough without bogging down on the framerate or committing to much on memory requirements. Do this in co-operation with the level designers, who can embed way- and data points in the level to be used by the game AI.
I am very happy to have read the 3rd edition of “AI for Games” by Ian Millington. I have been doubting over another book title or two, and I have also stumbled upon lots of fragmented works on the topic of developing Artificial Intelligence solutions in games. But with over a thousand valuable and worthwhile pages, “AI for Games” does give you the most complete and up to date insights and learnings on Artificial Intelligence for (video) games, without compromising on choosing a specific implementation language or being too subjective in favor of certain techniques.
Over Quintus Hegie
Econometrist en informaticus Quintus C. Hegie, MSc heeft een tiental jaar praktische ervaring met data gedreven digitale marketing in de financiële branche. Zijn vertrekpunt bij het ondersteunen van bedrijven met hun marketing afdeling is steeds de gedragingen en overtuigingen van de eindklant beter te leren begrijpen.