Worshiper Class Reference

#include <Worshiper.h>

Inheritance diagram for Worshiper:

Inheritance graph
[legend]
Collaboration diagram for Worshiper:

Collaboration graph
[legend]

Public Member Functions

virtual ~Worshiper ()
 Empty destructor.
BehaviourgetBehaviour ()
 Get the Behaviour.
void think ()
 Ask the worshiper to think to his strategy.
move_command getAction ()
 Return the next action to be executed.
std::list< Pheromone * > * getPheromones () const
 Return the list of pheromones to be put in the world.
move_command getLastAction () const
 Return the value of _last_command.
ColonygetColony () const
 Return the colony.
virtual void draw ()
 Draw the worshiper.
unsigned int getSize () const
 Get the value of size.
void setFood (unsigned int new_var)
 Set the value of food.
unsigned int getFood () const
 Get the value of food.
bool subFood ()
 Decrements the food of the worshiper for one iteration.
unsigned int getCapacity () const
 Get the value of capacity.
VisualContextgetVisualContext () const
 Get the VisualContext.
void setVisualContext (VisualContext *v)
 Set the VisualContext.
void destroyVisualContext ()
 Destroy the VisualContext.
BehaviourgetBehaviour () const
 Get the Behaviour.

Protected Member Functions

void compute_tex_vector ()
 Compute the texture vector.

Protected Attributes

Behaviour_behaviourStrategy
Colony_colony
VisualContext_visualContext
unsigned int _size
unsigned int _food
GLfloat m_tex_vector [4]

Private Member Functions

 Worshiper (Behaviour *behaviourStrategy, Colony *colony, unsigned int size, unsigned int food)
 Private constructor, so that only the friend class Colony can instanciate.

Private Attributes

move_command _last_command
 Memory of one case : the last command executed.

Friends

class Colony

Detailed Description

< The people of our world

Definition at line 43 of file Worshiper.h.


Member Function Documentation

Behaviour* Worshiper::getBehaviour (  )  [inline]

Get the Behaviour.

Returns:
the behaviour

Definition at line 97 of file Worshiper.h.

References _behaviourStrategy.

Referenced by GeneticReplication::addSurvivor().

00097                                     {
00098     return _behaviourStrategy;
00099   }

Here is the caller graph for this function:

move_command Worshiper::getAction (  ) 

Return the next action to be executed.

Use of Strategy Design Pattern

Returns:
command to be executed

Definition at line 80 of file Worshiper.cpp.

References _behaviourStrategy, _last_command, and Behaviour::getAction().

Referenced by World::addCommand().

00080                                   {
00081   _last_command = _behaviourStrategy->getAction();
00082   return _last_command;
00083 }

Here is the call graph for this function:

Here is the caller graph for this function:

std::list< Pheromone * > * Worshiper::getPheromones (  )  const

Return the list of pheromones to be put in the world.

Use of Strategy Design Pattern

Returns:
list of Pheromone*

Definition at line 85 of file Worshiper.cpp.

References _behaviourStrategy, and Behaviour::getPheromones().

Referenced by World::addPheromone().

00085                                                     {
00086   return _behaviourStrategy->getPheromones();
00087 }

Here is the call graph for this function:

Here is the caller graph for this function:

move_command Worshiper::getLastAction (  )  const [inline]

Return the value of _last_command.

Returns:
value of _last_command

Definition at line 129 of file Worshiper.h.

References _last_command.

Referenced by Behaviour::getLastAction().

00129                                             {
00130     return _last_command;
00131   }

Here is the caller graph for this function:

Colony* Worshiper::getColony (  )  const [inline]

Return the colony.

Returns:
colony

Definition at line 138 of file Worshiper.h.

References _colony.

Referenced by Behaviour::getPheromoneColony(), VisualContext::getPheromones(), WorshiperInfo::isEnnemy(), ColonyCell::reachable(), and UntilVictoryFight::resolve().

00138                                     {
00139     return _colony;
00140   }

Here is the caller graph for this function:

unsigned int Worshiper::getSize (  )  const [inline]

Get the value of size.

Returns:
the value of size

Definition at line 152 of file Worshiper.h.

References _size.

Referenced by WorshiperInfo::getSize(), Behaviour::getSize(), CorridorCell::reachable(), and UntilVictoryFight::resolve().

00152                                       {
00153     return _size;
00154   }

Here is the caller graph for this function:

void Worshiper::setFood ( unsigned int  new_var  ) 

Set the value of food.

Parameters:
new_var the new value of food

Definition at line 122 of file Worshiper.cpp.

References _food, and compute_tex_vector().

00122                                             {
00123   _food = new_var;
00124   // on recalcule la déformation de texture
00125   compute_tex_vector();
00126 }

Here is the call graph for this function:

unsigned int Worshiper::getFood (  )  const [inline]

Get the value of food.

Returns:
the value of food

Definition at line 168 of file Worshiper.h.

References _food.

Referenced by Colony::addSurvivor(), GeneticReplication::evaluation(), Behaviour::getFood(), and UntilVictoryFight::resolve().

00168                                       {
00169     return _food;
00170   }

Here is the caller graph for this function:

bool Worshiper::subFood (  ) 

Decrements the food of the worshiper for one iteration.

Returns:
true if the worshiper can continue to live, false if he has to die

Definition at line 133 of file Worshiper.cpp.

References _food, _size, compute_tex_vector(), and FOOD_CONSUMPTION.

00133                         {
00134   int res = _food - (FOOD_CONSUMPTION * _size);
00135 
00136   if(res > 0){
00137     _food = res;
00138   } else {
00139     _food = 0;
00140   }
00141 
00142   // on recalcule la déformation de texture
00143   compute_tex_vector();
00144 
00145   return (_food != 0);
00146 }

Here is the call graph for this function:

unsigned int Worshiper::getCapacity (  )  const [inline]

Get the value of capacity.

Returns:
the value of capacity

Definition at line 184 of file Worshiper.h.

References _size, and CAPACITY_FACTOR.

Referenced by compute_tex_vector(), Behaviour::getCapacity(), and Worshiper().

00184                                           {
00185     return (_size * CAPACITY_FACTOR);
00186   }

Here is the caller graph for this function:

VisualContext* Worshiper::getVisualContext (  )  const [inline]

Get the VisualContext.

Returns:
visual context

Definition at line 193 of file Worshiper.h.

References _visualContext.

Referenced by Behaviour::getVisualContext().

00193                                                  {
00194     return _visualContext;
00195   }

Here is the caller graph for this function:

void Worshiper::setVisualContext ( VisualContext v  ) 

Set the VisualContext.

Parameters:
v visual context

Definition at line 128 of file Worshiper.cpp.

References _visualContext, and VisualContext::setWorshiper().

Referenced by World::addNewWorshipers().

00128                                                   {
00129   _visualContext = v;
00130   _visualContext->setWorshiper(this);
00131 }

Here is the call graph for this function:

Here is the caller graph for this function:

Behaviour* Worshiper::getBehaviour (  )  const [inline]

Get the Behaviour.

Returns:
behaviour

Definition at line 214 of file Worshiper.h.

References _behaviourStrategy.

00214                                           {
00215     return _behaviourStrategy;
00216   }


Field Documentation

Behaviour* Worshiper::_behaviourStrategy [protected]

Behavioural strategy wor the worshiper

Definition at line 63 of file Worshiper.h.

Referenced by getAction(), getBehaviour(), getPheromones(), think(), Worshiper(), and ~Worshiper().

Colony* Worshiper::_colony [protected]

Colony of the worshiper

Definition at line 66 of file Worshiper.h.

Referenced by draw(), and getColony().

VisualContext* Worshiper::_visualContext [protected]

VisualContext, ie the visual information source of the worshiper

Definition at line 69 of file Worshiper.h.

Referenced by destroyVisualContext(), getVisualContext(), and setVisualContext().

unsigned int Worshiper::_size [protected]

His size

Definition at line 72 of file Worshiper.h.

Referenced by draw(), getCapacity(), getSize(), and subFood().

unsigned int Worshiper::_food [protected]

His quantity of food

Definition at line 75 of file Worshiper.h.

Referenced by compute_tex_vector(), getFood(), setFood(), subFood(), and Worshiper().

GLfloat Worshiper::m_tex_vector[4] [protected]

Texturing vector

Definition at line 78 of file Worshiper.h.

Referenced by compute_tex_vector(), and draw().


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