- Timestamp:
- Jul 25, 2011, 11:18:20 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.