Posts

Showing posts with the label GOAP

UnityLearn - AI For Beginners - GOAP - Adding Goal Challenge & Taking a Break

August 19, 2020 AI For Beginners Goal Orientated Action Planning (GOAP) Parts 14 and 15 Beginner Programming: Unity Game Dev Courses Unity Learn Course - AI For Beginners Adding Goal Challenge Adding Goal Challenge My Approach This tutorial starts with another challenge to implement a new GAction. This time it is the GoHome GAction for the patient to return to a transform tagged "Home" after they receive treatment. This was rather straight forward as I created this new GAction that just had a Preperform method setting the target to the tagged gameobject "Home" and putting in the Postperform method that the TreatingPatient world state should be reduced by 1 (since they have finished being treated). Once this GAction was applied to the patient, it needed to connect to the previous action by having a precondition of "isTreated" and I added an after effect of "isCured". The "isCured" state was also added as the new sec...

UnityLearn - AI For Beginners - GOAP - Implementing the Inventory System & Moving the Nurse

August 13, 2020 AI For Beginners Goal Orientated Action Planning (GOAP) Parts 12 and 13 Beginner Programming: Unity Game Dev Courses Unity Learn Course - AI For Beginners Implementing the Inventory System Implementing the Inventory System They begin this tutorial by adding another simple GAction to the patient agents named GetTreated. They follow this up by adding a WorldStates object to the GAgent class (named beliefs) as well as a WorldStates object in GAction that references the GAgent's beliefs (similar to how the GInventory reference was passed between GAgent and GAction). They then add some logic to the GAction GoToWaitingRoom to add the atHospital state to the beliefs of the GAction itself. Upon running it there is an error because the GPlanner has not been built to handle beliefs (the internal WorldStates of the GActions or GAgents). To solve this, they add a Node overload constructor to the GPlanner class to also take in a WorldStates reference to acce...

UnityLearn - AI For Beginners - GOAP - Creating a Multi-Step Plan & Plans That Require Multiple Agents

Image
July 30, 2020 AI For Beginners Goal Orientated Action Planning (GOAP) Parts 9 and 10 Beginner Programming: Unity Game Dev Courses Unity Learn Course - AI For Beginners Creating a Multi-Step Plan Creating a Multi-Step Plan This tutorial begins linking multiple actions together to create more intricate action plans. To do so, they created a second GAction, GoToWaitingRoom. GoToHospital action was given an after effect of hasArrived and GoToWaitingRoom was given a precondition of hasArrived to give them a point to link together. GoToWaitingRoom was then given the after effect isWaiting, so that the goal given would match up with this second action's outcome. This let's the system take an input goal of isWaiting and deduce the plan of action to get there through these two actions. Just to better visualize this demonstration, they created a basic spawner to consistently spawn in new patients to show that the newly created objects can follow the plans created prop...

UnityLearn - AI For Beginners - GOAP - Executing a Simple Plan

July 21, 2020 AI For Beginners Goal Orientated Action Planning (GOAP) Part 8 Beginner Programming: Unity Game Dev Courses Unity Learn Course - AI For Beginners Executing a Simple Plan Executing a Simple Plan This tutorial starts by actually implementing the newly created planner setup within the agents themselves. This involves creating a rather bulky LateUpdate method within the GAgents class which tries to handle all the possible cases of different states of having a planner and having actions to perform. This LateUpdate can be broken down into four main sections: Continues running an action that is in progress Generates a plan and possibly an action queue if they are not already present in agent Removes goal and planner once entire action queue is used up Selects the next action in queue to start performing They then created a new Patient class (which inherited from GAgent) to place on the patient agents and they created a new GoToHospital class (which i...

UnityLearn - AI For Beginners - GOAP - The GOAP Planner

July 21, 2020 AI For Beginners Goal Orientated Action Planning (GOAP) Part 7 Beginner Programming: Unity Game Dev Courses Unity Learn Course - AI For Beginners The GOAP Planner GOAP Planner - Part 1 Planner starts by looking through all the achievable actions and finding which can be performed given the starting states from the first node. This can create the branches for the action network which will then continue to have actions connected to them (that satisfy the state conditions) until a chain is found that has a result which matches the initial goal. GPlanner Class The first major step of this class is creating the Plan method which returns a Queue of GActions (this will basically be the full list of actions that will be chosen to actual be acted out). This starts by making a List of usable GActions (those which satisfy the IsAhchieavable condition). They then start a List of the newly create Node class objects, which acts as a more encompassing container f...

UnityLearn - AI For Beginners - GOAP - Setting Up GOAP System

June 11, 2020 AI For Beginners Goal Orientated Action Planning (GOAP) Parts 4, 5, and 6 Beginner Programming: Unity Game Dev Courses Unity Learn Course - AI For Beginners Intro This part of the course gets into actually programming the GOAP system and using it within their example Unity project. These tutorials focused on setting up the foundational classes: GAgent, GAction, GWorld, and WorldStates. These are used as the core of the system as they either hold all the information to pass around through the system, or serve as the base classes to work with for creating agents within the system. The World States The World States The main scripts created here are: GAgent GAction GWorld WorldStates WorldStates: They added another class within this script named WorldState. This WorldState class just holds a string named key, and an int named value. These will be used for a dictionary setup, hence the key and value naming setup. The rest of the WorldStates class i...

UnityLearn - AI For Beginners - GOAP - Introduction to GOAP

June 10, 2020 AI For Beginners Goal Orientated Action Planning (GOAP) Parts 1, 2, and 3 Beginner Programming: Unity Game Dev Courses Unity Learn Course - AI For Beginners Intro This course covers goal orientated action planning (GOAP) as another way to set up flexible systems of AI behavior. This blog covers the first 3 tutorials of the course which introduce the general GOAP concept by defining its parts and explaining the planning process going in to creating a GOAP system. An Introduction to GOAP GOAP Introduction Goal Orientated Action Planning (GOAP): has all the elements of a finite state machine, but uses them differently uses graphs for processing GOAPs actions and goals are decoupled actions are free elements in the system that are mixed/matched to meet goals instead of having a list of actions needed to meet a goal, GOAP allows for multiple solutions to be chosen from Actions Components: Precondition, Effect Precondition: state that must be met...