Game AI engineering is a hard to define subject. A group I am a part of had a recent discussion about what we should be teaching the future generations of budding AI engineers, and there were various propositions flying around for potential “curriculums”. Ultimately there can be no “right” solution, but here I will share with you my views on the subject.
90% of Game AI is A*
My co-blogger Luke Dicken recently wrote about the differences between game AI and traditional AI, and brought up this obvious point. There are many very neat algorithms that we use in AI, but A* is the big one. I should give a quick shout out to finite state machines and behaviour trees which have treated me well over the years – I’ll even concede that planners (like GOAP) have a place in game AI – but A* is used by every pathfinding system I have ever seen, and has other applications besides that.
To say A* is 90% of Game AI though is like saying a house is 90% bricks. What’s missing is the finesse. Creating interesting game AI is about identifying interesting problems to solve and coming up with novel ways to solve them. When I interview someone for an AI engineering position I don’t ask about their understanding of existing techniques – that’s what Google is for – I identify whether or not they have the desire to assess a situation and break down what needs to happen either to make the AI more fun or more intelligent.
Make It Fun
A lot of discussion about AI ignores this fact: The difference between academic AI and game AI is that we’re trying to make a game fun. The intelligence exhibited by NPCs in most games is inferred by their actions to make the game fun for the player, not actually codified by some extremely intelligent system.
A colleague and I came up with a list of “Three Laws of AI” a few years ago:
- Make it fun.
- Make it not stupid, so long as it doesn’t break #1.
- Make mistakes, so long as it doesn’t break #1 or #2.
Notice that intelligence is never actually mentioned here. Making an AI “not stupid” is extremely important for a believable experience. You could have the best looking graphics engine, the best physics simulation, beautiful voice acting and writing, but the second an AI character grinds into a wall or shoots himself in the foot with a rocket the illusion is broken. Making mistakes is also important; humans are fallible and to enhance the realism of an AI they should be too.
So how do you make something fun? Well that’s a loaded question. What is fun depends on the audience: it might be an immersive AI that makes you believe they are truly alien, or human, it might be an RTS AI that simulates the greatest Korean players, it might be a driving AI that rubber bands to keep you constantly fighting for first place, etc.
Play Games, and Be Good
Ultimately the best way to know how to make a game fun is to play other games, and identify what is or is not fun about them. It sounds simple, but in this day and age of zoning out in front of an Xbox for two hours playing the latest AAA hit, you frequently will ask someone why they found a game enjoyable and they’ll reply “err the graphics were good”. Of course that’s not what makes a game fun; sorry graphics engineers. Sit down and play the same encounter fifty times, then tell me if you know why it’s fun.
And actually you don’t really have to be good, but it helps to understand what makes someone good at games. Writing AI you are trying to get into the mindset of the NPC, and it is imperative that you understand movement in space and what is a “good” decision to make. In an FPS game if I am low on health I try to minimize the distance I need to travel to break line of sight with a target. I don’t go for a specifically tagged piece of cover; I just try and get anything I can between me and my attacker.
Game AI engineering, in my admittedly biased view, is the single feature that makes a good game great. It’s what makes the experience immersive, and makes you want to come back for more of the experience. To encourage new AI engineers we need to be careful what we are teaching them. It’s not enough to know the algorithms, you have to gain an understanding.