Behaviour Class Reference

#include <Behaviour.h>

Inheritance diagram for Behaviour:

Inheritance graph
[legend]
Collaboration diagram for Behaviour:

Collaboration graph
[legend]

Public Member Functions

virtual ~Behaviour ()
 Destructor.
void setWorshiper (const Worshiper *w)
 Assigns the behavior to a worshiper.
virtual void think ()=0
 Think at the strategy for this turn.
move_command getAction ()
 Return the next action to be executed.
std::list< Pheromone * > * getPheromones ()
 Return the Pheromone* list for pheromone creation.

Protected Member Functions

 Behaviour ()
 Protected constructor.
move_command getLastAction () const
 Get the last action executed.
VisualContextgetVisualContext () const
 Get the VisualContext of the worshiper.
unsigned int getSize () const
 Get the size of the Worshiper.
unsigned int getFood () const
 Get the food of the Worshiper.
unsigned int getCapacity () const
 Get the value of capacity.
void putPheromone (unsigned int n)
 Put a pheromone.
move_command randomMove () const
 Generate a randomized movement, different that teh one we came from.

Protected Attributes

move_command _action
std::list< Pheromone * > * _pheros

Private Member Functions

PheromonegetPheromoneColony (unsigned int i)
 Get the i-th pheromone which can be put by the worshiper in the world.

Private Attributes

Worshiper const * _worshiper

Detailed Description

< The behaviours interface

Definition at line 32 of file Behaviour.h.


Member Function Documentation

Pheromone * Behaviour::getPheromoneColony ( unsigned int  i  )  [private]

Get the i-th pheromone which can be put by the worshiper in the world.

Parameters:
i number of the pheromone
Returns:
the i-th pheromone pointer

Definition at line 45 of file Behaviour.cpp.

References _worshiper, Worshiper::getColony(), and Colony::getPheromone().

Referenced by putPheromone().

00045                                                        {
00046   return _worshiper->getColony()->getPheromone(i);
00047 }

Here is the call graph for this function:

Here is the caller graph for this function:

move_command Behaviour::getLastAction (  )  const [protected]

Get the last action executed.

Returns:
the last action executed

Definition at line 41 of file Behaviour.cpp.

References _worshiper, and Worshiper::getLastAction().

Referenced by randomMove().

00041                                             {
00042   return _worshiper->getLastAction();
00043 }

Here is the call graph for this function:

Here is the caller graph for this function:

VisualContext * Behaviour::getVisualContext (  )  const [protected]

Get the VisualContext of the worshiper.

Returns:
the VisualContext of the worshiper

Definition at line 53 of file Behaviour.cpp.

References _worshiper, and Worshiper::getVisualContext().

Referenced by randomMove(), Warrior::think(), GeneticBehaviour::think(), and Explorer::think().

00053                                                  {
00054   return _worshiper->getVisualContext();
00055 }

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int Behaviour::getSize (  )  const [protected]

Get the size of the Worshiper.

Returns:
the size of the Worshiper

Definition at line 57 of file Behaviour.cpp.

References _worshiper, and Worshiper::getSize().

Referenced by GeneticBehaviour::think().

00057                                       {
00058   return _worshiper->getSize();
00059 }

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int Behaviour::getFood (  )  const [protected]

Get the food of the Worshiper.

Returns:
the food of the Worshiper

Definition at line 61 of file Behaviour.cpp.

References _worshiper, and Worshiper::getFood().

Referenced by GeneticBehaviour::think().

00061                                       {
00062   return _worshiper->getFood();
00063 }

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int Behaviour::getCapacity (  )  const [protected]

Get the value of capacity.

Returns:
the value of capacity

Definition at line 65 of file Behaviour.cpp.

References _worshiper, and Worshiper::getCapacity().

Referenced by GeneticBehaviour::think().

00065                                           {
00066   return _worshiper->getCapacity();
00067 }

Here is the call graph for this function:

Here is the caller graph for this function:

void Behaviour::putPheromone ( unsigned int  n  )  [protected]

Put a pheromone.

Parameters:
n the number of the pheromone

Definition at line 49 of file Behaviour.cpp.

References _pheros, and getPheromoneColony().

Referenced by Warrior::think(), and Explorer::think().

00049                                            {
00050   _pheros->push_back(getPheromoneColony(n));
00051 }

Here is the call graph for this function:

Here is the caller graph for this function:

move_command Behaviour::randomMove (  )  const [protected]

Generate a randomized movement, different that teh one we came from.

Returns:
a randomized movement

Definition at line 69 of file Behaviour.cpp.

References getLastAction(), getVisualContext(), VisualContext::nbMovements(), and Random::value().

Referenced by Warrior::think(), and Explorer::think().

00069                                          {
00070   move_command res;
00071   do{
00072     res = (move_command) (Random::value() % getVisualContext()->nbMovements());
00073   } while(res == getLastAction());
00074   return res;
00075 }

Here is the call graph for this function:

Here is the caller graph for this function:

move_command Behaviour::getAction (  )  [inline]

Return the next action to be executed.

Returns:
command to be executed

Definition at line 131 of file Behaviour.h.

References _action.

Referenced by Worshiper::getAction().

00131 { return _action; }

Here is the caller graph for this function:

std::list<Pheromone*>* Behaviour::getPheromones (  )  [inline]

Return the Pheromone* list for pheromone creation.

Returns:
the Pheromone* list to put in the world

Definition at line 138 of file Behaviour.h.

References _pheros.

Referenced by Worshiper::getPheromones().

00138 { return _pheros; }

Here is the caller graph for this function:


Field Documentation

Worshiper const* Behaviour::_worshiper [private]

The Worshiper associated with the Behaviour

Definition at line 37 of file Behaviour.h.

Referenced by getCapacity(), getFood(), getLastAction(), getPheromoneColony(), getSize(), getVisualContext(), and setWorshiper().

move_command Behaviour::_action [protected]

The next action to execute

Definition at line 50 of file Behaviour.h.

Referenced by getAction(), Warrior::think(), GeneticBehaviour::think(), and Explorer::think().

std::list<Pheromone*>* Behaviour::_pheros [protected]

The list of pheromones to put in the world

Definition at line 53 of file Behaviour.h.

Referenced by getPheromones(), putPheromone(), Warrior::think(), GeneticBehaviour::think(), Explorer::think(), and ~Behaviour().


The documentation for this class was generated from the following files:
Generated on Sat Feb 2 22:23:02 2008 for Teapot Colony Wars by  doxygen 1.5.4