Changeset 2872 for code/trunk/src/orxonox/objects/controllers
- Timestamp:
- Mar 31, 2009, 1:15:52 AM (16 years ago)
- Location:
- code/trunk/src/orxonox/objects/controllers
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/objects/controllers/HumanController.cc
r2662 r2872 35 35 #include "objects/worldentities/pawns/Pawn.h" 36 36 #include "objects/gametypes/Gametype.h" 37 #include "objects/infos/PlayerInfo.h" 37 38 38 39 namespace orxonox … … 157 158 if (pawn) 158 159 pawn->kill(); 160 else if (HumanController::localController_s->player_) 161 HumanController::localController_s->player_->stopControl(HumanController::localController_s->controllableEntity_); 159 162 } 160 163 } -
code/trunk/src/orxonox/objects/controllers/PongAI.cc
r2860 r2872 55 55 56 56 this->setConfigValues(); 57 58 // this->randomOffsetTimer_.setTimer(MAX_REACTION_TIME * (1 - this->strength_), false, this, createExecutor(createFunctor(&PongAI::calculateRandomOffset)));59 // this->ballEndPositionTimer_.setTimer(MAX_REACTION_TIME * (1 - this->strength_), false, this, createExecutor(createFunctor(&PongAI::calculateBallEndPosition)));60 // this->randomOffsetTimer_.stopTimer();61 // this->ballEndPositionTimer_.stopTimer();62 57 } 63 58 … … 88 83 if ((mypos.x > 0 && ballvel.x < 0) || (mypos.x < 0 && ballvel.x > 0)) 89 84 { 90 // Ball is flying away85 // The ball is flying away 91 86 this->ballDirection_.x = -1; 92 87 this->ballDirection_.y = 0; 93 88 89 // Move to the middle 94 90 if (mypos.z > hysteresisOffset) 95 91 move = 1; … … 99 95 else if (ballvel.x == 0) 100 96 { 101 // Ball is standing still97 // The ball is standing still 102 98 this->ballDirection_.x = 0; 103 99 this->ballDirection_.y = 0; … … 105 101 else 106 102 { 107 // Ball is approaching103 // The ball is approaching 108 104 if (this->ballDirection_.x != 1) 109 105 { 106 // The ball just startet to approach, initialize all values 110 107 this->ballDirection_.x = 1; 111 108 this->ballDirection_.y = sgn(ballvel.z); … … 115 112 this->calculateRandomOffset(); 116 113 this->calculateBallEndPosition(); 117 //this->randomOffsetTimer_.setInterval(MAX_REACTION_TIME * (1 - this->strength_));118 //this->ballEndPositionTimer_.setInterval(MAX_REACTION_TIME * (1 - this->strength_));119 //this->randomOffsetTimer_.startTimer();120 //this->ballEndPositionTimer_.startTimer();121 114 } 122 115 123 116 if (this->ballDirection_.y != sgn(ballvel.z)) 124 117 { 118 // The ball just bounced from a bound, recalculate the predicted end position 125 119 this->ballDirection_.y = sgn(ballvel.z); 126 120 127 121 this->calculateBallEndPosition(); 128 //this->ballEndPositionTimer_.startTimer();129 } 130 131 float desiredZValue = /*((1 - this->strength_) * ballpos.z) + */(/*this->strength_ * */this->ballEndPosition_)+ this->randomOffset_;122 } 123 124 // Move to the predicted end position with an additional offset (to hit the ball with the side of the bat) 125 float desiredZValue = this->ballEndPosition_ + this->randomOffset_; 132 126 133 127 if (mypos.z > desiredZValue + hysteresisOffset * (this->randomOffset_ < 0)) … … 156 150 157 151 // Both sides are equally probable 158 position *= sgn(rnd(-1,1));152 position *= rndsgn(); 159 153 160 154 // Calculate the offset in world units … … 174 168 for (float limit = 0.35; limit < this->strength_ || this->strength_ > 0.99; limit += 0.4) 175 169 { 170 // Bounce from the upper bound 176 171 if (this->ballEndPosition_ > dimension.y / 2) 177 172 { 173 // Mirror the predicted position at the upper bound and add some random error 178 174 this->ballEndPosition_ = dimension.y - this->ballEndPosition_ + (rnd(-1, 1) * dimension.y * (1 - this->strength_)); 179 175 continue; 180 176 } 177 // Bounce from the upper bound 181 178 if (this->ballEndPosition_ < -dimension.y / 2) 182 179 { 180 // Mirror the predicted position at the lower bound and add some random error 183 181 this->ballEndPosition_ = -dimension.y - this->ballEndPosition_ + (rnd(-1, 1) * dimension.y * (1 - this->strength_)); 184 182 continue; 185 183 } 184 // No bounce - break 186 185 break; 187 186 } … … 216 215 void PongAI::delayedMove() 217 216 { 217 // Get the new movement direction from the timer list 218 218 this->movement_ = this->reactionTimers_.front().second; 219 219 220 // Destroy the timer and remove it from the list 220 221 Timer<PongAI>* timer = this->reactionTimers_.front().first; 221 222 delete timer; -
code/trunk/src/orxonox/objects/controllers/PongAI.h
r2860 r2872 66 66 float strength_; 67 67 68 // Timer<PongAI> randomOffsetTimer_;69 // Timer<PongAI> ballEndPositionTimer_;70 68 std::list<std::pair<Timer<PongAI>*, char> > reactionTimers_; 71 69 char movement_;
Note: See TracChangeset
for help on using the changeset viewer.