Changeset 3515 in orxonox.OLD for orxonox/branches/trackManager/src/track_manager.cc
- Timestamp:
- Mar 12, 2005, 3:11:30 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/trackManager/src/track_manager.cc
r3514 r3515 123 123 int TrackElement::random(void* nothing) 124 124 { 125 if (this->childCount == 0) 125 int i = (int)floor ((float)rand()/(float)RAND_MAX * (float)this->childCount); 126 if (i >= this->childCount) 127 return this->childCount-1; 128 else 129 return i; 130 } 131 132 133 int TrackElement::leftRight(void* node) 134 { 135 PNode* tmpNode = (PNode*)node; 136 137 if (tmpNode->relCoordinate.z < 0) 126 138 return 0; 127 else 128 { 129 int i = (int)floor ((float)rand()/(float)RAND_MAX * (float)this->childCount); 130 if (i >= this->childCount) 131 return this->childCount-1; 132 else 133 return i; 134 } 135 } 139 else 140 return 1; 141 } 142 143 144 // todo 145 int TrackElement::nearest(void* node) 146 { 147 PNode* tmpNode = (PNode*)node; 148 149 Vector nodeRelCoord = tmpNode->relCoordinate; 150 151 if (nodeRelCoord.z < 0) 152 return 0; 153 else 154 return 1; 155 } 156 136 157 137 158 … … 376 397 /** 377 398 \brief decides under what condition a certain Path will be chosen. 399 \param cond the CONDITION of the decision 400 \param subject the Subject that will be decided upon with CONDITION cond. 401 */ 402 void TrackManager::condition(CONDITION cond, void* subject) 403 { 404 this->condition(this->currentTrackElem->ID, cond, subject); 405 } 406 /** 407 \brief decides under what condition a certain Path will be chosen. 378 408 \param groupID the ID on which to choose the preceding move 379 \param cond \todo think about this 380 */ 381 void TrackManager::condition(unsigned int groupID, PathCondition cond) 382 { 409 \param cond the CONDITION of the decision 410 \param subject the Subject that will be decided upon with CONDITION cond. 411 */ 412 void TrackManager::condition(unsigned int groupID, CONDITION cond, void* subject) 413 { 414 TrackElement* tmpElem = this->findTrackElementByID(groupID); 383 415 384 } 416 switch (cond) 417 { 418 case LOWEST: 419 tmpElem->condFunc = &TrackElement::lowest; 420 break; 421 case HIGHEST: 422 tmpElem->condFunc = &TrackElement::highest; 423 break; 424 case RANDOM: 425 tmpElem->condFunc = &TrackElement::random; 426 break; 427 case LEFTRIGHT: 428 tmpElem->condFunc = &TrackElement::leftRight; 429 break; 430 case NEAREST: 431 tmpElem->condFunc = &TrackElement::nearest; 432 break; 433 case ENEMYKILLED: 434 break; 435 default: // same as LOWEST 436 tmpElem->condFunc = &TrackElement::lowest; 437 break; 438 } 439 tmpElem->subject=subject; 440 } 441 385 442 386 443 /** … … 588 645 int TrackManager::choosePath(TrackElement* trackElem) 589 646 { 590 return (trackElem->*(trackElem->condFunc))( NULL);647 return (trackElem->*(trackElem->condFunc))(trackElem->subject); 591 648 } 592 649
Note: See TracChangeset
for help on using the changeset viewer.