Qualia  0.2
Public Member Functions | Private Attributes | List of all members
BehaviorTree::ProbabilityNode Class Reference

Executes behaviors randomly, based on a given set of weights. More...

#include <ProbabilityNode.h>

Inheritance diagram for BehaviorTree::ProbabilityNode:
Inheritance graph
[legend]
Collaboration diagram for BehaviorTree::ProbabilityNode:
Collaboration graph
[legend]

Public Member Functions

 ProbabilityNode ()
 
virtual ~ProbabilityNode ()
 
virtual BehaviorTreeNodesetChildren (BehaviorTreeNode *node,...)
 Sets children, giving them all the same weight. More...
 
virtual BehaviorTreeNodesetWeightedChildren (WeightedBehaviorTreeNode weightedNode,...)
 
void init (void *object)
 
BEHAVIOR_STATUS execute (void *object)
 This method is invoked by the node's parent when the node should be run. More...
 
- Public Member Functions inherited from BehaviorTree::BehaviorTreeInternalNode
 BehaviorTreeInternalNode ()
 
virtual ~BehaviorTreeInternalNode ()
 
virtual BehaviorTreeNode_setChildren (BehaviorTreeNode *node, va_list nodeList)
 Helper method for setChildren(). More...
 
- Public Member Functions inherited from BehaviorTree::BehaviorTreeNode
virtual ~BehaviorTreeNode ()
 

Private Attributes

MTRand_closed random
 
float totalSum
 
BehaviorTreeNodecurrentNode
 
float * weighting
 

Additional Inherited Members

- Public Attributes inherited from BehaviorTree::BehaviorTreeInternalNode
BehaviorTreeNode ** children
 This node's children nodes. More...
 
uint8_t nChildren
 The number of children of this node. More...
 

Detailed Description

Executes behaviors randomly, based on a given set of weights.

The weights are not percentages, but rather simple ratios.

For example, if there were two children with a weight of one, each would have a 50% chance of being executed. If another child with a weight of eight were added, the previous children would have a 10% chance of being executed, and the new child would have an 80% chance of being executed. This weight system is intended to facilitate the fine-tuning of behaviors.

Constructor & Destructor Documentation

ProbabilityNode::ProbabilityNode ( )
ProbabilityNode::~ProbabilityNode ( )
virtual

Member Function Documentation

BEHAVIOR_STATUS ProbabilityNode::execute ( void *  agent)
virtual

This method is invoked by the node's parent when the node should be run.

Implements BehaviorTree::BehaviorTreeInternalNode.

void ProbabilityNode::init ( void *  object)
virtual

Adds a child to the node with specific weight. Deprecated: use setWeightedChildren() method instead.

Deprecated:

Implements BehaviorTree::BehaviorTreeInternalNode.

BehaviorTreeNode * ProbabilityNode::setChildren ( BehaviorTreeNode node,
  ... 
)
virtual

Sets children, giving them all the same weight.

Reimplemented from BehaviorTree::BehaviorTreeInternalNode.

BehaviorTreeNode * ProbabilityNode::setWeightedChildren ( WeightedBehaviorTreeNode  weightedNode,
  ... 
)
virtual

Sets children with different weights. Accepts WeightedBehaviorTreeNode instead of BehaviorTreeNode. List of arguments should be terminated by WeightedBehaviorTreeNode::NULL_WEIGHTED_NODE.

Member Data Documentation

BehaviorTreeNode* BehaviorTree::ProbabilityNode::currentNode
private
MTRand_closed BehaviorTree::ProbabilityNode::random
private
float BehaviorTree::ProbabilityNode::totalSum
private
float* BehaviorTree::ProbabilityNode::weighting
private

The documentation for this class was generated from the following files: