bit-tech.net - How AI in Games Works

magerette

Hedgewitch
Joined
October 18, 2006
Messages
7,834
UK tech site bit-tech.net has a geeky in depth look at the nuts and bolts of AI in gaming, from the basics of the state machine to how it functions in NPC view and pathfinding in terrain, destructible environments, and how it's affected by hardware acceleration.
Here's a bit from the conclusion about where it's headed in future:
AI is clearly becoming much more important in games, but it still has to compete with pretty graphics when it comes to processing resources, and it’s often at the bottom of the pile.

Creative Assembly’s Richard Bull notes that "there’s still this disturbing mindset among programmers, particularly game programmers, that if the AI is taking any kind of considerable chunk of time, that’s a really bad thing. It’s only just getting to the stage now where people regard it as important enough to deserve this chunk of time in a game. If your graphics rendering is taking up 50 percent of your CPU time it’s like 'well, never mind, it looks great', but if you try to tell people that you have this really intelligent decision-making system that’s taking up 30 percent of the CPU time, they’ll say 'you obviously don’t know what you’re doing, it’s badly programmed' and so on".

However, with GPU hardware support and multithreading becoming more widespread, hopefully, we’ll see AI using a greater amount of resources. Just take a look at your CPU resources when you’re running Fallout 3 or GTA IV, and you’ll see that your CPU is being hammered. Anything that can provide game developers with more AI processing power will be warmly welcomed by the gaming industry, and we can then progress to even more sophisticated AI systems.
More information.
 
Joined
Oct 18, 2006
Messages
7,834
Man, I really hope this movement takes off. I've been saying for years that AI is the great, untapped potential in gaming and has remained so largely due to the obsession in the industry with eye candy and, in the RPG genre, over-sized worlds. *crosses fingers*
 
Joined
Oct 18, 2006
Messages
850
Location
CA, USA
Interesting read for me. I've been working in fields vaguely related to AI (data mining and some dabbling with machine learning), but I dont have much knowledge of game AIs outside "simple" games like chess.

The first page has a good point (that cant be stressed enough) in that game AI:s are all about appearing intelligent rather than actual intelligence. It's Turing "intelligence" we want rather than intelligence as defined by the encyclopedia.

Using some sort of machine learning to tune AI behaviour in real time is quite far off though. Such methods essentially rely on statistical power, and a single player simply cant put in enough playtime to give enough data points for that to work without serious overtraining issues (overtraining is when you optimise your model to fit a few data points that arent representative)...

I'm not that pessimistic about the computational demands. AI uses much less data than graphics, and if GPUs become more flexible devices that can be tapped for generic programming tasks then it should be possible to offload much of the AI computations onto them.
 
Joined
Nov 4, 2006
Messages
2,013
I would like AI to be not only about making the enemy more difficult. It should encompass all points. For example, if one dude sees your group coming, it should decide he can't take on you and go look for friends (not as a scripted event). Also, when enemy is wounded, maybe they should decide to run away instead of standing there waiting for you to finish them.
 
Joined
Sep 23, 2008
Messages
5,645
Location
Tardis
Using some sort of machine learning to tune AI behaviour in real time is quite far off though. Such methods essentially rely on statistical power, and a single player simply cant put in enough playtime to give enough data points for that to work without serious overtraining issues (overtraining is when you optimise your model to fit a few data points that arent representative)...
I don't think that's what they meant. I think they meant collecting data points from many players and updating the thinking of the AI based on that. Not necessarily on the fly, but in an incremental fashion akin to patches. For example, they could collect data from the thousands of on-line players of DoWII, crunch the numbers, and then release an AI patch 2 months post-live that improves/expands the AI based on what was learned from real players.

I'm not that pessimistic about the computational demands. AI uses much less data than graphics, and if GPUs become more flexible devices that can be tapped for generic programming tasks then it should be possible to offload much of the AI computations onto them.
I'm not so sure. It's not so much the data as the assessing of the world's current state, traversing the branching decision logic, weighing of the alternatives, and the making decisions. Multiplied by how many ever entites you have performing this "thinking" at any one time. Even just a few hundred NPC's/units/whatever doing this every second is a LOT of demand on a CPU.

@wolfing: absolutely. The possibilities for complex behavior from an improved AI are staggering. Think about playing an RPG one day that challenges you in a way similar to a real life Game/Dungeon Master. :cool: Obviously, we won't live to see the day computers approximate human thinking. But the gap between what games are doing now with AI and what a human opponent can do is so huge, there is immense opportunity for improvement.
 
Joined
Oct 18, 2006
Messages
850
Location
CA, USA
But in many cases isn't "intelligent AI" nothing more than "lemming AI" and not really intelligent as we know it - in extreme cases it can even be nothing more than "padding AI"

For me, sporadic, scenario-reactionary, incident-tendency or best of all specific scenario generated AI routines tend to pull players into a higher level of gaming immersion and greater reality, it is the repetitious element in AI structures that are off-putting.

There is still a long way to go before intelligent AI becomes "reactionary" intelligent.
 
Joined
Oct 18, 2006
Messages
1,105
Location
North-West England
Using some sort of machine learning to tune AI behaviour in real time is quite far off though. Such methods essentially rely on statistical power, and a single player simply cant put in enough playtime to give enough data points for that to work without serious overtraining issues (overtraining is when you optimise your model to fit a few data points that arent representative)...

Could work in MMORPG's though. Lots of players, lots of data points.
 
Joined
Oct 19, 2006
Messages
8,540
By the way, there's one game that does AI IMO extremely well: Dwarf Fortress. I don't think it's technically particularly fancy -- a state machine with a goal engine just like described in the article -- but it's very rich in states, including a great many that bring those bearded little buggers alive -- emotional states, for example.

For example, you might issue an order to kill the kittens that have been overbreeding in the fortress, but then the dwarf who gets the task might get so smitten by the kitten it's taking to the butcher to be turned into kitty-burger that he adopts it instead. And if the kitten gets subsequently killed, the dwarf will get upset about it. If he's already stressed-out, he might even fly into a rage and break stuff or even assault other dwarves. The dwarves make friends, get into spats with each other, fall in love, get married, have children, adopt pets, have preferences about the kinds of foods, drinks, and minerals they like or dislike, some dwarves might enjoy working outside while others prefer to stay underground, some enjoy fighting while others enjoy quieter pursuits and so on. And all this is reflected in their behavior.
 
Joined
Oct 19, 2006
Messages
8,540
This article seems not have a word about dialogs/talks. My bet is that there's just no attempt about it in gaming.

About a state machine with many states or parameters the problem is more the design of each state and consequences than its programming.
 
Joined
Oct 14, 2007
Messages
3,258
By the way, there's one game that does AI IMO extremely well: Dwarf Fortress. [...]

While that is formally "AI", it would be much more impressive if the computer could play by the same rules as you and be a challenge. I mean, to draw an analogy, in a RTS, it is almost trivial to program your units to return fire, seek cover and otherwise react, but it's much harder to make the opposing computer player use actual tactics. So yes, Dwarf Fortress is impressive enough, but it's not the end-all - the dwarves just have lots of options open and the smarts to seek cover food when needed.
 
Joined
Oct 23, 2006
Messages
585
Location
Serbia
Of course DF is not the end-all. However, it is an example of a novel and creative way to use AI to give depth to the game. If all it had was really smart combat AI, I kinda doubt too many people would bother to play it.
 
Joined
Oct 19, 2006
Messages
8,540
The interesting thing about AI, is that the most efficient and "hard" AI is usually the simplest one - whilst the more human-like behaviour tends to be much easier to defeat, because it deals with too many factors to effectively correlate them all.

Even if they some day succeeded in emulating human intelligence, they'd still need to make it an efficient gamer. That's quite a feat - and people tend to forget that while a child is typically a very easy opponent in a complex strategy game, the child is still infinitely more intelligent than any AI we'll see for years and years.

Then again, some people are impressed simply with a range of actions - like in Dwarf Fortress - because simply having different reactions to situations can appear "human" in nature. But only if those actions have some kind of intelligent motivator and long-term plan, would they actually mirror something like that which is happening in the human mind.

So, I think perception of AI is also a problem.

With all that, I believe Galactic Civilizations (1 and 2) is known for its multi-threaded and sophisticated AI. I haven't personally gotten into that game, but I wonder if it's as good as I've been hearing.
 
Back
Top Bottom