Vixen
caa30e12
csharp
public sealed class UtilitySet

A list of things an agent might do, and the rules for choosing between them.

Read the guide page for this →

Remarks

doc 37 § D2's second planner. What it produces is an IAgentAction index — the same thing a behaviour-tree task names and the same thing a GOAP plan's head names — so everything around the decision is written once, in AiSystem.

Immutable and shared by every agent running it, exactly like a BehaviorTreeTemplate. The per-agent half is a UtilityState and a span of cooldown stamps.

⚠ The defaults have inertia turned on, because a default that oscillates is a default that makes the feature look broken. A commitment bonus of 0.15 and a decision interval of 0.2 s are what P5's exit criterion measures.

Fields and properties (8)

  • public Symbol Name

    What it is called.

  • public int Count

    How many actions it holds.

  • public UtilityAction this[int index]

    The action at an index.

  • public IUtilitySelector Selector

    Which of the scored actions wins.

  • public float CommitmentBonus

    How much is added to the running action's score, to stop it being nudged out.

  • public float DecisionInterval

    Seconds between decisions. Scoring does not happen on the frames in between.

  • public ReadOnlySpan<UtilityAction> Actions

    Everything it holds, in order.

  • public int CandidateCount

Methods (10)

  • public UtilitySet(Symbol name, params UtilityAction[] actions)

    Creates a set.

  • public UtilityAction CandidateAt(int index)

    One of them.

  • public Symbol CandidateName(int index)

    What one candidate is called, for a table, an overlay and a diagnostic.

  • public int FactorsOf(int index)

    How many factors score one candidate.

  • public Symbol FactorName(int index, int factor)

    What one of a candidate's factors is called.

  • public float ScoreOf(in AgentContext context, int index, Span<float> detail = default(Span<float>))
  • public void Score(in AgentContext context, ref readonly UtilityState state, ReadOnlySpan<float> cooldowns, Span<float> scores)

    Scores every action, with inertia applied.

  • public int Choose(in AgentContext context, ref UtilityState state, Span<float> cooldowns, float delta, Span<float> scores)

    Decides what the agent should do now.

  • public void Finished(ref UtilityState state, Span<float> cooldowns)

    Tells the set that the running action finished, so its cooldown starts.

  • public int RequiredState(int actionState)

    How many bytes a caller needs to run this set out of a span.

Used by (30)

  • AiDebugChannelTestsVixen.Ai.Tests
  • AiDiagnosisExitCriteriaTestsVixen.Ai.Tests
  • AiSnapshotTestsVixen.Ai.Tests
  • AiSnapshotsVixen.Ai
  • AiSystemVixen.Ai
  • AuthorableNodeTestsVixen.Ai.Tests
  • BehaviorTreeResolverVixen.Ai
  • BucketedSelectorVixen.Ai
  • BuildStateVixen.Ai
  • HighestSelectorVixen.Ai
  • IUtilitySelectorVixen.Ai
  • OverlayFixtureVixen.Ai.Diagnostics.Tests
  • QueryScorerExitCriteriaTestsVixen.Ai.Tests
  • RunUtilitySetTaskVixen.Ai
  • SeamTestsVixen.Ai.Nodes.Tests
  • TopWeightedRandomSelectorVixen.Ai
  • UtilityAgentTestsVixen.Ai.Tests
  • UtilityContentTestsVixen.Ai.Tests
  • UtilityInertiaTestsVixen.Ai.Tests
  • UtilityOscillationTestsVixen.Ai.Tests
  • UtilitySelectorTestsVixen.Ai.Tests
  • UtilitySelectorsVixen.Ai
  • UtilitySetContentCompilerVixen.Ai
  • UtilitySetLibraryVixen.Ai
  • VillageVixen.Ai.Nodes.Tests
  • WeightedRandomSelectorVixen.Ai
  • AgentFixtureVixen.Editor.AssetEditors.Tests
  • LiveAgentVixen.Editor.AssetEditors.Tests
  • UtilitySetDocumentVixen.Editor.AssetEditors
  • UtilitySetViewVixen.Editor.AssetEditors