2024-01-12 20:05:50 +00:00
:github_url: hide
.. DO NOT EDIT THIS FILE!!!
.. Generated automatically from Godot engine sources.
2024-09-30 09:17:01 +00:00
.. Generator: https://github.com/godotengine/godot/tree/4.3/doc/tools/make_rst.py.
.. XML source: https://github.com/godotengine/godot/tree/4.3/modules/limboai/doc_classes/BTProbabilitySelector.xml.
2024-01-12 20:05:50 +00:00
.. _class_BTProbabilitySelector:
BTProbabilitySelector
=====================
**Inherits:** :ref: `BTComposite<class_BTComposite>` **<** :ref: `BTTask<class_BTTask>` **<** :ref: `BT<class_BT>`
BT composite that chooses a child task to execute based on attached probabilities.
.. rst-class :: classref-introduction-group
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 :ref: `abort_on_failure<class_BTProbabilitySelector_property_abort_on_failure>` value:
- If :ref: `abort_on_failure<class_BTProbabilitySelector_property_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 :ref: `abort_on_failure<class_BTProbabilitySelector_property_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 `` .
.. rst-class :: classref-reftable-group
Properties
----------
.. table ::
:widths: auto
2024-07-20 15:25:24 +00:00
+----------+--------------------------------------------------------------------------------+-----------+
| `` bool `` | :ref: `abort_on_failure<class_BTProbabilitySelector_property_abort_on_failure>` | `` false `` |
+----------+--------------------------------------------------------------------------------+-----------+
2024-01-12 20:05:50 +00:00
.. rst-class :: classref-reftable-group
Methods
-------
.. table ::
:widths: auto
2024-07-20 15:25:24 +00:00
+-----------+--------------------------------------------------------------------------------------------------------------------------------+
| `` float `` | :ref: `get_probability<class_BTProbabilitySelector_method_get_probability>` \ (\ child_idx\: `` int ` ` \ ) |const| |
+-----------+--------------------------------------------------------------------------------------------------------------------------------+
| `` float `` | :ref: `get_total_weight<class_BTProbabilitySelector_method_get_total_weight>` \ (\ ) |const| |
+-----------+--------------------------------------------------------------------------------------------------------------------------------+
| `` float `` | :ref: `get_weight<class_BTProbabilitySelector_method_get_weight>` \ (\ child_idx\: `` int ` ` \ ) |const| |
+-----------+--------------------------------------------------------------------------------------------------------------------------------+
| `` bool `` | :ref: `has_probability<class_BTProbabilitySelector_method_has_probability>` \ (\ child_idx\: `` int ` ` \ ) |const| |
+-----------+--------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref: `set_probability<class_BTProbabilitySelector_method_set_probability>` \ (\ child_idx\: `` int `` , probability\: `` float ` ` \ ) |
+-----------+--------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref: `set_weight<class_BTProbabilitySelector_method_set_weight>` \ (\ child_idx\: `` int `` , weight\: `` float ` ` \ ) |
+-----------+--------------------------------------------------------------------------------------------------------------------------------+
2024-01-12 20:05:50 +00:00
.. rst-class :: classref-section-separator
----
.. rst-class :: classref-descriptions-group
Property Descriptions
---------------------
.. _class_BTProbabilitySelector_property_abort_on_failure:
.. rst-class :: classref-property
2024-07-20 15:25:24 +00:00
`` bool `` **abort_on_failure** = `` false `` :ref: `🔗<class_BTProbabilitySelector_property_abort_on_failure>`
2024-01-12 20:05:50 +00:00
.. rst-class :: classref-property-setget
2024-07-20 15:25:24 +00:00
- |void| **set_abort_on_failure** \ (\ value\: `` bool ` ` \ )
- `` bool `` **get_abort_on_failure** \ (\ )
2024-01-12 20:05:50 +00:00
If `` true `` , BTProbabilitySelector will not choose another child to execute and will return `` FAILURE `` when a child task results in `` FAILURE `` .
.. rst-class :: classref-section-separator
----
.. rst-class :: classref-descriptions-group
Method Descriptions
-------------------
.. _class_BTProbabilitySelector_method_get_probability:
.. rst-class :: classref-method
2024-07-20 15:25:24 +00:00
`` float `` **get_probability** \ (\ child_idx\: `` int ` ` \ ) |const| :ref: ` 🔗<class_BTProbabilitySelector_method_get_probability> `
2024-01-12 20:05:50 +00:00
Returns the child task's selection probability.
.. rst-class :: classref-item-separator
----
.. _class_BTProbabilitySelector_method_get_total_weight:
.. rst-class :: classref-method
2024-07-20 15:25:24 +00:00
`` float `` **get_total_weight** \ (\ ) |const| :ref: `🔗<class_BTProbabilitySelector_method_get_total_weight>`
2024-01-12 20:05:50 +00:00
Returns the total weight of all child tasks.
.. rst-class :: classref-item-separator
----
.. _class_BTProbabilitySelector_method_get_weight:
.. rst-class :: classref-method
2024-07-20 15:25:24 +00:00
`` float `` **get_weight** \ (\ child_idx\: `` int ` ` \ ) |const| :ref: ` 🔗<class_BTProbabilitySelector_method_get_weight> `
2024-01-12 20:05:50 +00:00
Returns the child task's weight within the weighted probability selection algorithm.
.. rst-class :: classref-item-separator
----
.. _class_BTProbabilitySelector_method_has_probability:
.. rst-class :: classref-method
2024-07-20 15:25:24 +00:00
`` bool `` **has_probability** \ (\ child_idx\: `` int ` ` \ ) |const| :ref: ` 🔗<class_BTProbabilitySelector_method_has_probability> `
2024-01-12 20:05:50 +00:00
2024-03-04 20:36:16 +00:00
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 :ref: `BTComment<class_BTComment>` tasks.
2024-01-12 20:05:50 +00:00
.. rst-class :: classref-item-separator
----
.. _class_BTProbabilitySelector_method_set_probability:
.. rst-class :: classref-method
2024-07-20 15:25:24 +00:00
|void| **set_probability** \ (\ child_idx\: `` int `` , probability\: `` float ` ` \ ) :ref: ` 🔗<class_BTProbabilitySelector_method_set_probability> `
2024-01-12 20:05:50 +00:00
Sets the child task's weight calculated based on the desired probability.
.. rst-class :: classref-item-separator
----
.. _class_BTProbabilitySelector_method_set_weight:
.. rst-class :: classref-method
2024-07-20 15:25:24 +00:00
|void| **set_weight** \ (\ child_idx\: `` int `` , weight\: `` float ` ` \ ) :ref: ` 🔗<class_BTProbabilitySelector_method_set_weight> `
2024-01-12 20:05:50 +00:00
Sets the child task's weight for the weighted probability selection algorithm.
.. |virtual| replace :: :abbr: `virtual (This method should typically be overridden by the user to have any effect.)`
.. |const| replace :: :abbr: `const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
.. |vararg| replace :: :abbr: `vararg (This method accepts any number of arguments after the ones described here.)`
.. |constructor| replace :: :abbr: `constructor (This method is used to construct a type.)`
.. |static| replace :: :abbr: `static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
.. |operator| replace :: :abbr: `operator (This method describes a valid operator to use with this type as left-hand operand.)`
.. |bitfield| replace :: :abbr: `BitField (This value is an integer composed as a bitmask of the following flags.)`
2024-07-20 15:25:24 +00:00
.. |void| replace :: :abbr: `void (No return value.)`