00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00048 #include "Player.h"
00049
00060 SoccerCommand Player::deMeer5( )
00061 {
00062
00063 SoccerCommand soc(CMD_ILLEGAL);
00064 VecPosition posAgent = WM->getAgentGlobalPosition();
00065 VecPosition posBall = WM->getBallPos();
00066 int iTmp;
00067
00068 if( WM->isBeforeKickOff( ) )
00069 {
00070 if( WM->isKickOffUs( ) && WM->getPlayerNumber() == 9 )
00071 {
00072 if( WM->isBallKickable() )
00073 {
00074 VecPosition posGoal( PITCH_LENGTH/2.0,
00075 (-1 + 2*(WM->getCurrentCycle()%2)) *
00076 0.4 * SS->getGoalWidth() );
00077 soc = kickTo( posGoal, SS->getBallSpeedMax() );
00078 Log.log( 100, "take kick off" );
00079 }
00080 else
00081 {
00082 soc = intercept( false );
00083 Log.log( 100, "move to ball to take kick-off" );
00084 }
00085 ACT->putCommandInQueue( soc );
00086 ACT->putCommandInQueue( turnNeckToObject( OBJECT_BALL, soc ) );
00087 return soc;
00088 }
00089 if( formations->getFormation() != FT_INITIAL ||
00090 posAgent.getDistanceTo( WM->getStrategicPosition() ) > 2.0 )
00091 {
00092 formations->setFormation( FT_INITIAL );
00093 ACT->putCommandInQueue( soc=teleportToPos( WM->getStrategicPosition() ));
00094 }
00095 else
00096 {
00097 ACT->putCommandInQueue( soc=turnBodyToPoint( VecPosition( 0, 0 ), 0 ) );
00098 ACT->putCommandInQueue( alignNeckWithBody( ) );
00099 }
00100 }
00101 else
00102 {
00103 formations->setFormation( FT_433_OFFENSIVE );
00104 soc.commandType = CMD_ILLEGAL;
00105
00106 if( WM->getConfidence( OBJECT_BALL ) < PS->getBallConfThr() )
00107 {
00108 ACT->putCommandInQueue( soc = searchBall() );
00109 ACT->putCommandInQueue( alignNeckWithBody( ) );
00110 }
00111 else if( WM->isBallKickable())
00112 {
00113 VecPosition posGoal( PITCH_LENGTH/2.0,
00114 (-1 + 2*(WM->getCurrentCycle()%2)) * 0.4 * SS->getGoalWidth() );
00115 soc = kickTo( posGoal, SS->getBallSpeedMax() );
00116
00117 ACT->putCommandInQueue( soc );
00118 ACT->putCommandInQueue( turnNeckToObject( OBJECT_BALL, soc ) );
00119 Log.log( 100, "kick ball" );
00120 }
00121 else if( WM->getFastestInSetTo( OBJECT_SET_TEAMMATES, OBJECT_BALL, &iTmp )
00122 == WM->getAgentObjectType() && !WM->isDeadBallThem() )
00123 {
00124 Log.log( 100, "I am fastest to ball; can get there in %d cycles", iTmp );
00125 soc = intercept( false );
00126
00127 if( soc.commandType == CMD_DASH &&
00128 WM->getAgentStamina().getStamina() <
00129 SS->getRecoverDecThr()*SS->getStaminaMax()+200 )
00130 {
00131 soc.dPower = 30.0 * WM->getAgentStamina().getRecovery();
00132 ACT->putCommandInQueue( soc );
00133 ACT->putCommandInQueue( turnNeckToObject( OBJECT_BALL, soc ) );
00134 }
00135 else
00136 {
00137 ACT->putCommandInQueue( soc );
00138 ACT->putCommandInQueue( turnNeckToObject( OBJECT_BALL, soc ) );
00139 }
00140 }
00141 else if( posAgent.getDistanceTo(WM->getStrategicPosition()) >
00142 1.5 + fabs(posAgent.getX()-posBall.getX())/10.0)
00143
00144 {
00145 if( WM->getAgentStamina().getStamina() >
00146 SS->getRecoverDecThr()*SS->getStaminaMax()+800 )
00147 {
00148 soc = moveToPos(WM->getStrategicPosition(),
00149 PS->getPlayerWhenToTurnAngle());
00150 ACT->putCommandInQueue( soc );
00151 ACT->putCommandInQueue( turnNeckToObject( OBJECT_BALL, soc ) );
00152 }
00153 else
00154 {
00155 ACT->putCommandInQueue( soc = turnBodyToObject( OBJECT_BALL ) );
00156 ACT->putCommandInQueue( turnNeckToObject( OBJECT_BALL, soc ) );
00157 }
00158 }
00159 else if( fabs( WM->getRelativeAngle( OBJECT_BALL ) ) > 1.0 )
00160 {
00161 ACT->putCommandInQueue( soc = turnBodyToObject( OBJECT_BALL ) );
00162 ACT->putCommandInQueue( turnNeckToObject( OBJECT_BALL, soc ) );
00163 }
00164 else
00165 ACT->putCommandInQueue( SoccerCommand(CMD_TURNNECK,0.0) );
00166 }
00167 return soc;
00168 }
00169
00176 SoccerCommand Player::deMeer5_goalie( )
00177 {
00178 int i;
00179 SoccerCommand soc;
00180 VecPosition posAgent = WM->getAgentGlobalPosition();
00181 AngDeg angBody = WM->getAgentGlobalBodyAngle();
00182
00183
00184 static const VecPosition posLeftTop( -PITCH_LENGTH/2.0 +
00185 0.7*PENALTY_AREA_LENGTH, -PENALTY_AREA_WIDTH/4.0 );
00186 static const VecPosition posRightTop( -PITCH_LENGTH/2.0 +
00187 0.7*PENALTY_AREA_LENGTH, +PENALTY_AREA_WIDTH/4.0 );
00188
00189
00190 static Line lineFront = Line::makeLineFromTwoPoints(posLeftTop,posRightTop);
00191 static Line lineLeft = Line::makeLineFromTwoPoints(
00192 VecPosition( -50.0, posLeftTop.getY()), posLeftTop );
00193 static Line lineRight = Line::makeLineFromTwoPoints(
00194 VecPosition( -50.0, posRightTop.getY()),posRightTop );
00195
00196
00197 if( WM->isBeforeKickOff( ) )
00198 {
00199 if( formations->getFormation() != FT_INITIAL ||
00200 posAgent.getDistanceTo( WM->getStrategicPosition() ) > 2.0 )
00201 {
00202 formations->setFormation( FT_INITIAL );
00203 ACT->putCommandInQueue( soc=teleportToPos(WM->getStrategicPosition()) );
00204 }
00205 else
00206 {
00207 ACT->putCommandInQueue( soc = turnBodyToPoint( VecPosition( 0, 0 ), 0 ));
00208 ACT->putCommandInQueue( alignNeckWithBody( ) );
00209 }
00210 return soc;
00211 }
00212
00213 if( WM->getConfidence( OBJECT_BALL ) < PS->getBallConfThr() )
00214 {
00215 ACT->putCommandInQueue( searchBall() );
00216 ACT->putCommandInQueue( alignNeckWithBody( ) );
00217 }
00218 else if( WM->getPlayMode() == PM_PLAY_ON || WM->isFreeKickThem() ||
00219 WM->isCornerKickThem() )
00220 {
00221 if( WM->isBallCatchable() )
00222 {
00223 ACT->putCommandInQueue( soc = catchBall() );
00224 ACT->putCommandInQueue( turnNeckToObject( OBJECT_BALL, soc ) );
00225 }
00226 else if( WM->isBallKickable() )
00227 {
00228 soc = kickTo( VecPosition(0,posAgent.getY()*2.0), 2.0 );
00229 ACT->putCommandInQueue( soc );
00230 ACT->putCommandInQueue( turnNeckToObject( OBJECT_BALL, soc ) );
00231 }
00232 else if( WM->isInOwnPenaltyArea( getInterceptionPointBall( &i, true ) ) &&
00233 WM->getFastestInSetTo( OBJECT_SET_PLAYERS, OBJECT_BALL, &i ) ==
00234 WM->getAgentObjectType() )
00235 {
00236 ACT->putCommandInQueue( soc = intercept( true ) );
00237 ACT->putCommandInQueue( turnNeckToObject( OBJECT_BALL, soc ) );
00238 }
00239 else
00240 {
00241
00242 VecPosition posMyGoal = ( WM->getSide() == SIDE_LEFT )
00243 ? SoccerTypes::getGlobalPositionFlag(OBJECT_GOAL_L, SIDE_LEFT )
00244 : SoccerTypes::getGlobalPositionFlag(OBJECT_GOAL_R, SIDE_RIGHT);
00245 Line lineBall = Line::makeLineFromTwoPoints( WM->getBallPos(),posMyGoal);
00246
00247
00248 VecPosition posIntersect = lineFront.getIntersection( lineBall );
00249
00250
00251 if (posIntersect.isRightOf( posRightTop ) )
00252 posIntersect = lineRight.getIntersection( lineBall );
00253 else if (posIntersect.isLeftOf( posLeftTop ) )
00254 posIntersect = lineLeft.getIntersection( lineBall );
00255
00256 if( posIntersect.getX() < -49.0 )
00257 posIntersect.setX( -49.0 );
00258
00259
00260 if( posIntersect.getDistanceTo( WM->getAgentGlobalPosition() ) > 0.5 )
00261 {
00262 soc = moveToPos( posIntersect, PS->getPlayerWhenToTurnAngle() );
00263 ACT->putCommandInQueue( soc );
00264 ACT->putCommandInQueue( turnNeckToObject( OBJECT_BALL, soc ) );
00265 }
00266 else
00267 {
00268 ACT->putCommandInQueue( soc = turnBodyToObject( OBJECT_BALL ) );
00269 ACT->putCommandInQueue( turnNeckToObject( OBJECT_BALL, soc ) );
00270 }
00271 }
00272 }
00273 else if( WM->isFreeKickUs() == true || WM->isGoalKickUs() == true )
00274 {
00275 if( WM->isBallKickable() )
00276 {
00277 if( WM->getTimeSinceLastCatch() == 25 && WM->isFreeKickUs() )
00278 {
00279
00280 if( WM->getNrInSetInCircle( OBJECT_SET_OPPONENTS,
00281 Circle(posRightTop, 15.0 )) <
00282 WM->getNrInSetInCircle( OBJECT_SET_OPPONENTS,
00283 Circle(posLeftTop, 15.0 )) )
00284 soc.makeCommand( CMD_MOVE,posRightTop.getX(),posRightTop.getY(),0.0);
00285 else
00286 soc.makeCommand( CMD_MOVE,posLeftTop.getX(), posLeftTop.getY(), 0.0);
00287 ACT->putCommandInQueue( soc );
00288 }
00289 else if( WM->getTimeSinceLastCatch() > 28 )
00290 {
00291 soc = kickTo( VecPosition(0,posAgent.getY()*2.0), 2.0 );
00292 ACT->putCommandInQueue( soc );
00293 }
00294 else if( WM->getTimeSinceLastCatch() < 25 )
00295 {
00296 VecPosition posSide( 0.0, posAgent.getY() );
00297 if( fabs( (posSide - posAgent).getDirection() - angBody) > 10 )
00298 {
00299 soc = turnBodyToPoint( posSide );
00300 ACT->putCommandInQueue( soc );
00301 }
00302 ACT->putCommandInQueue( turnNeckToObject( OBJECT_BALL, soc ) );
00303 }
00304 }
00305 else if( WM->isGoalKickUs() )
00306 {
00307 ACT->putCommandInQueue( soc = intercept( true ) );
00308 ACT->putCommandInQueue( turnNeckToObject( OBJECT_BALL, soc ) );
00309 }
00310 else
00311 ACT->putCommandInQueue( turnNeckToObject( OBJECT_BALL, soc ) );
00312 }
00313 else
00314 {
00315 ACT->putCommandInQueue( soc = turnBodyToObject( OBJECT_BALL ) );
00316 ACT->putCommandInQueue( turnNeckToObject( OBJECT_BALL, soc ) );
00317 }
00318 return soc;
00319 }
00320
00321