Overview of AI
- This is based on Introduction to AI with Blueprint
- You will be doing this for your next assignment.
- It is really good and I feel the results are worth it.
- You end up with a NPC who can chase you, look for food, run to random locations or hide
- He does a nice job integrating some theory as well.
- There is a missing bit, but I will cover that in my assignment notes.
- The framework appears to already have the project completed, so you will probably want to delete the AI parts and recreate them. Again, this is discussed in my notes.
- This goes very fast and is very in depth so I thought a preview might be in order.
- Some Ideas.
- An Intelligent Agent or IA is an autonomous entity that acts
- In this case, he says that there are three components
- Sense or discover what is in the environment.
- Think or figure out what to do next based on the input.
- Act or take an action based on the action.
- For sensing, we will use two different items.
- Navigation Meshes
- This is a resonably modern concept.
- Build a mesh of convex polygons that "covers" the areas where we can navigate.
- In (A navigation mesh for dynamic environmentsâ
) they present this navigateion mesh for "Zelda"
A navigation mesh for dynamic environmentsâ
-
- I grabbed this one from Gamedev.net.
-
-
- Navigation within a polygon is simple since it is convex, just move directly there.
- Navigation outside of polygons, form a graph and do a shortest path computation (Algorithms or Discrete II)
- Building a nav mesh is easy,
- just drag a Nav Mesh Bounds Volume into the scene
- There are some parameters you might need to adjust
- But this will generate the mesh for you.
- He cautions about large nav meshes.
- You can stitch mutliplies together if you wish.
- There are functions like GetRandomReachablePointInRadius
- He employs this to make the NPC wander about in the scene.
- The next item is the AI controller
- Remember a character is a pawn that moves around.
- These can be controled by a controller.
- You will probably have a controler for each different type of NPC in your scene.
- He uses the controler for two things.
- To run the AI, which controls the character (NPC)
- To implment fnctions which communicate between the character (NPC) and the AI.
- The AI is implmented as a Behavior Tree.
- A blackboard
- Think of this as a variable storage location.
- In the blackboard he declares the variables that control the AI
-
- Just like we need to transfer data to the GUI, we need to send data to the blackboard as well.
- Here is a script in the AI_Player Controller that does this.
-
- And this is called by a function in player (NPC)
-
- The tree
- The tree is constructed from a series of nodes
- The end nodes are called tasks.
- There are some pre-built tasks.
- Move to
- Wait
-
- Notice the move_to is accessing a value stored in the blackboard.
- Or you can build a task.
- Find navigable location inteacts with the nav-mesh to
generate a location the player can move to.
-
- Here is the blueprint
-
- Notice here it is setting a value in the blackboard.
- These tasks are combined in a sequence
- This is a special node that attempts to execute ALL of the tasks associated with it.
-
- Another type of node is a Selector
- This type of node stops executing as soon as the first child executes successfully.
-
- There is another type of node called Parallel, but it is not discussed in the tutorial. (But a presentation on this might be great)
- These nodes can have a Decorator
- This is a conditional that effects if the node should fire or not.
- They interact with variables from the blackboard.
- And determine if a node should fire or not.
-
- Here, we check to see if hunger has reaced 100%, and if so, search for food. If not, do something else.
- A Node can also have a Service
- This is an action associated with a composite node.
- It is a function that gets executed when the node is executed.
-
- Here, every time the taks fires, it also runs the service.
- This is just a blueprint that increments the "Hunger" variable.
-
- The final portion discussed is the Environmental Query System
- This is a cool experimental portion of Unreal.
- It gives the NPC "Senses"
- In this system, you describe a series of queries.
- In this case, we are asking for the closest food sources within 1000 units
-
- This gets tied to the BTree
-
- And executed when the player is trying to find food.
-