文件名称:Artificial.Intelligence.for.Games
文件大小:5.26MB
文件格式:PDF
更新时间:2013-08-15 16:10:05
Artificial.Intelligence.for.Games
Two memories stand out in my career writing game AI. The first takes place in a dingy computer lab on the top floor of the computer science building at Birmingham University in the UK. Although I am half-way through the first year of my Artificial Intelligence degree, I’ve only been in the department for a couple of weeks after transferring from a Mathematics major. Catching up on a semester of work is, unexpectedly, great fun, and there are a great bunch of fellow students eager to help me learn about Expert Systems, Natural Language Processing, Philosophy of Mind, and the Prolog programming language. One of my fellow students has written a simple text-based adventure game in Prolog. I’m not new to game programming—I was part of the 8-bit bedroom coding scene through my teenage years, and by this time had written more than ten games myself. But this simple game completely captivates my attention. It is the first time I’ve seen a finite state machine in action. There is an Ogre, who can be asleep, dozing, distracted, or angry. And you can control his emotions through hiding, playing a flute, or stealing his dinner. All thoughts of assignment deadlines are thrown to the wind, and a day later I have my own game in C written with this new technique. It is a mind-altering experience, taking me to an entirely new understanding of what is possible. The enemies I’d always coded were stuck following fixed paths, or waited until the player came close before homing right in. In the FSM I saw the prospect of modeling complex emotional states, triggers, and behaviors. And I knew Game AI is what I wanted to do. The second memory is more than ten years later. Using some technology developed to simulate military tactics, I have founded a company called Mindlathe, dedicated to providing artificial intelligence middleware to games and other real-time applications. It is more than two years into development, and we are well into the process of converting prototypes and legacy code into a robust AI engine. I am working on the steering system; producing a formation motion plug-in. On screen I have a team of eight robots wandering through a landscape of trees. Using techniques in this book, they are staying roughly in formation, while avoiding collisions and taking the easiest route through more difficult terrain. The idea occurred to me to combine this with an existing demo we had of characters using safe-tactical locations to hide in. With a few lines of code I had the formation locked xxxi xxxii Preface to tactical locations. Rather than robots trying to stay in a V formation, they tried to stick to safe locations, moving forward only if they would otherwise get left behind. Immediately the result was striking: the robots dashed between cover points, moving one at a time, so the whole group made steady progress through the forest, but each individual stayed in cover as long as possible. Thememory stays with me, not because of that idea, but because it was the fastest and most striking example of something I had seen many times: that incredibly realistic results can be gained from intelligently combining very simple algorithms. Both memories, along with many years of experience have taught me that, with a good toolbox of simple AI techniques, you can build stunningly realistic game characters. Characters with behaviors that would take far longer to code directly, and would be far less flexible to changing needs and player tactics. This book is an outworking of that experience. It doesn’t tell you how to build a sophisticated AI from the ground up. It gives you a huge range of simple (and not so simple) AI techniques that can be endlessly combined, re-used, and parameterized to generate almost any character behavior that you can conceive. This is the way I, and most of the developers I know, build game AI. Those who do it long-hand each time are a dying breed. As development budgets soar, as companies get more risk averse, and as technology development costs need to be spread over more titles; having a reliable toolkit of tried-and-tested techniques is the only sane choice. I hope you’ll find an inspiring palette of techniques in this book that will keep you in realistic characters for decades to come.