Skip to content

Latest commit

 

History

History
376 lines (230 loc) · 8.39 KB

mountaingoap.agent.md

File metadata and controls

376 lines (230 loc) · 8.39 KB

Agent

Namespace: MountainGoap

GOAP agent.

public class Agent

Inheritance ObjectAgent

Fields

Name

Name of the agent.

public string Name;

Properties

CurrentActionSequences

Gets the chains of actions currently being performed by the agent.

public List<List<Action>> CurrentActionSequences { get; }

Property Value

List<List<Action>>

State

Gets or sets the current world state from the agent perspective.

public ConcurrentDictionary<string, object> State { get; set; }

Property Value

ConcurrentDictionary<String, Object>

Memory

Gets or sets the memory storage object for the agent.

public Dictionary<string, object> Memory { get; set; }

Property Value

Dictionary<String, Object>

Goals

Gets or sets the list of active goals for the agent.

public List<BaseGoal> Goals { get; set; }

Property Value

List<BaseGoal>

Actions

Gets or sets the actions available to the agent.

public List<Action> Actions { get; set; }

Property Value

List<Action>

Sensors

Gets or sets the sensors available to the agent.

public List<Sensor> Sensors { get; set; }

Property Value

List<Sensor>

CostMaximum

Gets or sets the plan cost maximum for the agent.

public float CostMaximum { get; set; }

Property Value

Single

IsBusy

Gets or sets a value indicating whether the agent is currently executing one or more actions.

public bool IsBusy { get; set; }

Property Value

Boolean

IsPlanning

Gets or sets a value indicating whether the agent is currently planning.

public bool IsPlanning { get; set; }

Property Value

Boolean

Constructors

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)

Parameters

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.

Methods

Step(StepMode)

You should call this every time your game state updates.

public void Step(StepMode mode)

Parameters

mode StepMode
Mode to be used for executing the step of work.

ClearPlan()

Clears the current action sequences (also known as plans).

public void ClearPlan()

Plan()

Makes a plan.

public void Plan()

PlanAsync()

Makes a plan asynchronously.

public void PlanAsync()

ExecutePlan()

Executes the current plan.

public void ExecutePlan()

TriggerOnPlanningStarted(Agent)

Triggers OnPlanningStarted event.

internal static void TriggerOnPlanningStarted(Agent agent)

Parameters

agent Agent
Agent that started planning.

TriggerOnPlanningStartedForSingleGoal(Agent, BaseGoal)

Triggers OnPlanningStartedForSingleGoal event.

internal static void TriggerOnPlanningStartedForSingleGoal(Agent agent, BaseGoal goal)

Parameters

agent Agent
Agent that started planning.

goal BaseGoal
Goal for which planning was started.

TriggerOnPlanningFinishedForSingleGoal(Agent, BaseGoal, Single)

Triggers OnPlanningFinishedForSingleGoal event.

internal static void TriggerOnPlanningFinishedForSingleGoal(Agent agent, BaseGoal goal, float utility)

Parameters

agent Agent
Agent that finished planning.

goal BaseGoal
Goal for which planning was completed.

utility Single
Utility of the plan.

TriggerOnPlanningFinished(Agent, BaseGoal, Single)

Triggers OnPlanningFinished event.

internal static void TriggerOnPlanningFinished(Agent agent, BaseGoal goal, float utility)

Parameters

agent Agent
Agent that finished planning.

goal BaseGoal
Goal that was selected.

utility Single
Utility of the plan.

TriggerOnPlanUpdated(Agent, List<Action>)

Triggers OnPlanUpdated event.

internal static void TriggerOnPlanUpdated(Agent agent, List<Action> actionList)

Parameters

agent Agent
Agent for which the plan was updated.

actionList List<Action>
New action list for the agent.

TriggerOnEvaluatedActionNode(ActionNode, Dictionary<ActionNode, ActionNode>)

Triggers OnEvaluatedActionNode event.

internal static void TriggerOnEvaluatedActionNode(ActionNode node, Dictionary<ActionNode, ActionNode> nodes)

Parameters

node ActionNode
Action node being evaluated.

nodes Dictionary<ActionNode, ActionNode>
List of nodes in the path that led to this point.

Events

OnAgentStep

Event that fires when the agent executes a step of work.

public static event AgentStepEvent OnAgentStep;

OnAgentActionSequenceCompleted

Event that fires when an action sequence completes.

public static event AgentActionSequenceCompletedEvent OnAgentActionSequenceCompleted;

OnPlanningStarted

Event that fires when planning begins.

public static event PlanningStartedEvent OnPlanningStarted;

OnPlanningStartedForSingleGoal

Event that fires when planning for a single goal starts.

public static event PlanningStartedForSingleGoalEvent OnPlanningStartedForSingleGoal;

OnPlanningFinishedForSingleGoal

Event that fires when planning for a single goal finishes.

public static event PlanningFinishedForSingleGoalEvent OnPlanningFinishedForSingleGoal;

OnPlanningFinished

Event that fires when planning finishes.

public static event PlanningFinishedEvent OnPlanningFinished;

OnPlanUpdated

Event that fires when a new plan is finalized for the agent.

public static event PlanUpdatedEvent OnPlanUpdated;

OnEvaluatedActionNode

Event that fires when the pathfinder evaluates a single node in the action graph.

public static event EvaluatedActionNodeEvent OnEvaluatedActionNode;