Jump to content

What is Game AI?

Ezio Auditore

Is AI in the game nothing but a series of daisy chained if loops (I am not a programmer). Also as AI if loops are daisy chained , is that why a gpu can't process it as efficiently as a processor?

Please quote me so that I know that you have replied unless it is my own topic.

Link to comment
Share on other sites

Link to post
Share on other sites

15 hours ago, Ezio Auditore said:

Is AI in the game nothing but a series of daisy chained if loops (I am not a programmer). Also as AI if loops are daisy chained , is that why a gpu can't process it as efficiently as a processor?

There are a number of types of AI used in games but the most common three are fixed, reactive, finite state machine, and GOAP/emergent.

 

Fixed is simple. Think space invaders. They just scroll along a fixed path or do a fixed action.

 

Reactive is the conditional type that you're thinking of. If player within range, move to player. If player adjacent attack player. That's where you get your typical "AI types" (seeker, follower, path, etc.)

 

Finite state machine was the start of complex AIs. Instead of defining actions based on conditions you define all the states that a thing can be in. And the actions it can take in that state. You can then implement conditional logic on top of those states. For example think older RTSes. A tank can be moving, attacking, idle, hold position etc. You define all those states and then conditionally say what it does in those states. An action it takes can also transition it it a different state, like in hold position it may switch to attacking state of an enemy approaches, and then shift back to hold position if the enemy dies.

 

Then there's "Goal Oriented Action Planning" (or GOAP) AIs.  Basically you start with a finite state machine, remove all the changes between states, and add effects that have costs and rewards. Example: You need 100 food. Shaking a tree gives you 10 food and costs 10 time. Getting an axe gives you 0 food but costs 20 time. Hunting gives you 20 food for 10 time, but requires an axe. You can build a graph of these possible actions and use heuristics to optimize and find what the best option is. Shaking a tree has a total cost of 100 time, hunting has a total cost of 70 time (20 to get the axe, and 50 for hunting afterwards) so you hunt. If the axe disappears before you get it then you rebuild your graph and find that shaking trees is your best option.

 

The last option is the most relevant for modern titles. While it may seem like more work to define all the possible actions a thing can do, and optimize those, it's actually much much easier to use that to build a complex AI.

 

A finite state machine is great for basic AI, but as you get more and more states and need to manage transitions between them it quickly gets out of hand because for every state you add, the number of transitions you need to manage increases drastically.

Link to comment
Share on other sites

Link to post
Share on other sites

10 hours ago, Sniperfox47 said:

There are a number of types of AI used in games but the most common three are fixed, reactive, finite state machine, and GOAP/emergent.

 

Fixed is simple. Think space invaders. They just scroll along a fixed path or do a fixed action.

 

Reactive is the conditional type that you're thinking of. If player within range, move to player. If player adjacent attack player. That's where you get your typical "AI types" (seeker, follower, path, etc.)

 

Finite state machine was the start of complex AIs. Instead of defining actions based on conditions you define all the states that a thing can be in. And the actions it can take in that state. You can then implement conditional logic on top of those states. For example think older RTSes. A tank can be moving, attacking, idle, hold position etc. You define all those states and then conditionally say what it does in those states. An action it takes can also transition it it a different state, like in hold position it may switch to attacking state of an enemy approaches, and then shift back to hold position if the enemy dies.

 

Then there's "Goal Oriented Action Planning" (or GOAP) AIs.  Basically you start with a finite state machine, remove all the changes between states, and add effects that have costs and rewards. Example: You need 100 food. Shaking a tree gives you 10 food and costs 10 time. Getting an axe gives you 0 food but costs 20 time. Hunting gives you 20 food for 10 time, but requires an axe. You can build a graph of these possible actions and use heuristics to optimize and find what the best option is. Shaking a tree has a total cost of 100 time, hunting has a total cost of 70 time (20 to get the axe, and 50 for hunting afterwards) so you hunt. If the axe disappears before you get it then you rebuild your graph and find that shaking trees is your best option.

 

The last option is the most relevant for modern titles. While it may seem like more work to define all the possible actions a thing can do, and optimize those, it's actually much much easier to use that to build a complex AI.

 

A finite state machine is great for basic AI, but as you get more and more states and need to manage transitions between them it quickly gets out of hand because for every state you add, the number of transitions you need to manage increases drastically.

So GOAPis daisy chai pned loop whereas the otber 2 are not.......?

Please quote me so that I know that you have replied unless it is my own topic.

Link to comment
Share on other sites

Link to post
Share on other sites

6 hours ago, Ezio Auditore said:

So GOAPis daisy chai pned loop whereas the otber 2 are not.......?

Reactive is a series of a couple if loops. If a player is in range move and attack, if a player is adjacent attack. Else wander aimlessly.

 

Finite State Machines aren't so much a bunch of nested if statements as a graph of states and transitions between them.

 

GOAPs aren't so much a bunch of nested if statements as a graph of actions, effects, and preconditions, with costs and reward associated to them.

 

The implementation will involve a lot of if statements, but no more than *any* code is a bunch of if statements.

 

The bigger reason that GPUs can't process it effectively is that it's not really massively parallel in any way. There's not really anything else you can do while processing an AI graph because all of the steps of it are pretty much dependent on the previous step. You may be able to do a couple things at once when building graphs or transversing graphs, but nowhere near the level where a GPU would offer any real benefit.

 

Keep in mind that Game AI and Deep Learning AI are *very* very very different beasts. A deep learning AI is entirely massively parallel while the workload for a game AI is mostly serial.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×