Class Selector

All Implemented Interfaces:
Goal, Behavior

public class Selector extends Composite
A selector of sub-goals, that chooses a single Behavior to execute from a list. The default selection function is a random selection but this can be specified in the builder.
  • Method Details

    • getNextBehavior

      public Behavior getNextBehavior()
    • getSelectionFunction

      public com.google.common.base.Function<List<Behavior>,Behavior> getSelectionFunction()
    • reset

      public void reset()
      Description copied from interface: Goal
      Resets the goal and any resources or state it is holding.
      Specified by:
      reset in interface Behavior
      Specified by:
      reset in interface Goal
      Overrides:
      reset in class Composite
    • retryChildren

      public boolean retryChildren()
    • run

      public BehaviorStatus run()
      Description copied from interface: Behavior
      Runs the behavior for one 'tick', optionally changing the state that it is in.
      Returns:
      The new state
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • selecting

      public static Selector.Builder selecting(Behavior... behaviors)
    • selecting

      public static Selector.Builder selecting(Collection<Behavior> behaviors)