Changeset 10797 for code/branches/AI_HS15/src/orxonox
- Timestamp:
- Nov 12, 2015, 11:27:41 AM (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/CommonController.cc
r10796 r10797 117 117 } 118 118 } 119 void CommonController::maneuver() 120 { 121 122 if (this->target_ && this->bHasPositionOfTarget_ && this->getControllableEntity()) 123 { 124 Vector3 diffVector = this->positionOfTarget_ - this->getControllableEntity()->getWorldPosition(); 125 float diffLength = diffVector.length(); 126 Vector3 diffUnit = diffVector/diffLength; 127 128 Vector3 myForwardVector = this->getControllableEntity()->getOrientation() * WorldEntity::FRONT; 129 float myDotProduct = diffVector.dotProduct(myForwardVector); 130 131 Vector3 opponentForwardVector = this->target_->getOrientation() * WorldEntity::FRONT; 132 float opponentDotProduct = diffVector.dotProduct(opponentForwardVector); 133 134 float myAngle = math::arccos ( myForwardVector.dotProduct(diffVector)/(diffLength) ); 135 float targetAngle = math::arccos ( opponentForwardVector.dotProduct(-diffVector)/(diffLength) ); 136 137 bool bThisIsLookingAtTarget = (myAngle/(diffLength*diffLength) < math::pi/8000000.0f); 138 bool bTargetIsLookingAtThis = (targetAngle/(diffLength*diffLength) < math::pi/8000000.0f); 139 140 float angleDiff = targetAngle - myAngle; 141 //I am looking when my angle < pi/6 142 //if his angle is bigger than mine 143 if ( angleDiff > 0 ) 144 { 145 //if diff is insignificant 146 if ( bThisIsLookingAtTarget && bTargetIsLookingAtThis ) 147 { 148 //if this can make target overshoot 149 if ( diffLength < 200 ) 150 { 151 Vector3* target = new Vector3 ( 0, -200, -200 ); 152 moveToPoint( 153 *target, 154 randomInRange(45, 180) 155 ); 156 } 157 //do scissors 158 else 159 { 160 Vector3 target = (diffUnit) * 150.0f 161 Vector3* randVector = new Vector3( 162 randomInRange(-300, 300), 163 randomInRange(-300, 300), 164 randomInRange(-300, 300) 165 ); 166 Vector3 projection = randVector.dotProduct(diffUnit) * diffUnit; 167 *randVector -= projection; 168 target += randVector; 169 moveToPoint( 170 *target, 171 randomInRange(45, 180) 172 ); 173 } 174 } 175 //this has advantage 176 else 177 { 178 179 } 180 } 181 182 } 183 if (this->getControllableEntity() && !this->target_) 184 { 185 this->maneuverType_ = ManeuverType::NONE; 186 } 187 orxout (internal_error) << "ManeuverType = " << this->maneuverType_ << endl; 188 } 119 189 void CommonController::chooseManeuverType() 120 190 { -
code/branches/AI_HS15/src/orxonox/controllers/DivisionController.cc
r10796 r10797 171 171 } 172 172 */ 173 if (this->myFollower_ && this->target_)174 this->myFollower_->setTarget(this->target_);175 if (this->target_ && this->myWingman_)176 this->myWingman_->setTarget(this->target_);173 // if (this->myFollower_ && this->target_) 174 // this->myFollower_->setTarget(this->target_); 175 // if (this->target_ && this->myWingman_) 176 // this->myWingman_->setTarget(this->target_); 177 177 /* 178 178 for (ObjectList<Controller>::iterator it = ObjectList<Controller>::begin(); it; ++it)
Note: See TracChangeset
for help on using the changeset viewer.