#include <Worshiper.h>
Public Member Functions | |
virtual | ~Worshiper () |
Empty destructor. | |
Behaviour * | getBehaviour () |
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. | |
Colony * | getColony () 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. | |
VisualContext * | getVisualContext () const |
Get the VisualContext. | |
void | setVisualContext (VisualContext *v) |
Set the VisualContext. | |
void | destroyVisualContext () |
Destroy the VisualContext. | |
Behaviour * | getBehaviour () 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 |
Definition at line 43 of file Worshiper.h.
Behaviour* Worshiper::getBehaviour | ( | ) | [inline] |
Get the Behaviour.
Definition at line 97 of file Worshiper.h.
References _behaviourStrategy.
Referenced by GeneticReplication::addSurvivor().
00097 { 00098 return _behaviourStrategy; 00099 }
move_command Worshiper::getAction | ( | ) |
Return the next action to be executed.
Use of Strategy Design Pattern
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 }
std::list< Pheromone * > * Worshiper::getPheromones | ( | ) | const |
Return the list of pheromones to be put in the world.
Use of Strategy Design Pattern
Definition at line 85 of file Worshiper.cpp.
References _behaviourStrategy, and Behaviour::getPheromones().
Referenced by World::addPheromone().
00085 { 00086 return _behaviourStrategy->getPheromones(); 00087 }
move_command Worshiper::getLastAction | ( | ) | const [inline] |
Return the 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 }
Colony* Worshiper::getColony | ( | ) | const [inline] |
Return the 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 }
unsigned int Worshiper::getSize | ( | ) | const [inline] |
Get 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 }
void Worshiper::setFood | ( | unsigned int | new_var | ) |
Set the value of food.
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 }
unsigned int Worshiper::getFood | ( | ) | const [inline] |
Get 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 }
bool Worshiper::subFood | ( | ) |
Decrements the food of the worshiper for one iteration.
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 }
unsigned int Worshiper::getCapacity | ( | ) | const [inline] |
Get 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 }
VisualContext* Worshiper::getVisualContext | ( | ) | const [inline] |
Get the VisualContext.
Definition at line 193 of file Worshiper.h.
References _visualContext.
Referenced by Behaviour::getVisualContext().
00193 { 00194 return _visualContext; 00195 }
void Worshiper::setVisualContext | ( | VisualContext * | v | ) |
Set the VisualContext.
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 }
Behaviour* Worshiper::getBehaviour | ( | ) | const [inline] |
Get the Behaviour.
Definition at line 214 of file Worshiper.h.
References _behaviourStrategy.
00214 { 00215 return _behaviourStrategy; 00216 }
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().