Review: Programming Game AI By Example by Mat Buckland

Programming Game AI By Example by Mat Buckland is one of those books that comes highly recommended and was one I had been meaning to read for a long time. In fact, I originally purchased the paperback in 2006 and never got around to reading it. The interesting part is that the book is still very much relevant today and is not dated in the least. Well now maybe some of the engines and middleware have this stuff built in, but the fundamentals I think I still important to understand.

The book starts with a quick primer on math and physics. The basics are explained, like Cartesian coordinates, trigonometry, vectors, coordinate spaces, and some physics. Like most people reading a book of this level, the beginning was a light refresher. However, I’m a big stickler for reading books from cover to cover with no skipping around, so I did not mind a short recap. Next Buckland gets into state-driven design and demonstrates a simple command-line app using the concepts. I found this approach successful, and it was able to show the concepts without complex 2D or 3D math getting in the way.

He followed up with autonomous moving agents, mostly based on steering behaviors. I was already somewhat familiar with steering behaviors, but I found the author’s description and code to be clear and concise and explained the concept better than I’ve seen before. He then applies the previous topics to a simple soccer game. This was a great next step, and really compiled the knowledge being taught into something concrete. In the next chapter, the author went into graphs; what they are, how to use them, and some popular algorithms link Dijkstra and A*. I always wanted to know what A* was, and this book explains it fairly well.

Buckland then devotes a section to cover scripting languages and why they are useful. In this case, he chose Lua (not a bad choice) and explains some basics about the language, how to interface it with C++, and creates a simple finite state machine. This chapter is helpful even if you’re not coding AI and just need a scripting language for your game or engine (provided you like Lua). In fact, a lot of the concepts in this book are generic enough that they can be applied to multiple fields of interest for game developers.

Next, the author creates a simple overhead game framework used in the subsequent examples. Using this framework he then shows practical path planning, goal driven agent behavior, and finishes up with fuzzy logic. Fuzzy logic is another one of those buzzwords that always intrigued me but I never really understood. Buckland concludes with a quite excellent explanation of the concept.

Overall I found this book to be stellar on all accounts. I feel that any game developer could gain insight from this text, even if they aren’t primarily working with AI programming. The scripting coverage could be used in many games, and the algorithms covered are generic enough to apply to different disciplines. While this is the first book I’ve read on AI, I really can’t imagine a better introduction. Highly recommended.