Okay, So let's stick into something that it's way more fascinating than just making you know, bad guys shoot straight in games, we're talking about artificial intelligence, but specifically in games, that kind of hidden intelligence that makes the world's feel alive.
Rights, the stuff making characters seem like they're thinking or moving believably.
Exactly, and sometimes, let's be honest, it leads to those glitches that are just hilariously memorable.
Yeah, it's that invisible layer, isn't it, ye, shaping so much of how you experience the game, making it feel reactive, not just static.
Totally, and to really get our heads around how it all works. We've gathered a whole stack of material. We're talking algorithms, techniques, some history. It's pretty deep stuff.
You can get technical.
Yeah, but our mission here for this deep dive is to sort of cut through that jargon. We want to find the really cool, important ideas and give you listening now a short tut to understanding what's going on behind.
The scenes, like lifting the curtain a bit, Yeah.
Uncover some surprises, maybe have a few aha moments along the way.
So think of it like getting a peek under the hood, looking at the simulated brains, making everything tick, your opponents, your allies, even the whole world sometimes.
Okay, so where do we start. The sources actually bring up an interesting point about the history. Back in the mid nineties, AI was actually like a selling point on the back of the box.
Oh yeah, I remember that era. Beneath a Steel Sky is a good example.
Right, It promised virtual theater. What was that supposed to be?
Well, the idea, the ambition was for characters who weren't just puppets. They'd move around, do their own thing, make the world feel lived in. Virtual theater. Sounded grand, but the reality, the reality is the sources kind of point out was maybe a bit less revolutionary. Often it just met characters pacing back and forth on pretty fixed paths. Still, it was an early.
Attempt, a bit underwhelming then maybe, But then something came along that really shifted things, didn't it, gold enneye double O seven.
Yeah, that was definitely a game changer for a lot of people's perception of AI.
What did it do differently?
It wasn't just pre programmed patterns. I mean, yes, the guards us simple state machines, that's true, But the key thing was this basic sense simulation.
They added sense simulation.
Yeah, characters could essentially see their buddies. If one guard saw another get taken out, they'd react, maybe investigate, maybe raise the alarm. It wasn't super complex, but that idea of awareness of perceiving the world a change things big time, and that whole concept simulating senses, site, sound, it became absolutely central to stealth games.
Later on, like Thief or Metal Here sawid.
Exactly Thief, Metal Gear, splinter Cell. The core gameplay loop often revolves around exploiting or avoiding the AI senses how guards react to a noise or a shadow or seeing something suspicious.
So this points to a fundamental cycle that seems to run through all the material we looked.
At pretty much. Yeah, you can boil a lot of it down to perception leads to decision making, which leads to action.
Per section decision action.
Okay, the AI gathers info for the world, decides what to do about it, and then actually does something, move, shoots, hides, talks.
Whatever, right, and to actually do those actions. Especially back then, developers were always fighting against hardware limits, weren't they.
Oh, absolutely huge constraint. Early days, you had maybe one CPU doing everything. Now we've got multiple cores, powerful GPUs.
PPUs are more for graphics though.
Mostly Yeah, they're built for massively parallel stuff, tons of simple calculations at once, which is perfect for graphics, but it does influence AI. Sometimes. If you can break an AI task into lots of small independent bits, maybe you can leverage the GPU. But CPUs are still king for that complex, sequential thinking part of AI.
So it's always a trade off performance versus complexity.
Always has been, always will being gamed of.
And it's not just consoles and PCs anymore. You've got phones, tablets, iOS, Android, AI has to run everywhere.
Now, Yeah, the rise of mobile is huge, and that's where engines like Unreal, Unity, godot are so important. They provide this layer of this framework.
So you can write the AI once.
Pretty much, write at once, deploy it on PC, console, mobile, maybe with some tweaks, but the core logic can often be reused. That definitely shapes how you design the AI systems in the first place.
Okay, so keeping that cycle in mind, perception, decision, action, and let's talk about the action bit, specifically movement. How do AI characters actually you know, get around because unless it's maybe an economic sim they need to move.
Movement's fundamental. Yeah, an AI character has a position, maybe an orientation, physical properties. Yeah, and the movement algorithms figure out frame by frame where they need to go next to reach their goal.
But you don't want them just snapping between locations. Right, has to look physical exactly.
That's where kinematics comes in. It's basically applying physics Newton's laws. Really, even in a simple way. Velocity can't change instantly right inertia. Yeah, So the algorithms don't teleport the character. They consider its current speed and direction and use acceleration to make the movement smooth and believable. No instance stops or starts.
And the sources talk about these things called steering behaviors like building blocks for a movement.
They are think of them as simple reactive urges. Seek tells a character to move towards a target. Flea tells it to run away. Very basic, but you build on those, you combine them. So pursue isn't just seek. It tries to predict where a moving target will be and seeks that point. Collision avoidant steers away from obstacles. Often these more complex behaviors work by delegating to the simpler ones seek the target, but also flee from that wall that's getting too close.
The material mentioned a potential issue with a simple wander behavior, something about rotational jerkiness. What does that look like?
Imagine a character just randomly picking a new direction every single frame. They kind of twitch and spin around unnaturally. It looks terrible. Uh so simple wander needs smoothing. Maybe you pick a random point on a circle slightly ahead of the character and steer towards that. Updating it less frequently makes it look more like they're meandering, not having a seizure.
Gotcha. So steering handles the how of moving smoothly, But how does the AI figure out the where? Especially in a big complex level. That sounds like pathfinding.
That's exactly what pathfinding is for finding a route a sequence of steps from point A to point B that avoids opticles like walls, pits, whatever the level design are put in the way.
It's the how do I get there from here? Problem? Precisely the source of mentioned classic algorithms Dykstra's algorithm. I think I remember that from a computer science class.
Yeah, dykstras is fundamental graph theory, it's guaranteed to find the absolute shortest path from your start point to every other reachable point in the graph, representing.
The level every other point.
That sounds like a lot, it can be, and that's the catch. For games. Usually you only care about the past to one specific goal. Calculating the shortest path to everywhere else is often effort.
So games tend to use a more A.
Star A is generally the go to. Yeah. Yeah, it's smarter about searching, how so it uses a heuristic think of it as an educated guess or a rule of thumb to estimate the distance remaining to.
The goal, like as the crow flies distance.
Often yeah, or Manhattan distance. In grid based worlds, Igelegan combines the actual cost traveled so far with this estimated future cost. This lets to prioritize exploring paths that seem to be heading more directly towards the goal.
Ah, so it doesn't waste time exploring paths that are clearly going the wrong way, even if they look short initially.
Exactly, it focuses the search, makes it much faster than Diikstra in most typical game scenarios. Now there's a small trade off mentioned. Oh, if you're heuristic, your guess is bad. Specifically, if it overestimates the actual cost to the goal, then a might not find the absolute mathematically shortest path. It might find a path that looks shorter based on the bad gas.
So developers might accept a path that's like ninety nine percent optimal if it means the calculation is way faster.
That's the aha moment right there, exactly. Performance often trump's perfect optimality. In real time games, good enough, fast enough is often the.
Mantra makes sense. So for A or diestra to even work, they need a map, right, but not the full three D graphics geometry.
Where they need a simplified representation of the navigable space. You can't search through raw triangles.
Like navigation meshes. I've heard that.
Term nav meshes are super common. They basically represent all the walkable surfaces as a set of connected polygons like piles on the floor. The AI path finds across these polygons.
How does that work with the algorithm? Are the polygons the nodes?
Sometimes the center of the polygons, but often it's the edges between the polygons. The edges as nodes approach is mentioned. Path finding becomes finding a sequence of edges to cross to get from the starting polygon to the goal polygon.
Okay, but what about huge open worlds. Those nav meshes must get enormous.
They do, and that's where hierarchy pathfinding comes into play. Layers kind of you group areas together, like maybe this whole building is one high level note and that neighborhood is another. The AI first finds a path between these big regions, like planning a trip using major highways. Then once it enters a region, it does a more detailed pathfind within that smaller area, figuring out the local streets.
That seems way more manutable. Okay, so characters can move realistically with steering, and they can find paths with pathfinding, But how do they decide decide where to go, whether to fight or hide or talk. That's the decision making part of the.
Cycle, right, This is the core intelligence, the brain making the choices. It determines what the character intends to do.
The sources mentioned decision trees as a common technique, simple if thin stuff.
Pretty much, they're like flow charts, a series of questions usually yes no, leading down branches to an action is the enemy visible? Yes? Do I have AMMO? Yes?
Shoot?
No reload back up the tree is the endy visible? No patrol.
They sound fast and easy for designers to work with.
They are very fast, execute, modular, easy to build and tweak, use for tons of stuff from simple reactions to choose the animations.
What about state machines those seem classic too.
Finite state machines yeah, FSMs. You define distinct states. The AI can be in patrolling, investigating, attacking, fleeing, and transitions between them. If you're patrolling and you hear a noise, the transition condition you switch to the investigating state.
Sounds neat, but maybe it gets messy. If you have lots of states.
It can become a spaghetti diagram really quickly if you're not careful, lots of arrows criss crossing. That's why higer Arsenill state machines.
Were developed, so states within states exactly.
Your combat state might contain substates like taking cover, firing, reloading. It helps organize complexity, and you can have transitions that jump across levels, like a sudden loud noise pulling you out of reloading right back to a top level alert state.
Now The material really highlights behavior trees as being super popular. Now, what's the deal with them?
Behavior trees are very powerful and crusely very intuitive for designers. They structure tasks in a tree like way. The AI executes the tree usually depth first, trying branches until it finds an action or sequence that succeeds.
Can you give an example?
Sure, a root node might be engage enemy. It has children like is enemy visible? If yes, it goes down the attack branch. If no, it tries the search for enemy branch, which might have subtasks like go to last known position, then scan area. It feels logical, like how a person might approach a problem.
Again, they're reusable, hugely reusable.
You create nodes for common actions, move to play, animation, check condition, and assemble them into trees. You can make a complex take cover behavior and just drop it into different AI characters. Trees engines often have visual editors like Lego for.
AI like al prefabs.
Okay, that makes sense exactly that concept.
Are there other ways? The sources mention things like utility based systems. Yeah, goal oriented behavior.
Yeah, those are a different philosophy instead of pre defined logic flows. The AI has goals or motives hunger, thirst, safety, curiosity, each with a current insistence level.
How much it wants it.
Basically, yeah, the AI looks at all the actions it could do and evaluates how well each action would satisfy its most insistent needs. It picks the action that leads to the lowest overall discontentment.
Sounds more adaptive, maybe less predictable, it can be.
The big challenge is often calculating the utility of an action. How much will eating this apple reduce my hunger? How long will it take to pathfind to the apple? Often requires good estimation heuristics.
Again, seems complex to set up right.
It can be more work up front than say, a state machine. Rule based systems are another alternative mentioned, using if then rules like if player is visible and health is low, then find cover. But writing good comprehensive rule sets is really hard.
The knowledge acquisition bottleneck they called it.
Right, So while powerful in theory, they're less common in practice for moment to moment character AI compared to trees or state machines.
Okay, individual decisions covered. What about coordinating groups or making bigger strategic plans?
Yeah, moving beyond single characters, that's tactical and strategic. AI tactical is about local coordination soldiers using cover fire, flanking maneuvers. Strategic is the big picture, deciding which continent to invade in a global strategy game, or managing an economy in an RTS.
For tactics, the sources mention tactical waypoints, not just points to walk to, but points with extra info.
Exactly, a waypoint might be tagged as good cover spot versus north or ambush point, but just relying on static points placed by a designer has limits. What if the situation changes.
So run time analysis.
Yeah, better systems analyze the environment dynamically, calculating lines of sight, checking actual cover effectiveness based on where the enemies are right now.
The frag maps idea sounded cool learning from where players die.
It's a neat example of simple tactical learning. Basically, areas on the map build up a danger value. If AI units keep getting killed there, future AI might then learn to avoid those spots or be more cautious.
But they need to unlearn it too, right, so they don't avoid a place forever after one unlucky death.
Exactly, a decay factor or unlearning bias is important and.
For strategy, Like in an RTS, how does the AI decide whether to build more units or research tech.
Often with multi tiered AI, you have layers. A top level strategic layer makes broad decisions we need more resource income or prepare for an attack on their.
Base, and that gets passed down right.
A mid level tactical layer might translate attack their base into a simple strikeforce alpha A coordinates x y and proceed along route Z. Then the lowest level AI, the individual unit AI, handles the actual movement in shooting based on those orders.
So the player is often the top strategic layer in an RTS.
In many cases, yes, the player sets the goals and the AI executes the details, though some games have high level AI opponents making strategic choices.
Too, and tactical pathfinding came up again. Path cost isn't just distance, right.
It's about the quality of the path caxically speaking. Is it exposed to enemy fire? Does it offer good ambush opportunities? A path might be longer but much safer, so tactical pathfinding would prefer it.
Okay, The big one learning Can game AI actually learn like you know? Learn learn?
The sources definitely cover learning, but with a crucial caveat for games, the goal isn't just effective AI. It's AI that results in good gameplay. An AI that learns an unbeatable exploit isn't fun.
That's a really important distinction. So what kinds of learning do they use?
Some simple stuff like parameter modification basically tweaking numbers like if the AI keeps losing, maybe slightly increase its accuracy. Parameter uses optimization techniques like kill climbing. Then there's action prediction, trying to guess what the player will do next based on past behavior using techniques like n grams.
And reinforcement learning. That's the hot top AI. Generally trial and error.
Exactly the AI tries ashs, gets rewards or penalties from the game, find treasure, reward, fall in lava, penalty, and learns over time which actions lead to good outcomes in different situations or states. Q learning is a common example mentioned.
What's the challenge there? For games?
Defining the state? Real game worlds are incredibly complex and continuous. Trying to break down every possible situation, player, position, enemy health, ammial count, time of day into discrete states for the algorithm can be really.
Hard and neural networks. Deep learning.
Neural nets are powerful pattern recognizers. They learn by adjusting connections between artificial neurons. They were used historically in things like checkers programs or td GAMIN for evaluating board positions. Deep blue used complex evaluation, possibly including n ends.
But are they used for deciding if a guard should open a door?
Less so, according to the sources, for general character behavior logic, things like behavior trees are often more press tactical, easier to design, debug and control. Neural nets are great for specific tasks like image recognition or maybe complex evaluation, but maybe overkill or too inch of a black box for typical moment to moment decisions.
Right now, So, traditional methods are still really dominant for a lot of character AI for.
The actual decision logic very much so. The complexity, data needs and training time for deep learning for general flexible character behavior are still pretty significant hurdles compared to more established techniques.
Okay, wow, so we've got movement, pathfinding, decisions, tactics, strategy, even learning. How does all this stuff actually run inside the game, and how does the AI even know what's happening in the world. This is the.
Plumbing right exactly, The implementation details Yeah, super important. First off, scheduling, you might have hundreds of AI characters. You can't afford to run every single AI calculation for every character every single frame. Your game would grind to a halt.
So you need to manage who thinks.
When precisely you schedule AI updates. Maybe important enemies nearby update every frame, but background characters only update every few seconds or when something relevant happens. High archo of scheduling helps manage this complexity.
And anytime algorithms what are they?
Those clever algorithms design so you can interrupt them part way through their calculation and they can still give you a usable, even if not perfect result.
Ah. So the AI doesn't just freeze for three seconds while it calculates the perfect path exactly.
You can get a rough path, quickly, start moving, and maybe refine the path in the background if it gets more processing time later. Avoids that deer in headlights.
Lack that can level of detail for AI similar to graphics.
Yep, same principle. AI complexity scales with importance usually distance faraway AI runs simpler logic, closer AI runs the full simulation. Behavior Compression is mentioned as a way to smoothly transition between these levels. So the change is in jarring.
Okay, how does the AI get its info? How does it perceive the world state?
Good question. The simplest way is polling. The AI just asked the game can I see the player? Is there a wall in front of me? Whenever it needs to know?
Sounds simple, but maybe slow if everyone's asking all the.
Time, it doesn't scale well exactly. Imagine hundreds of AIS constantly querying the world state. Very inefficient.
So what's better?
The event passing is much more common in complex games. The game generates events sound created at location X, player spotted by camera, Y, door Z opened. There's usually a central manager, oh, like a dispatcher, Yeah, an event manager. AI components listen or subscribe to events they care about. When an event happens, the manager notifies only the relevant listeners. Much cleaner, more modular, easier to debug.
That makes way more sense, and.
This ties back nicely to the sophisticated sense management we talked about earlier. Simulating how information actually propagates.
Not just line of sight sound, bouncing, smell.
Exactly, using sense graphs or similar structures to model how a sound travels around corners gets muffled by walls. Maybe how a smell lingers or travels with airflow. That's how you get really deep stealth gameplay. The AI isn't cheating, it's reacting to information propagated through a simulated sensory system.
That's how a guard hears you from another room.
Maybe right, they didn't see you, but the sound event reached their ears through the sense graph. Triggering an investigate state adds huge depth.
Okay, last piece, Maybe the tools developers aren't just writing C plus plus for everything right. Designers need ways to interact with this stuff.
Oh, tools are absolutely critical. Level designers need to place path finding nodes, or to find clever points or paint areas the AI should avoid. AI designers need ways to build and tune behaviors.
Can some of that be automated, like generating the navmesh?
Some can, Yes, initial navmesh generation is often automatic, but designers almost always need tools to tweak it, fix errors, add metadata like this area is dangerous and for behavior.
Logic, visual editors like for behavior trees exactly.
Visual editors for state machines or behavior trees are invaluable. They led designers who might not be hardcore programmers build complex AI logic visually. Tools like Behavior Designer were mentioned, and scripting languages are huge too, Lua, Python custom languages allowing rapid iteration on specific character behaviors.
Gotcha, Okay, we've gone through the whole pipeline. Basically, how does this all come together? In specific game genres?
Quick examples sure shooters heavy on movement pathfinding for complex levels decision making often behavior trees or state machines for combat logic like flanking using cover and robust perception systems are key. Think Halo's AI using behavior trees or Golden eyed early sense simulation. Driving games big focus on movement AI obviously sophisticated steering behaviors for realistic car handling, collision avoidance, drafting, racing lines.
Artist games must be in Nightmare.
They're definitely demanding large scale pathfinding for potentially hundreds of units, group movement, streetrategic decision making AI for base building and resource management, tactical AI for unit formations and battles, lots of layers, lots of units to manage efficiently.
And then some games are about the AI.
Yeah. AI center genres, creature training games maybe using neural nets, or reinforcement learning or simulation games where the core is an ecosystem driven by AI agents following rules, maybe a food chain where player interaction is about influencing that system.
Wow. Okay, so we've really covered a lot of ground, from basic movement back in the nineties all the.
Way to complex layered decisions, tactical reasoning, learning systems, and the nitty gritty of how it's implemented.
We've kind of peeled back the layers on that hidden intelligence. Yeah, that perception, decision action loop, how characters navigate, how they choose what to do.
Hopefully you've got a much clearer picture now of the smarts and the engineering that goes into making game characters feel believable or challenging or sometimes just playing alive.
Yeah, it's definitely not just simple scripting most of the time. It's some serious computer science and clever design work.
Absolutely hopefully gives you a new appreciation next time you play.
Okay, so here's something for you to chew on listening right now. Think about a game you've played recently, an enemy that felt really smart, or maybe an NPC that did something unexpected but believable.
Base on what we talked about. What techniques do you think might be driving that behavior? Was it reacting to sound because of sense simulation? Did it seem to follow a logical plan maybe from a behavior tree?
Could you see hints of prioritize steering when it dodged while still trying to get somewhere, or maybe hierarchical pathfinding letting it cross a huge map without getting lost.
What kind of Aha moment might you be having right now about how that character actually worked. Next time you play Keep an Ear Out, Keep an Eye Out, you might start noticing the subtle signs of the AI mind at work. It's fascinating stuff once you know what to look for.
