Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

RandomTrans Class Reference

A transition that fires immediately, randomly choosing one destination node to activate. More...

#include <RandomTrans.h>

Inheritance diagram for RandomTrans:

Detailed Description

A transition that fires immediately, randomly choosing one destination node to activate.

This class should be extended in the following way:

setHistoryLength(int n) to maintain a history of recent choices that are not to be reused, i.e., drawing without replacement

Definition at line 16 of file RandomTrans.h.

List of all members.

Public Member Functions

 RandomTrans (StateNode *destination, float weight=1)
 constructor
 RandomTrans (const std::string &name, StateNode *destination, float weight=1)
 constructor
virtual void addDestination (StateNode *destination, float const weight)
 Add a destination node with a specified weight (defaults to 1.0).
virtual void addDestination (StateNode *destination)
 if destination is non-null, add it to the destination list
virtual void fire ()
 Firing this type of transition activates one destination node at random, instead of all destinations.

Protected Member Functions

 RandomTrans (const std::string &classname, const std::string &instancename, StateNode *destination, float weight=1)
 constructor, only to be called by subclasses (which need to specify their own classname)

Private Member Functions

void addWeight (float weight)
 adds a weight entry to the back of the queue

Private Attributes

std::vector< floatweights
 the probably of selection for each source

Constructor & Destructor Documentation

RandomTrans::RandomTrans ( StateNode destination,
float  weight = 1 
)

constructor

Definition at line 11 of file RandomTrans.cc.

RandomTrans::RandomTrans ( const std::string &  name,
StateNode destination,
float  weight = 1 
)

constructor

Definition at line 15 of file RandomTrans.cc.

RandomTrans::RandomTrans ( const std::string &  classname,
const std::string &  instancename,
StateNode destination,
float  weight = 1 
) [protected]

constructor, only to be called by subclasses (which need to specify their own classname)


Member Function Documentation

virtual void RandomTrans::addDestination ( StateNode destination  )  [virtual]

if destination is non-null, add it to the destination list

Reimplemented from Transition.

Definition at line 28 of file RandomTrans.h.

Referenced by addDestination().

void RandomTrans::addDestination ( StateNode destination,
float const   weight 
) [virtual]

Add a destination node with a specified weight (defaults to 1.0).

Definition at line 19 of file RandomTrans.cc.

void RandomTrans::addWeight ( float  weight  )  [private]

adds a weight entry to the back of the queue

Definition at line 24 of file RandomTrans.cc.

Referenced by addDestination(), and RandomTrans().

void RandomTrans::fire (  )  [virtual]

Firing this type of transition activates one destination node at random, instead of all destinations.

Reimplemented from Transition.

Definition at line 28 of file RandomTrans.cc.


Member Data Documentation

std::vector<float> RandomTrans::weights [private]

the probably of selection for each source

Definition at line 40 of file RandomTrans.h.

Referenced by addWeight(), and fire().


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

Tekkotsu v5.1CVS
Generated Mon May 9 04:59:15 2016 by Doxygen 1.6.3