Changeset 10654
- Timestamp:
- Oct 18, 2015, 8:53:37 PM (9 years ago)
- Location:
- code/branches/AI_HS15/src/orxonox/controllers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/AI_HS15/src/orxonox/controllers/AIController.cc
r10652 r10654 105 105 if (this->state_ == MASTER) 106 106 { 107 108 //------------------------------------------------------- 109 //collect data for AI behaviour 110 Vector3 meanOfEnemies; 111 Vector3 meanOfAllies; 112 113 for (ObjectList<AIController>::iterator it = ObjectList<AIController>::begin(); it; ++it) 114 { 115 116 Gametype* gt=this->getGametype(); 117 if (!gt) 118 { 119 gt=it->getGametype(); 120 } 121 if (!FormationController::sameTeam(this->getControllableEntity(), it->getControllableEntity(),gt)) 122 { 123 enemies.push_back(*it); 124 } 125 else { 126 allies.push_back(*it); 127 } 128 } 129 if (enemies.size() != 0 && allies.size() != 0){ 130 for (std::vector<AIController*>::iterator it = enemies.begin() ; it != enemies.end(); ++it) 131 meanOfEnemies += (*it)->getControllableEntity()->getPosition(); 132 meanOfEnemies /= enemies.size(); 133 for (std::vector<AIController*>::iterator it = allies.begin() ; it != allies.end(); ++it) 134 meanOfAllies += (*it)->getControllableEntity()->getPosition(); 135 meanOfAllies /= allies.size(); 136 //orxout(internal_error) << "There are " << enemiesCounter << " enemies, mean position is " << meanOfEnemies << endl; 137 orxout(internal_error) << "Distance is " << (meanOfEnemies-meanOfAllies).length() << endl; 138 orxout(internal_error) << "mean of Allies is " << meanOfAllies << ", with a size " << allies.size() << endl; 139 orxout(internal_error) << "mean of Enemies is " << meanOfEnemies << ", with a size " << enemies.size() << endl; 140 } 141 //------------------------------------------------------- 142 107 143 108 144 this->setFormationMode(ATTACK); … … 116 152 117 153 // make 180 degree turn - a specific Master Action 154 /* 118 155 random = rnd(1000.0f); 119 156 if (random < 5) … … 125 162 this->spinInit(); 126 163 164 */ 127 165 /*// follow a randomly chosen human - a specific Master Action 128 166 random = rnd(1000.0f); … … 146 184 } 147 185 } 148 186 allies.clear(); 187 enemies.clear(); 149 188 } 150 189 -
code/branches/AI_HS15/src/orxonox/controllers/AIController.h
r9667 r10654 54 54 55 55 Timer actionTimer_; //<! Regularly calls action(). 56 std::vector<AIController*> enemies, allies; 56 57 }; 57 58 }
Note: See TracChangeset
for help on using the changeset viewer.