Namespace: MountainGoap
GOAP agent.
public class Agent
Name of the agent.
public string Name;
Gets the chains of actions currently being performed by the agent.
public List<List<Action>> CurrentActionSequences { get; }
Gets or sets the current world state from the agent perspective.
public ConcurrentDictionary<string, object> State { get; set; }
ConcurrentDictionary<String, Object>
Gets or sets the memory storage object for the agent.
public Dictionary<string, object> Memory { get; set; }
Gets or sets the list of active goals for the agent.
public List<BaseGoal> Goals { get; set; }
Gets or sets the actions available to the agent.
public List<Action> Actions { get; set; }
Gets or sets the sensors available to the agent.
public List<Sensor> Sensors { get; set; }
Gets or sets the plan cost maximum for the agent.
public float CostMaximum { get; set; }
Gets or sets a value indicating whether the agent is currently executing one or more actions.
public bool IsBusy { get; set; }
Gets or sets a value indicating whether the agent is currently planning.
public bool IsPlanning { get; set; }
Agent(String, ConcurrentDictionary<String, Object>, Dictionary<String, Object>, List<BaseGoal>, List<Action>, List<Sensor>, Single)
Initializes a new instance of the Agent class.
public Agent(string name, ConcurrentDictionary<string, object> state, Dictionary<string, object> memory, List<BaseGoal> goals, List<Action> actions, List<Sensor> sensors, float costMaximum)
name
String
Name of the agent.
state
ConcurrentDictionary<String, Object>
Initial agent state.
memory
Dictionary<String, Object>
Initial agent memory.
goals
List<BaseGoal>
Initial agent goals.
actions
List<Action>
Actions available to the agent.
sensors
List<Sensor>
Sensors available to the agent.
costMaximum
Single
Maximum cost of an allowable plan.
You should call this every time your game state updates.
public void Step(StepMode mode)
mode
StepMode
Mode to be used for executing the step of work.
Clears the current action sequences (also known as plans).
public void ClearPlan()
Makes a plan.
public void Plan()
Makes a plan asynchronously.
public void PlanAsync()
Executes the current plan.
public void ExecutePlan()
Triggers OnPlanningStarted event.
internal static void TriggerOnPlanningStarted(Agent agent)
agent
Agent
Agent that started planning.
Triggers OnPlanningStartedForSingleGoal event.
internal static void TriggerOnPlanningStartedForSingleGoal(Agent agent, BaseGoal goal)
agent
Agent
Agent that started planning.
goal
BaseGoal
Goal for which planning was started.
Triggers OnPlanningFinishedForSingleGoal event.
internal static void TriggerOnPlanningFinishedForSingleGoal(Agent agent, BaseGoal goal, float utility)
agent
Agent
Agent that finished planning.
goal
BaseGoal
Goal for which planning was completed.
utility
Single
Utility of the plan.
Triggers OnPlanningFinished event.
internal static void TriggerOnPlanningFinished(Agent agent, BaseGoal goal, float utility)
agent
Agent
Agent that finished planning.
goal
BaseGoal
Goal that was selected.
utility
Single
Utility of the plan.
Triggers OnPlanUpdated event.
internal static void TriggerOnPlanUpdated(Agent agent, List<Action> actionList)
agent
Agent
Agent for which the plan was updated.
actionList
List<Action>
New action list for the agent.
Triggers OnEvaluatedActionNode event.
internal static void TriggerOnEvaluatedActionNode(ActionNode node, Dictionary<ActionNode, ActionNode> nodes)
node
ActionNode
Action node being evaluated.
nodes
Dictionary<ActionNode, ActionNode>
List of nodes in the path that led to this point.
Event that fires when the agent executes a step of work.
public static event AgentStepEvent OnAgentStep;
Event that fires when an action sequence completes.
public static event AgentActionSequenceCompletedEvent OnAgentActionSequenceCompleted;
Event that fires when planning begins.
public static event PlanningStartedEvent OnPlanningStarted;
Event that fires when planning for a single goal starts.
public static event PlanningStartedForSingleGoalEvent OnPlanningStartedForSingleGoal;
Event that fires when planning for a single goal finishes.
public static event PlanningFinishedForSingleGoalEvent OnPlanningFinishedForSingleGoal;
Event that fires when planning finishes.
public static event PlanningFinishedEvent OnPlanningFinished;
Event that fires when a new plan is finalized for the agent.
public static event PlanUpdatedEvent OnPlanUpdated;
Event that fires when the pathfinder evaluates a single node in the action graph.
public static event EvaluatedActionNodeEvent OnEvaluatedActionNode;