#include <Behaviour.h>
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. | |
VisualContext * | getVisualContext () 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 | |
Pheromone * | getPheromoneColony (unsigned int i) |
Get the i-th pheromone which can be put by the worshiper in the world. | |
Private Attributes | |
Worshiper const * | _worshiper |
Definition at line 32 of file Behaviour.h.
Pheromone * Behaviour::getPheromoneColony | ( | unsigned int | i | ) | [private] |
Get the i-th pheromone which can be put by the worshiper in the world.
i | number of the pheromone |
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 }
move_command Behaviour::getLastAction | ( | ) | const [protected] |
Get 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 }
VisualContext * Behaviour::getVisualContext | ( | ) | const [protected] |
Get 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 }
unsigned int Behaviour::getSize | ( | ) | const [protected] |
Get 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 }
unsigned int Behaviour::getFood | ( | ) | const [protected] |
Get 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 }
unsigned int Behaviour::getCapacity | ( | ) | const [protected] |
Get 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 }
void Behaviour::putPheromone | ( | unsigned int | n | ) | [protected] |
Put a pheromone.
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 }
move_command Behaviour::randomMove | ( | ) | const [protected] |
Generate a randomized movement, different that teh one we came from.
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 }
move_command Behaviour::getAction | ( | ) | [inline] |
Return the next action to be executed.
Definition at line 131 of file Behaviour.h.
References _action.
Referenced by Worshiper::getAction().
00131 { return _action; }
std::list<Pheromone*>* Behaviour::getPheromones | ( | ) | [inline] |
Return the Pheromone* list for pheromone creation.
Definition at line 138 of file Behaviour.h.
References _pheros.
Referenced by Worshiper::getPheromones().
00138 { return _pheros; }
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().