I just finished reading Practical Game AI Programming: Unleash the power of Artificial Intelligence to your game. My conclusion is there is a lot less to this book than meets the eye.
For someone thinking of purchasing this book, it would be difficult to weigh that decision before committing. The above link to Amazon has (as of this writing) no reviews. I’ve not found any other, independent evaluations of this work. Perhaps you could make a decision simply by studying the synopsis of this book before you buy it. Having done that, it is possible that you’d be prepared for what it offered. Having read the book, and then going back and reading the Amazon summary (which is taken from the publisher’s website), I find that it more or less describes the book’s content. In my case, I picked this book up as part of a Humble Book Bundle, so it was something of an impulse buy. I didn’t dig too hard into the description and instead worked my way through the chapters with my only expectations being based on the title.
Even applying the highest level of pre-purchase scrutiny only gets you so far. The description may indicate that the subject matter is of interest, but it is still a marketing pitch. It gives you no idea of the quality of either the information or the presentation. Furthermore, I think someone got a little carried away with their marketing hype. The description also tosses out some technical terms (e.g. rete algorithm, forward chaining, pruning strategies) perhaps meant to dazzle the potential buyer with AI jargon. The problem is, these terms don’t even appear in the book, much less get demonstrated as a foundation for game programing. I feel that no matter how much upfront research you did before you bought, you’d come away feeling you got less than you bargained for.
What this book is not is a exploration of artificial intelligence as I have discussed that term previously on this website. This is not about machine learning or generic decision-making algorithms or (despite the buzz words) rule-engines. The book mentions applications like Chess only in passing. Instead, the term “AI” is used as a gamer might. It discusses a few tricks that a game programmer can use to make the supposedly-intelligent entities within a game appear to have, well, intelligence when encountered by the player.
The topic that it does cover does, in fact, have some merit. The focus is mostly on simple algorithms and minimal code required to create the impression of intelligent characters within a game. Some of the topics I found genuinely enlightening. The overarching emphasis on simplicity is also something makes sense for programmers to aspire to. There is no need to program a character to have a complex motivation if you can, with only a few lines of code, program him to appear to have such complex motivation. It is just that I’m not sure that these lessons qualify as “unleashing the power of Artificial Intelligence” by anyone’s definition.
But even before I got that far, my impression started off very bad. The writing in this book is rather poor, in terms of grammar, word usage, and content. In some cases, misused words become so jarring as to make it difficult to read through a page. Elsewhere, there will be several absolutely meaningless sentences strung together, perhaps acknowledging that a broader context is required but not knowing how to express it. At first, I didn’t think I was going to get very far into the book. After a chapter or so, however, reading became easier. Part of it may be my getting used to the “style,” if one can call it that. Part of it may also be that there is more “reaching” in the introductory and concluding sections but less when writing about concrete points.
I can’t say for sure but it is my guess, based on reading through the book, that the author does not use English as his primary language. I sometimes wondered if the text was written first in another language and then translated (or mistranslated, as the case may be) into English. Beyond that, the book also does not seem to have benefited from the work of a competent editor.
The structure of the chapters, for the most part, follows a pattern. A concept is introduced by showcasing some “classic” games with the desired behavior. Then some discussion about the principle is followed by coding example, almost always in Unity‘s C# development environment. This is often accompanied by screenshots of Unity’s graphics, either in development mode or in run-time. Most of the chapters, however, feel “padded.” Screenshots are sometimes repetitious. Presentation of the code is done incrementally, with each new addition requiring the re-printing of all of the sample code shown so far along with the new line or lines added in. By the end of the chapter, adding a concept might consist of two explanatory sentences, 3 screenshots, and two pages of sample code, 90% of which is identical to the sample code several pages earlier in the book. This is not efficient and I don’t think it is useful. It does drive the page count way up.
I want to offer a caveat for my review. This is the first book I’ve read from this publisher. When reading about some of their other titles, it was explained that the books come with sample source code. If you buy the book directly from the publisher’s website (which I did not), the sample code is supposed to be downloaded along with the book text. If you buy from a third party, they provide a way to register your purchase on the publisher’s site to get access to the downloads. I did not try this. If this book does have downloaded samples that can be loaded into Unity, and those samples are well-done, that has a potential for adding significant value over the book on its own.
Back to the chapters. When I start going through the chapters, again it feels like there is some “padding” going on to make the subject matter seem more extensive than it is. The book starts with two chapters on Finite State Machines FSM and how that logic can be used to drive an “AI” character’s reactions to the player. Then the book takes a detour into Unity’s support for a Finite State Machine implementation of animations, which has its own chapter. This is most irrelevant to the subject of game AI and also, likely, of little value if you’re not using Unity.
After the animation chapter, we head back into the AI world with a discussion of the A*, and the Theta* variant thereof, pathfinding algorithm. This discussion is accompanied by a manual optimization solution of a simple square-grid based 2D environment, describing each calculation and illustrating each step. I do appreciate the concrete example of the algorithm in action. Many explanations of this topic I’ve found on-line simply show code or pseudo-code and leave it to the “student” to figure it all out. In this case, I think he managed to drive the page count up by and order of magnitude over what would have been sufficient to explain it clearly.
The final chapters show how Unity’s colliders and raycasting can be used to implement both collision avoidance and vision/detection systems. These are two very similar problems involving reacting to other objects in the environment that, themselves, can move around. As I said earlier, there are some useful concepts here, particularly in emphasizing a “keep it simple” design philosophy. If you can use configurable attributes on your development tool’s existing physics system to do something, that’s much preferable to generating your own code base. That goes double if the perception for the end user is indistinguishable, one method from the other. However, I also get the feeling that I’m just being shown some pictures of simple Unity capabilities, rather than “unleashing the power of AI” in any meaningful sense.
A few year’s back, I was trying to solve a similar problem, but trying to be predictive about the intent of the other object. For example, if I want to plot an intercept vector to a moving target but that target is not, itself, moving at a constant rate or direction, I need a good bit more math than the raycasting and colliders provide out of the box. Given the promise of this book’s subject matter, that might be a problem I’d expect to find, perhaps in the next chapter.
Alas, after discussing the problem of visual detection involving both direction and obstacles, the book calls an end to its journey. With the exception of the A* algorithm, the AI solutions consist almost entirely of Unity 3D geometry calls.
Although the book claims to be written in a way such that each chapter can be applied to a wide range of games, I feel like it narrows its focus as it progresses. The targeted game is, and I struggle with how to describe it so I’ll just pick an example, the heirs to the DOOM legacy. By this, I mean games where the player progresses through a series of “levels” in order to complete the game. What the player encounters through those levels is imagined and created by the designer so as to construct the story of the game. The term AI, then, distinguishes between different kinds of encounters, at least as far as the player perceives them. For example, the player might find herself rushing across a bridge, which starts to collapse when they reach the middle. This requires no “AI.” There is simple programmed in that, when the player reaches a certain point on the bridge, call the “collapseBridge” routine. If she makes it past the bridge and into the next chamber, where there are a bunch of gremlins that want to do her in, the player starts considering the “AI” of those gremlins. Do they react to what the player does, adopting different tactics depending on her tactics? If so, she might praise the “AI.” By the books end, the focus is entirely on awareness of and reaction between mobile elements of a game which, by defining the problem as such, is the subset of games in this category.
My harping on the narrow focus of this book goes to the determination of its value. If this book were free or very low cost, you would have to decide whether the poor use of English and the style detract from whatever useful information is presented. The problem with that is the price this book asks. The hardcopy (paperback) of the book is $50.00. The ebook is $31.19 on Amazon, discounted to $28 if you buy directly from the publisher’s site. All of those seem like a lot of money, per my budget. Now, my own price I figure to have been $7. I bought the $8 bundle package over the $1 package purely based on interest in this title. This is the first book in that set I’ve read, so if some of the others are good, I might consider the cost to be even lower. Still, even at $5, I feel like I’ve been cheated a bit by the content of this book.
The bundle contained other books from this same publisher, so I’ll plan to read at least one other before drawing any conclusions about their whole library. Assuming that the quality of this book is, in fact, an outlier, this is still a risk to the publisher’s reputation. When one of your books is overpriced and oversold, the cautious buyer should assume that they are all overpriced and oversold. Looking at the publisher’s site, this book has nothing but positive reviews. It’s really a blemish on the publisher as a whole.
Although I won’t go so far as to say “I wish I hadn’t wasted the time I spent reading this,” I can’t imagine any purchaser for whom this title would be worth the money.