Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 12, 2005, 3:11:30 AM (19 years ago)
Author:
bensch
Message:

orxonox/branches/trackManager: now ability to set LEFT-RIGHT decision for nodes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/trackManager/src/track_manager.cc

    r3514 r3515  
    123123int TrackElement::random(void* nothing)
    124124{
    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
     133int TrackElement::leftRight(void* node)
     134{
     135  PNode* tmpNode = (PNode*)node;
     136
     137  if (tmpNode->relCoordinate.z < 0)
    126138    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
     145int 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
    136157
    137158
     
    376397/**
    377398   \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*/
     402void 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.
    378408   \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*/
     412void TrackManager::condition(unsigned int groupID, CONDITION cond, void* subject)
     413{
     414  TrackElement* tmpElem = this->findTrackElementByID(groupID);
    383415 
    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
    385442
    386443/**
     
    588645int TrackManager::choosePath(TrackElement* trackElem)
    589646{
    590   return (trackElem->*(trackElem->condFunc))(NULL);
     647  return (trackElem->*(trackElem->condFunc))(trackElem->subject);
    591648}
    592649
Note: See TracChangeset for help on using the changeset viewer.