Changeset 8786
- Timestamp:
- Jul 25, 2011, 11:18:20 PM (13 years ago)
- Location:
- code/branches/ai2
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/ai2/data/levels/missionOne.oxw
r8773 r8786 56 56 </collisionShapes> 57 57 </Pawn> 58 <Pawn health=30 position=" 20,0,0" direction="0,-1,0" collisionType=dynamic mass=100000>58 <Pawn health=30 position="70,0,0" direction="0,-1,0" collisionType=dynamic mass=100000> 59 59 <attached> 60 60 <Model position="0,0,0" mesh="crate.mesh" scale3D="3,3,3" /> … … 64 64 </collisionShapes> 65 65 </Pawn> 66 <Pawn health=30 position=" 40,0,0" direction="0,-1,0" collisionType=dynamic mass=100000>66 <Pawn health=30 position="140,0,0" direction="0,-1,0" collisionType=dynamic mass=100000> 67 67 <attached> 68 68 <Model position="0,0,0" mesh="crate.mesh" scale3D="5,5,5" /> … … 72 72 </collisionShapes> 73 73 </Pawn> 74 <Pawn health=30 position=" 60,0,0" direction="0,-1,0" collisionType=dynamic mass=100000>74 <Pawn health=30 position="210,0,0" direction="0,-1,0" collisionType=dynamic mass=100000> 75 75 <attached> 76 76 <Model position="0,0,0" mesh="crate.mesh" scale3D="5,5,5" /> -
code/branches/ai2/src/orxonox/controllers/AIController.cc
r8769 r8786 114 114 this->bShooting_ = false; 115 115 116 // boost 117 random = rnd(maxrand); 118 if (random < botlevel_*100 ) 119 this->boostControl(); 120 121 // update Checkpoints 122 random = rnd(maxrand); 123 if (this->defaultWaypoint_ && random > (maxrand-10)) 124 this->manageWaypoints(); 125 else //if(random > maxrand-10) //CHECK USABILITY!! 126 this->manageWaypoints(); 127 116 128 } 117 129 … … 196 208 this->bShooting_ = false; 197 209 198 // boost210 // boost 199 211 random = rnd(maxrand); 200 212 if (random < botlevel_*100 ) 201 this->boostControl(); //TEST 213 this->boostControl(); 214 215 // update Checkpoints 216 random = rnd(maxrand); 217 if (this->defaultWaypoint_ && random > (maxrand-10)) 218 this->manageWaypoints(); 219 else //if(random > maxrand-10) //CHECK USABILITY!! 220 this->manageWaypoints(); 202 221 } 203 222 } … … 212 231 float random; 213 232 float maxrand = 100.0f / ACTION_INTERVAL; 214 if (this->waypoints_.size() > 0 && this->getControllableEntity() && this->mode_ == DEFAULT) //Waypoint functionality. 233 ControllableEntity* controllable = this->getControllableEntity(); 234 235 if (controllable && this->mode_ == DEFAULT)// bot is ready to move to a target 215 236 { 216 if (this->waypoints_[this->currentWaypoint_]->getWorldPosition().squaredDistance(this->getControllableEntity()->getPosition()) <= this->squaredaccuracy_) 217 this->currentWaypoint_ = (this->currentWaypoint_ + 1) % this->waypoints_.size(); 218 219 this->moveToPosition(this->waypoints_[this->currentWaypoint_]->getWorldPosition()); 237 if (this->waypoints_.size() > 0 ) //Waypoint functionality. 238 { 239 if (this->waypoints_[this->waypoints_.size()-1]->getWorldPosition().squaredDistance(controllable->getPosition()) <= this->squaredaccuracy_) 240 this->waypoints_.pop_back(); // if goal is reached, remove it from the list 241 if(this->waypoints_.size() > 0 ) 242 this->moveToPosition(this->waypoints_[this->waypoints_.size()-1]->getWorldPosition()); 243 } 244 else if(this->defaultWaypoint_ && ((this->defaultWaypoint_->getPosition()-controllable->getPosition()).length() > 200.0f)) 245 { 246 this->moveToPosition(this->defaultWaypoint_->getPosition()); // stay within a certain range of the defaultWaypoint_ 247 random = rnd(maxrand); 248 } 220 249 } 221 250 if(this->mode_ == DEFAULT) … … 283 312 else if (this->mode_ == ROCKET)//Rockets do not belong to a group of bots -> bot states are not relevant. 284 313 { //Vector-implementation: mode_.back() == ROCKET; 285 ControllableEntity *controllable = this->getControllableEntity();286 314 if(controllable) 287 315 { -
code/branches/ai2/src/orxonox/controllers/ArtificialController.cc
r8773 r8786 96 96 this->timeout_ = 0; 97 97 this->currentWaypoint_ = 0; 98 this->setAccuracy(100); 98 this->setAccuracy(9); 99 this->defaultWaypoint_ = NULL; 99 100 } 100 101 … … 1125 1126 } 1126 1127 1128 /** 1129 @brief Manages boost. Switches between boost usage and boost safe mode. 1130 */ 1127 1131 void ArtificialController::boostControl() 1128 1132 { … … 1158 1162 } 1159 1163 1160 void ArtificialController::updatePointsOfInterest(std::string name, float distance) 1164 /** 1165 @brief Adds first waypoint of type name to the waypoint stack, which is within the searchDistance 1166 @param name object-name of a point of interest (e.g. "PickupSpawner", "ForceField") 1167 */ 1168 void ArtificialController::updatePointsOfInterest(std::string name, float searchDistance) 1161 1169 { 1162 1170 WorldEntity* waypoint = NULL; 1163 if(name == "Pickup") 1164 { 1165 for (ObjectList<WorldEntity>::iterator it = ObjectList<WorldEntity>::begin(); it != ObjectList<WorldEntity>::end(); ++it) 1166 { 1167 //get POI by string: Possible POIs are PICKUPSPAWNER, FORCEFIELDS (!analyse!), ... 1168 //distance to POI decides wether it is added (neither too close nor too far away) 1169 //How should POI's be managed? (e.g. Look for POIs if there are no real targets to move to or if they can be taken "en passant".) 1170 waypoint = *it; 1171 if(waypoint->getIdentifier() == ClassByString(name)) 1172 { 1173 ControllableEntity* controllable = this->getControllableEntity(); 1174 if(!controllable) continue; 1175 float distance = ( waypoint->getPosition() - controllable->getPosition() ).length(); 1176 if(distance > 50.0f || distance < 5.0f) continue; 1177 if(name == "PickupSpawner") // PickupSpawner: adjust waypoint accuracy to PickupSpawner's triggerdistance 1178 { 1179 squaredaccuracy_ = waypoint->getTriggerDistance() * waypoint->getTriggerDistance(); 1180 } 1181 else if(name == "ForceField") // ForceField: analyze is angle between forcefield boost and own flying direction is acceptable 1182 { 1183 1184 } 1185 1186 1187 break; 1188 } 1189 1190 /*const Vector3 realDistance = it->getPosition() - this->getControllableEntity()->getPosition(); 1191 if( realDistance.length() < distance) 1171 for (ObjectList<WorldEntity>::iterator it = ObjectList<WorldEntity>::begin(); it != ObjectList<WorldEntity>::end(); ++it) 1172 { 1173 if((*it)->getIdentifier() == ClassByString(name)) 1174 { 1175 ControllableEntity* controllable = this->getControllableEntity(); 1176 if(!controllable) continue; 1177 float actualDistance = ( (*it)->getPosition() - controllable->getPosition() ).length(); 1178 if(actualDistance > searchDistance || actualDistance < 5.0f) continue; 1179 // TODO: PickupSpawner: adjust waypoint accuracy to PickupSpawner's triggerdistance 1180 // TODO: ForceField: analyze is angle between forcefield boost and own flying direction is acceptable 1181 else 1192 1182 { 1193 float minDistance = it->getTriggerDistance().length()*it->getTriggerDistance().length(); 1194 if(this->squaredaccuracy_ > minDistance) 1195 this->squaredaccuracy_ = minDistance; 1196 //waypoint = static_cast<WorldEntity*>(it); 1183 waypoint = *it; 1197 1184 break; 1198 // }*/1185 } 1199 1186 } 1200 1187 } … … 1203 1190 } 1204 1191 1192 /** 1193 @brief Adds point of interest depending on context 1194 */ 1195 void ArtificialController::manageWaypoints() 1196 { 1197 if(!defaultWaypoint_) 1198 this->updatePointsOfInterest("PickupSpawner", 60.0f); // long search radius if there is no default goal 1199 else 1200 this->updatePointsOfInterest("PickupSpawner", 20.0f); // take pickup en passant if there is a default waypoint 1201 } 1202 1205 1203 } -
code/branches/ai2/src/orxonox/controllers/ArtificialController.h
r8769 r8786 93 93 { return sqrt(this->squaredaccuracy_); } 94 94 void updatePointsOfInterest(std::string name, float distance); 95 void manageWaypoints(); 95 96 96 97 protected: … … 175 176 size_t currentWaypoint_; 176 177 float squaredaccuracy_; 178 WorldEntity* defaultWaypoint_; 177 179 }; 178 180 } -
code/branches/ai2/src/orxonox/controllers/WaypointController.cc
r8769 r8786 40 40 { 41 41 RegisterObject(WaypointController); 42 this->setAccuracy(100); 42 43 } 43 44
Note: See TracChangeset
for help on using the changeset viewer.