You might have noticed I've been using this blog as my answer file. Every post answers a complicated question that's too important to leave unanswered but too complicated to explain in casual conversation.
One question I run into is: "Don't you think we're moving toward special-purpose AI hardware, in the same way that the ATI and nVidia GPUs accelerate 3D graphics?"
This post explains why that will never happen, and why we should be happy that it won't.
1. There's no standard definition of "AI." It means something different in every game.
You can't make special-purpose hardware if you can't define what the special purpose is.
We've been able to achieve huge performance improvements with specialized graphics hardware because there's a set of very well-understood algorithms needed to transform, texture, light, and rasterize polygons. Everyone uses this same functionality for rasterized 3D graphics, and as a result, ATI and nVidia have been able to design GPUs to optimize that functionality.
The problem is, AI doesn't have any equivalent set of algorithms.
Instead, we have a big toolbox of techniques, and everyone uses different tools from the toolbox.
It's not because we're lazy or too stubborn to share our secrets with each other. It's because our games really are different and they have different needs.
Unlike 3D graphics and physics simulation, "AI" is not a well-defined problem. Depending on who you talk to, "AI" means anything from "creating entertaining and believable characters" to "simulating aspects of human intelligence" to "creating tools to let game designers design behaviors that meet the goals of the game design."
Imagine you get 5 AI programmers in a room together. One works on real-time strategy (RTS) games, one works on first-person shooter (FPS) games, one works on third-person God-of-War style melee action games, one works on 2D fighting games, and one works on basketball games.
The RTS programmer says, "I use influence mapping for strategic analysis." None of the other AI programmers use them.
The fighting game programmer says, "I have a lot of finite-state machines (FSMs) defining the animation systems for the characters in my game with lots of event-based communication between the FSMs so I can keep them in sync while they're fighting." The RTS, FPS, and basketball game programmer all hate FSMs and prefer to use behavior trees and planners.
The FPS AI programmer says, "I use A* on navigation meshes for pathfinding." The strategy game AI programmer says, "I use A*, too, but I use a grid, since that gives me random access to any cell in the grid, and I can get away with it because all the gameplay happens on a flat 2D plane." None of the other 3 AI programmers have pathfinding in their games at all.
The basketball game programmer explains that most of his work involves controlling entire teams of basketball players and getting them to understand the rules of basketball and the successful strategies in different situations and play the way a basketball team would. The RTS and FPS programmer also use squad-level AI, but in completely different ways. The 2D fighting game AI programmer doesn't have any need for it, and the third-person melee combat game programmer doesn't use it either since most of the enemies in his game are either zombies (who are too stupid to coordinate) or bosses (who the player fights alone).
There's no room for specialized hardware here. Any hardware-level optimizations that would improve performance for one kind of AI system would be useless in most of the other kinds of games.
2. Performance improvements in current-generation AI won't make a noticeable difference. The big innovations will require new game designs.
Game AI has been using 1-10% of CPU for the last few decades. As a result of that, we've been forced to adopt very fast algorithms for pathfinding and decision-making. There's not much room for improvement there.
Yes, in theory, we can make things like pathfinding, spatial analysis, planning, influence mapping, and behavior trees faster with special-purpose hardware.
In practice, these aspects of AI are not big issues anyway. A hardware accelerator card for pathfinding, for example, might let us use 3% of CPU instead of 5%. Any "accelerator" that only gives you 2% of your CPU back isn't worth the circuit boards it's printed on.
There's no doubt that in the long run, we're going to find all sorts of new applications for huge boosts in computing power. But for that to happen, the way we design games will have to change.
3. Bad AI rarely comes from a lack of computing power.
In cases where AI is broken, throwing more hardware at the problem isn't going to help the situation since it's addressing the wrong problem.
In every single case I've seen where a game had AI problems, the reasons had nothing to do with the hardware. Broken AI is almost always a result of bad engineering, bad design, bad planning, software problems (such as an underlying game engine that was too unstable to support productive AI development), or a lack of resources (not enough time in the schedule, not enough AI developers in the industry).
In general, there's very little correlation between the hardware platform and the quality of game AI. Some of the most powerful hardware has some of the worst game AI, and vice versa.
4. It's a chicken-and-egg problem. The hardware will never gain traction.
No one will buy an AI accelerator card unless games support the functionality they provide. No games are going to support the functionality of AI accelerator cards unless there's a big enough market for it.
Adding AI-related features. is expensive.
When ATI and nVidia add new graphics functionality to their video cards, it's (usually) possible to add support for that in your game without making major changes. In a lot of cases, a graphics programmer spend a few hours, days, or weeks tweaking the code to support the hardware features, and you can post "before" and "after" screenshots showing how much better your game looks with the new functionality.
That's not possible with AI. In order for AI functionality to be noticeable, you have to redesign your game to make those AI features visible. That's too expensive.
5. Even the graphics guys are moving away from special-purpose hardware.
Over time, graphics programmers have come to need ever more programmability from GPU hardware. Graphics chip vendors have felt the need to push for ever greater programmability to distinguish themselves from the competition.
Simultaneously, Moore's law has forced CPUs in the direction of parallelism. The PC, Xbox 360, and PS3 all now support different flavors of multicore computing.
These two trends may be starting to come together in an interesting way.
Intel's recently-announced Larrabee architecture seems to represent a very interesting convergence of the programmability of a CPU with the throughput performance of a next-generation GPU.
Current-generation GPUs are hard-wired for 3D rendering and can only be used for AI in some extremely rare situations. With Larrabee, it will be possible to run high-level AI code written in C++.
As I explained previously, there is no silver bullet. Most of the problems game AI developers face are related to planning, design, production, and software technology. Hardware won't help us too much with those issues. Also, the really big advances in game AI will take time, and they'll benefit the most from entirely new kinds of game designs that may be a long time coming.
But there's no denying that this approach to hardware opens up some very exciting new possibilities. Whether Larrabee itself is successful or not, this overall kind of approach is exactly what game AI developers need to open the door: a high-throughput, fully programmable, large-scale multicore system.
Posted by PaulT at August 11, 2008 09:56 AM | TrackBackIt would seem to me that another problem with AI acceleration is the lack of an acceptable fallback? Even if it worked, the card would basically become required. With graphics, if you didn't have the latest card, you'd just get fewer polygons, less realistic lighting, etc. The only time it affects gameplay is when you sometimes don't get the right kind of fog or something.
But with AI, you can't have a "stupider" mode for people without the card. You can't just have the NPCs bump into walls more often or something; it would significantly affect gameplay.
Posted by: ToastyKen at August 16, 2008 01:00 AMI think that certainly there can be hardware development for specific AI techniques. Neural networks, which come in handy for dynamic decision-making and adaptive responses are very slow on non parallelized hardware. On a many core system, the using large neural nets to determine npc behavior in rts or fps games could be possible, but special purpose neural network simulating hardware (or connections to biological networks?!!) could be utilized to create truly adaptive and unpredictable AI.
Posted by: Jeremy at August 16, 2008 01:21 AMYeah, I think that's somewhat covered point 3 ToastyKen, although I agree entirely on the fallback angle.
Graphics can get away with Anti Aliasing and texture options to improve visual quality easily on higher cards. What would AI have? "Shoot better"? "Find me more easily"? "Defeat me much faster"? - any option makes it a difficulty option, where as 95% of graphics options doesn't affect how hard a game is or the games design.
Also, since it uses the general CPU's AI can be given more CPU if really required by the game design, and on PC's the speed of CPU's are rapidly going up, with the low end increasing very fast as new PC's get sold.
Physics works too, but even that is of limited hardware usefulness and needs specific routines for little gain - and again, if the game requires the card, the gameplay is drastically changed.
AI is so limited but yet these claims of a AI card is banded around, I wonder why there isn't any plans for a "Scripting language card" (LUACard! PythonCard!) or "Unpacking Resources Card" (UnzipCard! LoadOffHDDFastCard!), or a "More Fun" card (CreateRainbowsCard! MagicFairyDustCard!), urg. :/
Posted by: Andrew at August 16, 2008 01:59 AMInteresting argument, though I think that it's a real chicken and egg problem. The thing is that some of the prinicples of AI haven't yet been found or understood. That is an issue completely independent of hardware. But let's imagine that one of the tens of thousands AI researchers out there finds an algorithm (can be on toilet paper if you are of the imaginative type) that makes, say, agent reasoning by a factor of ten better. Even if the computational cost of that algorithm may be 1000x higher than for the standard one, there might be a couple of games that reduce their number of other agents or features so far as to be able to let you have fun with 1 or two of these AI enemies on the exisiting hardware. As soon that turns out to be successful, probably with a couple of variation around it, other games might pick it up. Then its just a matter of time, first some of the components might pop up as additional software instructions for hardware devices and then later affect hardware design - as one of the 227 features hardware designers balance in their design.
Posted by: clemens at August 16, 2008 03:18 AMHa, Machine Learning accelerators would be really useful. Plus a lot of it is easy to do on the GPU or better hardware. To make ML accelerators really useful what you need to do is make more desktop application use ML. Every music player should be extracting features from music, every app should be monitoring the user to provide better than clippy kinds of suggestions. Ever file should be thoroughly indexed. Image files need to be parsed, segmented, feature extracted.
A lot of it could be done with extra hardware, but repurposing GPUs for K-NN etc might be a good motivator.
> [ANONYMOUS]
> Ha, Machine Learning accelerators would be really useful.
For machine learning accelerators to be useful for games, the industry would first have to use machine learning.
... Which it almost never does, for reasons that usually don't have anything to do with performance.
But that's a post for another day.
In any event, if game developers did use ML, that's actually another justification for the generalized multicore approach that systems like Larrabee use. There's no single accepted way to do machine learning. Those (very few) game developers who have used machine learning have all used different flavors of neural networks, genetic algorithms, simulated annealing, decision trees generated via ID3, and naive Bayesian classifiers.
Any theoretical fixed-function machine-learning hardware wouldn't be able to address all of those. Better to use general-purpose CPUs and let the developers pick the algorithms that suit them.
Posted by: PaulT at August 17, 2008 08:15 PM> [Jeremy]
> ... but special purpose neural network
> simulating hardware (or connections to
> biological networks?!!) could be utilized to
> create truly adaptive and unpredictable AI.
Creating unpredictable AI is already easy, and some games to have fairly unpredictable AI (Monolith's F.E.A.R. is probably one of the best examples of this; the AIs in Black & White are also unpredictable -- probably a bit too much).
Adaptive AI is a big topic that I hope to post more about in the future.
I think neural networks get way too much hype, though; neural nets are really best at recognition and classifications tasks -- i.e. the input side of AI rather than the behavior side -- which game AI usually doesn't have to worry about very much.
And when it comes to recognition and classification, there are usually far better ways to do it -- Support Vector Machines (SVMs) in particular are the current cutting edge of classification.
Neural nets tend to be extremely unpredictable and difficult (if not impossible) to understand, debug, and test. Very few games have used them successfully, and those that have, probably could have done what they did much more easily with other techniques.
When it comes to adaptive AI, the most successful implementation I'm aware of is the ID3-based decision tree classifier in Black & White (see http://www.gameai.com/blackandwhite.html for more info). Decision trees have many advantages: generating them is fast and easy, and the resulting decision tree can be evaluated quickly and is easy to understand.
Posted by: PaulT at August 17, 2008 09:26 PMTotally agree with you Paul.
It's also worth pointing out that hardware is gradually moving away from specialised solutions as it becomes clear that utilising multiple high-throughput chips is the way to go since clockspeed has reached a ceiling - everything ends up looking rather like a GPU anyway. This will force us to look at ways to parallelise general routines (rather than specialised ones such as the 3D pipeline) to work well on things like Larrabee or the PS3 in the future if we want to use the power available.
So, even if the AI techniques could be defined enough to be put into hardware it wouldn't be worth making a card for it as the multi-multi-core cpu/gpu will work better anyway.
Posted by: Matthew Wiggins at August 18, 2008 04:00 PM"Never" is a very long time. AI processing may not be a well-defined space now, but that doesn't mean it won't be in a few decades' time...
Posted by: website designs at August 19, 2008 08:43 AM> [Matthew Wiggins]
> So, even if the AI techniques could be defined
> enough to be put into hardware it wouldn't be
> worth making a card for it as the multi
> multi-core cpu/gpu will work better anyway.
Thanks, Matthew! Great insight.
Posted by: PaulT at August 19, 2008 10:46 AM