Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Replicator::Replicator(WorldObjects& worldObjects, WorldReplicators& replicators, std::string ID, unsigned int category, unsigned int energy) :
- ChargedObject(energy), m_ID(ID), m_category(category), m_Leader(NULL)
- {
- if( ( getCounter()++ ) == 0 )
- srand(time(0));
- setPosition( rand() % WORLD_BOUNDARIES_X, rand() % WORLD_BOUNDARIES_Y );
- setRadius( REPLICATOR_BASE_ABSORPTION_RADIUS );
- m_targetMarked = false;
- /** Behaviour Management **/
- /// The blackboard represents the memory and the senses of this Replicator
- m_bt.setBlackboard( new ReplicatorBlackboard(*this, worldObjects, replicators) );
- /// This tree will only have two nodes
- /// I) The first one is going to represent the logic for seeking nearby objects charged with energy
- BT_Node *searchForEnergy = new BT_Node("Search for energy");
- m_bt.add( searchForEnergy );
- /// First we add a service that is going to search for the closest charged object
- searchForEnergy->add( new ReplicatorService_FindClosestObject );
- /** Then we add some conditions to see if we want to go for this object
- *** 1) Do we need more energy ?
- *** 2) Do we have enough energy to move to this object ?
- **/
- searchForEnergy->add( new ReplicatorCheck_LowEnergy );
- searchForEnergy->add( new ReplicatorCheck_TargetReachable );
- /// II) The second node is going to represent the logic for seeking another Replicator of a higher category in case we already
- /// have enough energy
- BT_Node *searchForHigherReplicators = new BT_Node("Search for higher Replicators");
- m_bt.add( searchForHigherReplicators );
- /// First we add a service that is going to search for a higher Replicator nearby
- searchForHigherReplicators->add( new ReplicatorService_FindHigherReplicator );
- /** Then we add some conditions to see if we want to go after this Replicator
- *** 1) Do we have enough energy to move to this object...
- *** 2) AND Do we have enough energy to download it's data ?
- **/
- searchForEnergy->add( new ReplicatorCheck_CanReachTargetAndDownload );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement