Changeset 10652
- Timestamp:
- Oct 16, 2015, 3:25:17 PM (9 years ago)
- Location:
- code/branches/AI_HS15/src/orxonox/controllers
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/AI_HS15/src/orxonox/controllers/AIController.cc
r10651 r10652 61 61 if (this->formationFlight_) 62 62 { 63 //When this is a master and was destroyed, destructor might complain that there are slaves of this, although this was removed from formation 64 //race conditions? 65 //destructor takes care of slaves anyway, so no need to worry about internal_error 66 63 67 64 68 //changed order -> searchNewMaster MUSTN'T be called in SLAVE-state (bugfix for internal-error messages at quit) … … 68 72 69 73 // return to Master after being forced free 70 if (this->freedomCount_ == 1)74 if (this->freedomCount_ == ACTION_INTERVAL) 71 75 { 72 76 this->state_ = SLAVE; 73 this->freedomCount_ = 0; 74 } 75 } 76 77 this->freedomCount_ = 0; // ACTION_INTERVAL is 1 sec, freedomCount is a remaining time of temp. freedom 78 } 79 } else{ 80 //form a formation 81 if (!this->forcedFree()) 82 this->searchNewMaster(); 83 } 77 84 this->defaultBehaviour(maxrand); 78 85 … … 82 89 { 83 90 // search enemy 84 random = rnd(maxrand); 85 if (random < (botlevel_*100) && (!this->target_)) 91 if ((!this->target_)) 86 92 this->searchNewTarget(); 87 93 88 // next enemy 89 random = rnd(maxrand); 90 if (random < (botlevel_*30) && (this->target_)) 91 this->searchNewTarget(); 92 94 93 95 // shoot 94 random = rnd(maxrand); 95 if (!(this->passive_) && random < (botlevel_*100) && (this->target_ && !this->bShooting_)) 96 if ((this->target_ && !this->bShooting_)) 96 97 this->bShooting_ = true; 97 98 98 99 // stop shooting 99 random = rnd(maxrand); 100 if (random < (1-botlevel_)*50 && (this->bShooting_)) 100 if (this->bShooting_ && !this->target_) 101 101 this->bShooting_ = false; 102 102 … … 105 105 if (this->state_ == MASTER) 106 106 { 107 108 this->setFormationMode(ATTACK); 109 107 110 this->commandSlaves(); 108 111 … … 127 130 this->followRandomHumanInit(); 128 131 */ 132 /* 129 133 // lose master status (only if less than 4 slaves in formation) 130 134 random = rnd(maxrand); 131 135 if(random < 15/(this->slaves_.size()+1) && this->slaves_.size() < 4 ) 132 136 this->loseMasterState(); 133 137 */ 138 134 139 // look out for outher masters if formation is small 135 140 random = rnd(maxrand); … … 149 154 if (!this->isActive()) 150 155 return; 151 152 156 float random; 153 157 float maxrand = 100.0f / ACTION_INTERVAL; … … 189 193 { 190 194 this->aimAtTarget(); 191 random = rnd(maxrand); 192 if(this->botlevel_*70 > random && !this->isCloseAtTarget(100)) 193 this->follow(); //If a bot is shooting a player, it shouldn't let him go away easily. 195 this->follow(); //If a bot is shooting a player, it shouldn't let him go away easily. 194 196 } 195 197 } … … 252 254 }//END_OF ROCKET MODE 253 255 256 254 257 SUPER(AIController, tick, dt); 255 258 } 256 259 //**********************************************NEW 257 260 void AIController::defaultBehaviour(float maxrand) 258 { 259 if (!this->target_) 260 this->searchNewTarget(); 261 if (!(this->passive_) && (this->target_ && !this->bShooting_)) 262 this->bShooting_ = true; 263 /* 264 float random; 265 // search enemy 266 random = rnd(maxrand); 267 if (random < (botlevel_* 100) && (!this->target_)) 268 this->searchNewTarget(); 269 270 // forget enemy 271 random = rnd(maxrand); 272 if (random < ((1-botlevel_)*20) && (this->target_)) 273 this->forgetTarget(); 274 275 // next enemy 276 random = rnd(maxrand); 277 if (random < (botlevel_*30) && (this->target_)) 278 this->searchNewTarget(); 279 280 // fly somewhere 281 random = rnd(maxrand); 282 if (random < 50 && (!this->bHasTargetPosition_ && !this->target_)) 283 this->searchRandomTargetPosition(); 284 285 // stop flying 286 random = rnd(maxrand); 287 if (random < 10 && (this->bHasTargetPosition_ && !this->target_)) 288 this->bHasTargetPosition_ = false; 289 290 // fly somewhere else 291 random = rnd(maxrand); 292 if (random < 30 && (this->bHasTargetPosition_ && !this->target_)) 293 this->searchRandomTargetPosition(); 294 295 if (this->state_ == MASTER) // master: shoot 296 { 297 random = rnd(maxrand); 298 if (!(this->passive_) && random < (100*botlevel_) && (this->target_ && !this->bShooting_)) 299 { 300 this->bShooting_ = true; 301 this->forceFreeSlaves(); 302 } 303 } 304 else 305 { 306 // shoot 307 random = rnd(maxrand); 308 if (!(this->passive_) && random < (botlevel_*100) && (this->target_ && !this->bShooting_)) 309 this->bShooting_ = true; 310 } 311 312 // stop shooting 313 random = rnd(maxrand); 314 if (random < ((1 - botlevel_)*50) && (this->bShooting_)) 315 this->bShooting_ = false; 316 317 // boost 318 random = rnd(maxrand); 319 if (random < botlevel_*50 ) 320 this->boostControl(); 321 */ 322 323 324 // update Checkpoints 325 /*random = rnd(maxrand); 326 if (this->defaultWaypoint_ && random > (maxrand-10)) 327 this->manageWaypoints(); 328 else //if(random > maxrand-10) //CHECK USABILITY!!*/ 329 if (this->waypoints_.size() == 0 ) 330 this->manageWaypoints(); 331 261 { 262 if (!this->target_) 263 this->searchNewTarget(); 264 if (!(this->passive_) && (this->target_ && !this->bShooting_)) 265 this->bShooting_ = true; 332 266 333 267 } -
code/branches/AI_HS15/src/orxonox/controllers/ArtificialController.h
r10651 r10652 53 53 { return this->botlevel_; } 54 54 static void setAllBotLevel(float level); 55 //WAYPOINT FUNCTIONS 55 //WAYPOINT FUNCTIONS` 56 56 void addWaypoint(WorldEntity* waypoint); 57 57 WorldEntity* getWaypoint(unsigned int index) const; -
code/branches/AI_HS15/src/orxonox/controllers/FormationController.cc
r10631 r10652 105 105 orxout(internal_error) << this << " is still master in " << (*it) << endl; 106 106 it->myMaster_ = 0; 107 it->state_ = FREE; 107 108 } 108 109 … … 472 473 Vector3 dest = this->getControllableEntity()->getPosition(); 473 474 474 // 1 slave: follow475 // only 1 slave: follow 475 476 if (this->slaves_.size() == 1) 476 477 {
Note: See TracChangeset
for help on using the changeset viewer.