BTProbabilitySelector

Inherits: BTComposite < BTTask < BT

BT composite that chooses a child task to execute based on attached probabilities.

Description

BTProbabilitySelector chooses a child task to execute based on attached probabilities. It is typically used for decision-making purposes. Probability distribution is calculated based on weights assigned to each child task.

Returns SUCCESS when a child task results in SUCCESS.

Returns RUNNING when a child task results in RUNNING.

The behavior of BTProbabilitySelector when a child task results in FAILURE depends on the abort_on_failure value:

  • If abort_on_failure is false, when a child task results in FAILURE, BTProbabilitySelector will normalize the probability distribution over the remaining children and choose a new child task to be executed. If all child tasks fail, the composite will return FAILURE.

  • If abort_on_failure is true, when a child task results in FAILURE, BTProbabilitySelector will not choose another child task to be executed and will immediately return FAILURE.

Properties

bool

abort_on_failure

false

Methods

float

get_probability(child_idx: int) const

float

get_total_weight() const

float

get_weight(child_idx: int) const

bool

has_probability(child_idx: int) const

void

set_probability(child_idx: int, probability: float)

void

set_weight(child_idx: int, weight: float)


Property Descriptions

bool abort_on_failure = false 🔗

  • void set_abort_on_failure(value: bool)

  • bool get_abort_on_failure()

If true, BTProbabilitySelector will not choose another child to execute and will return FAILURE when a child task results in FAILURE.


Method Descriptions

float get_probability(child_idx: int) const 🔗

Returns the child task’s selection probability.


float get_total_weight() const 🔗

Returns the total weight of all child tasks.


float get_weight(child_idx: int) const 🔗

Returns the child task’s weight within the weighted probability selection algorithm.


bool has_probability(child_idx: int) const 🔗

Returns whether the child task at index child_idx participates within the weighted probability selection algorithm and has a probability assigned to it. Returns false for BTComment tasks.


void set_probability(child_idx: int, probability: float) 🔗

Sets the child task’s weight calculated based on the desired probability.


void set_weight(child_idx: int, weight: float) 🔗

Sets the child task’s weight for the weighted probability selection algorithm.