How does AI work, and is it really AI?

+
So this is an honest question, I've done a little bit of coding in my time but I'm by no means a programmer. A couple of buddies and I tried to build a conversation algorithm at school (long, long ago like qbasic long ago) it fooled my little sister into believing that the computer was sentient but mainly it was just a complicated array and some if-else statements.
I was wondering how much of computer game npc behaviour is procedural and how much (if any) is actually artificial intelligence or machine learning?
 
So this is an honest question, I've done a little bit of coding in my time but I'm by no means a programmer. A couple of buddies and I tried to build a conversation algorithm at school (long, long ago like qbasic long ago) it fooled my little sister into believing that the computer was sentient but mainly it was just a complicated array and some if-else statements.
I was wondering how much of computer game npc behaviour is procedural and how much (if any) is actually artificial intelligence or machine learning?

None of it is AI.

Simply put - true AI doesn't exist anywhere in the world as of this moment. At least, not publicly.

It's all scripted. Some games push the limit to the point where it almost feels like AI but the illusion breaks down the second you throw something at it for which it wasn't scripted.

Furthermore, the hardware required for true AI is still far, very far, out of reach of the home computer.

Personally, I doubt we'll get to see an actual true AI within the decade but that's just my opinion.
 
"AI" in basically any game is always some form of state machine.
Behavior trees seems to be still the current state of the Art...

While there are some smaller games that try to go a bit outside of that with things like swarm intelligence and hive minds (and nowadays maybe some form of machine learning), a game that employs such techniques for enemy AI has to build it's game mechanics around that.

There seems to be no currently known way of doing it the other way around, i.e. training some machine learning algorithm to work with the mechanics of a given game.

There are SOME successes in employing machine learning in StarCraft and Leage of Legends (by google), but it still has severe limitations:
Only 17 of the heroes in Leage of Legends can be played by the ai or it's opponent.
And while in both games the AI can beat top players, it struggles against opponents in lower ranks (because of their less optimal playstyle which it is not accustomed to). The starcraft one can even be exploited consistently with strategies that would fail against a true pro.

And just because we are on the topic of game AI already:
It is totally possible to build an AI that will beat each and every human player, just by exploiting the internal information of a game.
But that is akin to playing against someone with wallhacks, aimbots and the reaction time of a machine. Hardly any fun...
So the actual challenge for AI in games is to be bad enough that the players can win, but good enough so they don't feel like a pushover.
Very difficult to balance, and totally different from just building the perfect AI. It's a desing problem, not a technical one.
 
Last edited:
AI is any system designed to mimic or give the illusion of intelligent behavior. From that standpoint, yes there is AI in the game.

From the standpoint of games released in the past and the level of intelligent behavior gamers have come to expect in modern game titles? Uh...not so much.
 
Depends.

If you're looking for the kind of AI that actively 'think' ,adapt , learn and use whatever tactics available in order to beat you, then no, and it's unnecessary because games will become unbeatable .

For example, in a FPS, human players always exploit the AI's lack of ability to adapt and use the environment accordingly. You simply KNOW that particular npc is not going to look this way and if you kill him quietly, none of his buddies will ever notice.

What if that particular AI suddenly decides to randomly look around and told his buddies to radio check every 3 minutes?

IF the AI becomes really clever, it'd disable your controls . lol
 
Last edited:
From the standpoint of games released in the past and the level of intelligent behavior gamers have come to expect in modern game titles? Uh...not so much.
This feels a bit off-topic, but I have seen this claim countless times by now, and I just have to ask:
How on earth can you come to this conclusion?

I grant you, the AI sometimes bugs out, and enemies are standing around like idiots while you shoot them down...
But otherwise it's working great: The enemies will flank and circle you, flush you out of cover with grenades and go into hiding if you kill their buddies. They make use of cover and even tactically switch between it.
They seem to have trouble with avoiding grenades, but sometimes they do, so it is probaby just a bit buggy in certain areas.
It's nothing revolutionary, but nothing to be ashamed of either...

The only reason I can see you would make that claim is by mistaking traffic, crowd movements and pathing for AI.
Which - hint hint - they are not. All three are covered by very basic algorithms. Some games put additional AI on top of these systems, but that is EXTREMELY rare. Off the top of my head I only know three games that did this to any noticeable degree: GTA V, RDR2 and Left 4 Dead.

So, please enlighten me, how do you come to this conclusion? What is so sub-par about cyberpunks AI? Where are all these games which supposedly set such a hight standard that cyberpunk is unable to reach it?
 
This feels a bit off-topic, but I have seen this claim countless times by now, and I just have to ask:
How on earth can you come to this conclusion?

I grant you, the AI sometimes bugs out, and enemies are standing around like idiots while you shoot them down...
But otherwise it's working great: The enemies will flank and circle you, flush you out of cover with grenades and go into hiding if you kill their buddies. They make use of cover and even tactically switch between it.
They seem to have trouble with avoiding grenades, but sometimes they do, so it is probaby just a bit buggy in certain areas.
It's nothing revolutionary, but nothing to be ashamed of either...

The only reason I can see you would make that claim is by mistaking traffic, crowd movements and pathing for AI.
Which - hint hint - they are not. All three are covered by very basic algorithms. Some games put additional AI on top of these systems, but that is EXTREMELY rare. Off the top of my head I only know three games that did this to any noticeable degree: GTA V, RDR2 and Left 4 Dead.

So, please enlighten me, how do you come to this conclusion? What is so sub-par about cyberpunks AI? Where are all these games which supposedly set such a hight standard that cyberpunk is unable to reach it?
I have some experience in this. "AI" encompasses all kinds of algorithmic processes that include action that appears to be intelligent...from pathing & crowd movement to combat strategy, to dialog selection. In fact, all intelligent action can be pared down in the end to search problems. It's not sexy, but AI is at its core just searching complex search spaces for usable solutions. There is nothing "magic" about AI, it's all just algorithms.

When you see everybody on screen squats in unison when a gun is fired, or a vehicle stops due to an obstable in the street and waits forever until the obstacle is removed, or spawns police right behind you that do nothing but instantly try to kill you, that is a failure of algorithms to find usable (e.g. "plausible") solutions to the search space...which in this case is making the player feel like he/she is in a real world.

That's how I can say that. :)
 
First on topic:
If op (or anyone reading this) is really interested in a more deep introduction, I think this article does well:

In general, if you want to learn about how games are built, gamedev.net will keep you occupied for years ;)
It's not really focused on AAA next-gen games though, so not everything on there is how the "true professionals" would do it.
For that you need to buy a few books, like "Game AI Pro" or the very excellent "Game Programming Gems". More than a bit outdated nowadays though ;)

"AI" encompasses all kinds of algorithmic processes that include action that appears to be intelligent...from pathing & crowd movement to combat strategy
That seems to be the rub, doesn't it?
While I can agree with that definition, it renders the term "AI" useless as a judgeable category.

Yeah, the crowd simulation is not very advanced. But that is not the main point of interaction in this game.
Saying cyberpunks AI sucks because of crowds is like saying Skyrims physics sucks because of its skyfloating npcs:
It's impact on actual gameplay is so little that it can hardly outweigh the nicely working parts.

You say nothing about enemy AI, which kinda proves my point: The one system you interact with THE MOST, and you can't even find a single refutation of my points.

I think I am just a bit upset about the overgeneralization:
The combat AI in this game is totally on par with games like Half-Life 2, Call of Duty or Metal Gear Solid.
As I said, nothing revolutionary, but nothing to be ashamed about either.
Disregarding all of cyberpunks AI as "bad" feels to me like saying the AI in all games apart from the last 2 years sucks.
Which is simply not true...
 
Wow thanks for all the responses! To be honest I hadn't realised that the npc were all decision tree based and I was starting to wonder whether there was more to it. I guess the trees must be pretty complex.
If op (or anyone reading this) is really interested in a more deep introduction, I think this article does well:

I'll definitely read the article!
In a nutshell out doesn't sound like things have really moved on that far from my attempt all those years ago. If the chat algorithm couldn't work out your statement, the last line of code was something along the lines of "Oh my is that the time, lovely to chat, bye bye! " which I suppose is the equivalent of crouching in plain sight.

If you're looking for the kind of AI that actively 'think' ,adapt , learn and use whatever tactics available in order to beat you, then no, and it's unnecessary because games will become unbeatable .

I don't know, I think it would be pretty cool to have a game where the enemy learnt from your tactics as you progressed through different missions. There have been so many games over the years where the I've either kited or kettled bots because it was the easiest way to get through the level. Not thinking machine learning in a multiplayer setting, you'd just end up with a spawn fragging sniper 😉 I definitely understand the point about integrating fun and challenge.

But bots that change up their tactics and actually set up a crossfire or an ambush would be a fun challenge, especially if they don't fall for the same ploy more than twice.


So next question. Are the decision trees object based like a style sheet where each npc could have a different set of variables (fight/ flight type responses etc) or are they more like a self contained nested If statement with a set of outcomes? Just wondering because there's been a lot of talk about how difficult it would be to change the behaviour of vehicles or the npcs like they're set in stone as part of the engine. It struck me as unlikely as I thought code nowadays was much more object oriented precisely so elements could be replaced or tweaked without rewriting whole sections. I imagine one missing parentheses still kills everything though!
Post automatically merged:

First on topic:
If op (or anyone reading this) is really interested in a more deep introduction, I think this article does well:

In general, if you want to learn about how games are built, gamedev.net will keep you occupied for years ;)
It's not really focused on AAA next-gen games though, so not everything on there is how the "true professionals" would do it.
For that you need to buy a few books, like "Game AI Pro" or the very excellent "Game Programming Gems". More than a bit outdated nowadays though ;)


That seems to be the rub, doesn't it?
While I can agree with that definition, it renders the term "AI" useless as a judgeable category.

Yeah, the crowd simulation is not very advanced. But that is not the main point of interaction in this game.
Saying cyberpunks AI sucks because of crowds is like saying Skyrims physics sucks because of its skyfloating npcs:
It's impact on actual gameplay is so little that it can hardly outweigh the nicely working parts.

You say nothing about enemy AI, which kinda proves my point: The one system you interact with THE MOST, and you can't even find a single refutation of my points.

I think I am just a bit upset about the overgeneralization:
The combat AI in this game is totally on par with games like Half-Life 2, Call of Duty or Metal Gear Solid.
As I said, nothing revolutionary, but nothing to be ashamed about either.
Disregarding all of cyberpunks AI as "bad" feels to me like saying the AI in all games apart from the last 2 years sucks.
Which is simply not true...
Just read that article, thank you so much!
 
Last edited:
So this is an honest question, I've done a little bit of coding in my time but I'm by no means a programmer. A couple of buddies and I tried to build a conversation algorithm at school (long, long ago like qbasic long ago) it fooled my little sister into believing that the computer was sentient but mainly it was just a complicated array and some if-else statements.
I was wondering how much of computer game npc behaviour is procedural and how much (if any) is actually artificial intelligence or machine learning?
Fairly sure its the same basic idea, it's all controlled by a behavior tree.
 
First on topic:
If op (or anyone reading this) is really interested in a more deep introduction, I think this article does well:

In general, if you want to learn about how games are built, gamedev.net will keep you occupied for years ;)
It's not really focused on AAA next-gen games though, so not everything on there is how the "true professionals" would do it.
For that you need to buy a few books, like "Game AI Pro" or the very excellent "Game Programming Gems". More than a bit outdated nowadays though ;)


That seems to be the rub, doesn't it?
While I can agree with that definition, it renders the term "AI" useless as a judgeable category.

Yeah, the crowd simulation is not very advanced. But that is not the main point of interaction in this game.
Saying cyberpunks AI sucks because of crowds is like saying Skyrims physics sucks because of its skyfloating npcs:
It's impact on actual gameplay is so little that it can hardly outweigh the nicely working parts.

You say nothing about enemy AI, which kinda proves my point: The one system you interact with THE MOST, and you can't even find a single refutation of my points.

I think I am just a bit upset about the overgeneralization:
The combat AI in this game is totally on par with games like Half-Life 2, Call of Duty or Metal Gear Solid.
As I said, nothing revolutionary, but nothing to be ashamed about either.
Disregarding all of cyberpunks AI as "bad" feels to me like saying the AI in all games apart from the last 2 years sucks.
Which is simply not true...
Well, accept the definition or not, that is the definition of AI. You can *never* know if a system is intelligent or not, you can only know the degree to which it appears intelligent. You can't even know if another human being is intelligent, you can only know how they behave. This is the whole reason behind the Turing test -- if a system can fool you into believing it's another human being, then you have to accept that it's as intelliigent as a human, regardless of whether it really is, because the answer to that is unknowable.

I'd contend the only reason that combat is the system you interact with more in the game than any other is that it's the only system with any real dynamism. And I disagree that enemies are "smart" in the game. They have only a few basic tricks: charge forward, duck behind cover and pop off an occasional shot, or chuck a grenade. That's really about it.

If you want smart combat AI, you have hard to predict behavior like enemies that run off down a side street, making you think they have fled, only to have them go around the block and attack you from another side. That can never happen in this game partially because of the limited tactical responses and partially because of terrible pathing. The AI would just get stuck somewhere if it tried this. As is I can totally predict what's about to happen in a fight, because they only have 3-5 options in their behavior.

The reason you focus on combat is that's the best AI in the game, and it's still very bad. I'd say if the non-combat NPCs were interesting, could engage in real conversations and have interesting interactions, we'd all find that at least as compelling as combat. If you could sit at a vendor's food stall, chat him up, and him remember you next time, eventually start telling you personal details about his life, and eventually maybe even give you a mission or two, how amazing would that be? Or if you could talk to an NPC in the street, make some witty banter, and then have them back to your apartment for a roll in the hay?

None of the above is impossible or even that difficult, it just requires some clever work on the part of the game designers. Then we'd feel like we were in a real living city instead of a large stage where we just wander from one fight to the next.

To answer another question in this thread, I don't think there is any machine learning involved. Machine learning involves emergent behavior, meaning the system gets better at a task over time through "training" (meaning iteratively trying tasks over and over with different behaviors to find more optimal solutions to a problem). The enemies don't learn or do anything new over time, the systems are all very static. It's possible that some behavioral training was done on the front end to get to those static strategies, but if that's the case I can say without hesitation that the system needed way more training or better objective functions (the definition of what a "good solution" looks like).
 
Last edited:
Depends.

If you're looking for the kind of AI that actively 'think' ,adapt , learn and use whatever tactics available in order to beat you, then no, and it's unnecessary because games will become unbeatable .

For example, in a FPS, human players always exploit the AI's lack of ability to adapt and use the environment accordingly. You simply KNOW that particular npc is not going to look this way and if you kill him quietly, none of his buddies will ever notice.

What if that particular AI suddenly decides to randomly look around and told his buddies to radio check every 3 minutes?

IF the AI becomes really clever, it'd disable your controls . lol
Agree with this, competent AI would just roll over player leading to massive rage quits, so it has to be not too stupid not too smart
 
In games, AI is just a decision maker tree, or you can call a behavior tree, for example.

AI - Listen / See /Smell, sense the player, and now they start the decision making, could be something like.
First, Player is enemy or friendly, in case of friendly, use random talk or face, in case of enemy start combat tree.
The combat tree is more complex, AI can interact with others NPC´s to coordinate attacks, find cover, change ammo/weapons etc... this all is a branch of a big tree and the steps of this tree keep repeating, for example.
NPC state combat, in cover? No, repeat, find cover, in cover? yes, go to next action, shoot, keep repeating this for X time, find new cover, in cover? yes, shoot, and so on...
But a good combat AI will take in consideration a lot of stuff, what weapon the player is using, flank the player, cover fire etc...
A good behavior tree is something that takes time to make, i see once the behavior tree from The Division, that thing was HUGE, really, i think they have 1000x or more conditions there.
 
There are ways to train AI agents (like NPCs) to whatever level of competence you want to achieve. It's just behavioral optimization over trial and error, it takes a lot of trials (like hundreds of thousands or millions). The big problem you have is that you can't really train them against humans, it would take way too long, so you have to train them against bots you design with static behaviors.

Then you can train to specific scenarios like "player hides behind cover and refuses to come out" or player throws a grenade." You develop competent strategies against each one, then you make bots that combine strategies and retrain your AI agents against the bots that are mixing strategies (like the player might). Now your AI are already good at individual scenarios, you are re-training them to adapt tactics.

This can lead to very interesting and surprising AI behavior, but it's time consuming and difficult and most game companies would rather write scripted tactics because that is way easier.

I'm kind of surprised nobody is doing this kind of robust and adaptive AI agents, and just selling it as a toolkit to developers for their games, kind of like JALI. Or maybe there are products like that and I just don't know about them.
 
I'm kind of surprised nobody is doing this kind of robust and adaptive AI agents, and just selling it as a toolkit to developers for their games, kind of like JALI. Or maybe there are products like that and I just don't know about them.

It's the cost, mainly. Training an AI like the Starcraft playing Alphastar cost millions of dollars and the AI itself is highly sensitive to any changes to the game(like patches). Also most game AI's are really just supposed to be punching bags for the players powertrip, so fighting the perfect AI opponent wouldn't be much fun anyways.
 
So this is an honest question, I've done a little bit of coding in my time but I'm by no means a programmer. A couple of buddies and I tried to build a conversation algorithm at school (long, long ago like qbasic long ago) it fooled my little sister into believing that the computer was sentient but mainly it was just a complicated array and some if-else statements.
I was wondering how much of computer game npc behaviour is procedural and how much (if any) is actually artificial intelligence or machine learning?
There's no actual hard AI in this or any other current commercial game.

Of course, the meaning of AI is debatable; in the days when I was CEO of an AI company we always talked about automated inference rather than artificial intelligence, since our systems did/do logical reasoning and human beings don't/can\t. These days pattern matching in huge data sets is also included in what is called 'artificial intelligence', and that is a bit more like what human brains actually do, but there isn't any of that in modern games, either.

True artificial intelligence is very hard. Furthermore, when you look in detail at what any software system is doing, it ends up looking pretty procedural. Even an inference engine is using procedures to determine which rules to choose to process next, and how to apply those rules to the data available.

What intelligence ultimately boils down to is making reasonable decisions given uncertain information. A game engine never has to do that; it has total, perfect information about the current state of the game world at all times. The only thing that's uncertain from the game engine's point of view is what the player will decide to do next; but, while that's a really interesting problem in games like Chess and Go, it isn't really a problem at all in CRPGs or first person shooters.

So no. Games generally don't have AI. Techniques learned from AI could be beneficial in making NPCs behave more like real people, and I'd really like to see that done; but NPCs in almost all modern games are basically clockwork automata, running on pre-determined rails, with little or no actual agency. But hard AI in games? No. Apart from Chess and Go (and a small subset of mostly highly abstract games like that), it isn't there, and it isn't there because it wouldn't actually be very useful.
 
There's no actual hard AI in this or any other current commercial game.

Of course, the meaning of AI is debatable; in the days when I was CEO of an AI company we always talked about automated inference rather than artificial intelligence, since our systems did/do logical reasoning and human beings don't/can\t. These days pattern matching in huge data sets is also included in what is called 'artificial intelligence', and that is a bit more like what human brains actually do, but there isn't any of that in modern games, either.

True artificial intelligence is very hard. Furthermore, when you look in detail at what any software system is doing, it ends up looking pretty procedural. Even an inference engine is using procedures to determine which rules to choose to process next, and how to apply those rules to the data available.

What intelligence ultimately boils down to is making reasonable decisions given uncertain information. A game engine never has to do that; it has total, perfect information about the current state of the game world at all times. The only thing that's uncertain from the game engine's point of view is what the player will decide to do next; but, while that's a really interesting problem in games like Chess and Go, it isn't really a problem at all in CRPGs or first person shooters.

So no. Games generally don't have AI. Techniques learned from AI could be beneficial in making NPCs behave more like real people, and I'd really like to see that done; but NPCs in almost all modern games are basically clockwork automata, running on pre-determined rails, with little or no actual agency. But hard AI in games? No. Apart from Chess and Go (and a small subset of mostly highly abstract games like that), it isn't there, and it isn't there because it wouldn't actually be very useful.
I've just been reminded of the 2016 grants for CP2077 and the living cities application sounds like they started with a similar idea.
"Comprehensive technology for the creation of 'live' cities of great scale playable in real-time, which is based on the principles of artificial intelligence and automation, and takes into account the development of innovative processes and tools supporting the creation of high-quality games with open worlds."

Read more: https://www.tweaktown.com/news/7304...cs-will-have-unique-daily-routines/index.html

Surely the processing power required would be truly immense. I can understand how console or a home PC could handle a room full of npc bots in combat or how it deals with Total War style empire management using decision trees and procedures but managing a whole city seems very ambitious.

Surely an online game hosted by a server farm somewhere would be required to implement the kind of npc behaviour that would be necessary to have the 1000 unique individuals carrying out their daily lives? I'd love to see it done though.
I'm kind of surprised nobody is doing this kind of robust and adaptive AI agents, and just selling it as a toolkit to developers for their games, kind of like JALI. Or maybe there are products like that and I just don't know about them.
Maybe that should be your next project, sounds like a winner to me!
 
None of it is AI.

Simply put - true AI doesn't exist anywhere in the world as of this moment. At least, not publicly.

It's all scripted. Some games push the limit to the point where it almost feels like AI but the illusion breaks down the second you throw something at it for which it wasn't scripted.

Furthermore, the hardware required for true AI is still far, very far, out of reach of the home computer.

Personally, I doubt we'll get to see an actual true AI within the decade but that's just my opinion.
ai exists, but it isn't used in games. But yes they have AI that they feed loads of data and it solves problems by its own means.
 
None of it is AI.

Simply put - true AI doesn't exist anywhere in the world as of this moment. At least, not publicly.

It's all scripted. Some games push the limit to the point where it almost feels like AI but the illusion breaks down the second you throw something at it for which it wasn't scripted.

Furthermore, the hardware required for true AI is still far, very far, out of reach of the home computer.

Personally, I doubt we'll get to see an actual true AI within the decade but that's just my opinion.

AlphaGo is a computer program that plays the board game Go. It was developed by DeepMind.
IT beat the best player of Go Lee Se-dol 4 1.
That happened in 2016.
 
Last edited:
Wrong.
AlphaGo is a computer program that plays the board game Go. It was developed by DeepMind.
IT beat the best player of Go Lee Se-dol 4 1.
That happened in 2016.
I'm surprised more people don't know about AlphaStar, the AI that plays Starcraft 2 in the 0.5% of Grandmaster players. The limitation is computational power required to train the AI's.
 
Top Bottom