当前位置:网站首页>RoboCup (2D) experiment 50 questions and the meaning of main functions
RoboCup (2D) experiment 50 questions and the meaning of main functions
2022-07-28 10:37:00 【Bald but naturally】
For how to play a ball game, please refer to my previous blog
The connection point of blog is here
Main function meaning :
soc = dribble(ang, DRIBBLE_FAST); // With the ball ( angle , Fast belt )
soc = dribble(ang, DRIBBLE_Slow);
soc=dribble(ang,DRIBBLE_WITHBALL);// Safety belt
soc=leadingPass(o,1);// To the goal o Pass to o In front of the 1m
soc=kickBallCloseToBody(-120);// The ball rotates counterclockwise around itself
soc=kickTo(VecPosition(0,0),SS->getBallSpeedMax())// To point (0,0) Shoot at maximum speed
soc=mark(OBJECT_BALL,5,MARK_GOAL);// Mark and defend
soc=intercept(true)// Break the ball
soc=ShootToGoalex(OBJECT_GOAL_L)// A shot
soc=moveToPos(pos,20);// With 20 The angle is close to the target point pos
ACT->putCommandInQueue(soc); // Put the action into the command queue
ACT->putCommandInQueue( turnNeckToObject(OBJECT_BALL,soc)); // Turn your neck to the ball while doing the action
AngDeg ang=(VecPosition(52.5,0)-posAgent).getDirection()// Ask for the angle between the goal and me
Circle cir(posAgent,7);// Define a radius that is itself the center of a circle 7m The circle of
WM->getNrInSetInCircle(OBJECT_SET_OPPONENTS,cir);// Get the number of opponents in the circle
WM->getClosestInSetTo(OBJECT_SET_OPPONENTS,posAgent);// Get my nearest opponent
WM->getGlobalPosition(o);// obtain o Coordinates of
WM->isOpponentAtAngle(30,30)// Judge the front -30 To 30 Is there an opponent
WM->getCurrentCircle()// Get the number of cycles
SS->getGoalWidth()// Get the goal width
WM->getBallPos().getX()// Get the ball x coordinate
WM->getAgentObjectType()// Get your player type
WM->getOppGoalieType()// Get the opposite player type
WM->getPlayerNumber() // Get player number
WM->isInTheirPenaltyArea(WM->getBallPos())// Judge whether the ball is in the opponent's penalty area
WM->isBallKickable()// Judge whether you can play football
WM->getAgentGlobalPosition()// Get my current coordinates
WM->getClosestInSetTo(OBJECT_SET_TEAMMATES,posAgent)// Get the player closest to me
WM->getSecondClosestInSetTo(OBJECT_SET_TEAMMATES,OBJECT_BALL)// The second is near
WM->isBallInOurPossesion()// Judge whether our side controls the ball
WM->getOffsideX()// Get offside line
WM->isCornerKickUs()// Judge whether it is our corner kick mode
WM->isOffsideUs()// Judge whether it is our sideline mode
for(ObjectTo=iterateObjectStart(iIndex,OBJECT_SET_TEAMMATES);o!=OBJECT_ILLEGAL;o=iterateObjectNext(iIndex,OBJECT_SET_TEAMMATES))// Traverse our players
posAgent.getY()// Current players y coordinate
Experiment 50 questions
The following code has not been rigorously tested
For reference only · Independent thinking
(1) stay playOn In mode , Get the ball and quickly dribble forward .
if ( WM->isBallKickable())
{
AngDeg ang = 0.0;
soc = dribble(ang, DRIBBLE_FAST);
ACT->putCommandInQueue(soc);
ACT->putCommandInQueue( turnNeckToObject(OBJECT_BALL,soc));
}
(2) stay PlayOn In mode , After getting the ball, dribble slowly towards the goal .
if ( WM->isBallKickable())
{
AngDeg ang=(VecPosition(52.5,0)-posAgent).getDirection();
soc=dribble(ang, DRIBBLE_SLOW);
ACT->putCommandInQueue(soc);
ACT->putCommandInQueue( turnNeckToObject(OBJECT_BALL,soc));
}
(3) stay playOn In mode , After getting the ball, turn it counterclockwise around your body .
if ( WM->isBallKickable())
{
soc=kickBallCloseToBody(-120);
ACT->putCommandInQueue(soc);
ACT->putCommandInQueue( turnNeckToObject(OBJECT_BALL,soc));
}
(4) stay playOn In mode , When you get the ball , Someone is pressing ( Around oneself 7 The range of meters is at least 1 Opposing players ), Then kick the ball to the other side away from the opponent , Safety belt
( If the opponent is on the right , Kick the ball to the left , Such as the left side of the opponent , Kick the ball to the right ).
if ( WM->isBallKickable())
{
Circle cir(posAgent,7);
int num=WM->getNrInSetInCircle(OBJECT_SET_OPPONENTS,cir);
AngDeg ang=0;
if(num>0)
{
ObjectT o=WM->getClosestInSetTo(OBJECT_SET_OPPONENTS,posAgent);
VecPosition p=WM->getGlobalPosition(o);
if((p-posAgent).getDirection()>=0)
{
ang+=45;
soc=dribble(ang,DRIBBLE_WITHBALL);
}
else{
ang-=45;
soc=dribble(ang,DRIBBLE_WITHBALL);
}
}
/*else{ AngDeg ang=(VecPosition(52.5,0)-posAgent).getDirection(); soc=dribble(ang,DRIBBLE_WITHBALL); }*/
ACT->putCommandInQueue(soc);
ACT->putCommandInQueue( turnNeckToObject(OBJECT_BALL,soc));
}
(5) stay playOn In mode , After getting the ball , Someone is pressing , Pass to the nearest teammate ; Otherwise, quickly dribble towards the goal .
if ( WM->isBallKickable())
{
{
Circle cir(posAgent,7);
int num=WM->getNrInSetInCircle(OBJECT_SET_OPPONENTS,cir)
if(num>0)
{
soc=leadingPass(WM->getClosestInSetTo(OBJECT_SET_TEAMMATES,posAgent) ,1);
}
else
{
AngDeg ang=(VecPosition(52.5,0)-posAgent).getDirection();
soc=dribble(ang, DRIBBLE_FAST);}
}
ACT->putCommandInQueue(soc);
ACT->putCommandInQueue( turnNeckToObject(OBJECT_BALL,soc));
}
(6) stay playOn In mode , If someone presses ( Around oneself 7 The range of meters is at least 1 Opposing players ), Then take the ball safely ; Otherwise, quickly dribble towards the goal .
if ( WM->isBallKickable())
{
{
Circle cir(posAgent,7);
int num=WM->getNrInSetInCircle(OBJECT_SET_OPPONENTS,cir)
AngDeg ang=(VecPositoin(52.5,0)-posAgent).getDirection();
if(num>0)
soc=dribble(0,DRIBBLE_WITHBALL);
else
soc=dribble(ang,DRIBBLE_FAST);
}
ACT->putCommandInQueue(soc);
ACT->putCommandInQueue( turnNeckToObject(OBJECT_BALL,soc));
}
(7) stay PlayOn In mode , If there is no other player ahead , Then shoot directly at the opponent's side at the maximum speed ( The number of cycles is even , The right side of the goal shoots , The period is odd , Shoot to the left in the direction of the goal ).
if ( WM->isBallKickable())
{
if(WM->isOpponentAtAngle(30,30)==false)
{
VecPosition posGoal(PITCH_LENGTH/2.0,
(-1+2*(WM->getCurrentCircle()%2))*0.4*SS->getGoalWidth());
soc=kickTo(posGoal,SS->getBallSpeedMax());
}
ACT->putCommandInQueue(soc);
ACT->putCommandInQueue( turnNeckToObject(OBJECT_BALL,soc));
}
(8) stay playOn In mode , When you get the ball , Play to the center of the court in our half ; After half a court , Quickly take the ball to the opponent's goal .
if ( WM->isBallKickable())
{
if(WM->getBallPos().getX()<0)
soc=kickTo(VecPosition(0,0),1.0);
else
{
AngDeg ang=(VecPositoin(52.5,0)-posAgent).getDirection();
soc=dribble(ang,DRIBBLE_FAST);
}
ACT->putCommandInQueue(soc);
ACT->putCommandInQueue( turnNeckToObject(OBJECT_BALL,soc));
}
(9) stay PlayOn In mode , When you get the ball , Pass it to the nearest teammate who is not defended around ( No one defends around it 5 Whether there is an opponent's player in the range of meters ) Foot .
if ( WM->isBallKickable())
{
Circle cir(WM->getClosestInSetTo(OBJECT_SET_TEAMMATES,posAgent),5);
int num=WM->getNrInSetInCircle(OBJECT_SET_OPPONENTS,cir);
if(num=0)
soc=leadingPass(WM->getClosestInSetTo(OBJECT_SET_TEAMMATES, posAgent) ,1.0);
ACT->putCommandInQueue(soc);
ACT->putCommandInQueue( turnNeckToObject(OBJECT_BALL,soc));
}
(10) stay playOn In mode , When you get the ball , Pass the ball to the unguarded teammate closest to your front ( Judge your teammates 5 Are there any defenders in the range of meters ).
if ( WM->isBallKickable())
{
{
Circle cir(WM->getClosestInSetTo(OBJECT_SET_TEAMMATES,posAgent),5);
int num=WM->getNrInSetInCircle(OBJECT_SET_OPPONENTS,cir);
VecPosition diff=WM->getGlobalPosition(WM->getClosestInSetTo(
OBJECT_SET_TEAMMATES,posAgent));
AngDeg ang=(diff-posAgent).getDirection();
if(num=0&&ang>=-90&&ang<=90)
soc=leadingPass(WM->getClosestInSetTo(OBJECT_SET_TEAMMATES,posAgent) ,1.0);
}
ACT->putCommandInQueue(soc);
ACT->putCommandInQueue( turnNeckToObject(OBJECT_BALL,soc));
}
(11) stay playOn In mode , After getting the ball , Pass to the next nearest teammate in our half ; In the other half , Not 10 Player No. passes to 10 Number player ,10 Player No. 1 quickly dribbles the ball towards the goal .
if ( WM->isBallKickable())
{
if(WM->getBallPos().getX()<0)
{
soc=leadingPass(WM->getSecondClosestInSetTo(OBJECT_SET_TEAMMATES,posAgent)
,1.0);
}
if(WM->getBallPos().getX()>=0)
{
if(WM->getAgentObjectType()!=OBJECT_TEANMATE_10)
{
soc=leadingPass(OBJECT_TEANMATE_10 ,1.0)
}
if(WM->getAgentObjectType()==OBJECT_TEANMATE_10)
{
AngDeg ang=(VecPositoin(52.5,0)-posAgent).getDirection();
soc=dribble(ang,DRIBBLE_FAST);
}
}
ACT->putCommandInQueue(soc);
ACT->putCommandInQueue( turnNeckToObject(OBJECT_BALL,soc));
}
(12) stay playOn In mode , If in our half , Then slowly dribble forward , If in the other half , Then quickly dribble towards the goal .
if ( WM->isBallKickable())
{
if(WM->getBallPos().getX()<0)
soc=dribble(0,DRIBBLE_SLOW);
if(WM->getBallPos().getX()>=0)
{
AngDeg ang=(VecPositoin(52.5,0)-posAgent).getDirection();
soc=dribble(ang,DRIBBLE_FAST);
}
ACT->putCommandInQueue(soc);
ACT->putCommandInQueue( turnNeckToObject(OBJECT_BALL,soc));
}
(13) stay playOn In mode , When you get the ball , If it is 2 Number , Then kick the ball to the left sideline , If it is 5 Number , Then kick the ball to the right sideline , And turn your neck to the ball ; Other players dribble forward .
if ( WM->isBallKickable())
{
if(WM->getAgentObjectType()==OBJECT_TEAMMATE_2)
{
soc=kickTo(VecPosition(WM->getBallPos().getX(),-34),1.0);
ACT->putCommandInQueue(turnNeckToObject(OBJECT_BALL,soc));}
else if(WM->getPlayerNumber()==5)
{
soc=kickTo(VecPosition(WM->getBallPos().getX(),34),1.0);
}
else
soc=dribble(0,DRIBBLE_WITHBALL);
ACT->putCommandInQueue(soc);
ACT->putCommandInQueue( turnNeckToObject(OBJECT_BALL,soc));
}
//(14) stay playOn In mode , When you get the ball , If I were 4 Number , Pass it to 7 Number ; Otherwise , Pass to the nearest teammate ; After arriving at the opponent's penalty area, shoot at the side of the goal with a large gap at the maximum speed .
if ( WM->isBallKickable())
{
if(WM->isInTheirPenaltyArea(WM->getBallPos())) {
posGoalie=WM->getGlobalPosition(WM->getOppGoalieType());
ang_goalie=(posGoalie-posAgent).getDirection();
angup=(VecPosition(52.5,6.0)-posAgent).getDirection();
angdown=(VecPosition(52.5,-6.0)-posAgent).getDirection();
if(std::fabs(angup-ang_goalie)>std::fabs(angdown-ang_goalie))
soc=kickTo(VecPosition(52.5,6.0),SS->getBallSpeedMax());
else
soc=kickTo(VecPosition(52.5,-6.0),SS->getBallSpeedMax());
}
if(WM->getPlayerNumber()==4)
soc=leadingPass(OBJECT_TEAMMATE_7,1.0);
else leadingPass(WM->getClosestInSetTo(OBJECT_SET_TEAMMATES,posAgent),1.0);
ACT->putCommandInQueue(soc);
ACT->putCommandInQueue( turnNeckToObject(OBJECT_BALL,soc));
}
(15) stay playOn In mode , Vertical dribble .
if ( WM->isBallKickable())
{
if(WM->getBallPos().getY()<=0) soc=dribble(90,DRIBBLE_WITHBALL);
else soc=dribble(-90,DRIBBLE_WITHBALL);
ACT->putCommandInQueue(soc);
ACT->putCommandInQueue( turnNeckToObject(OBJECT_BALL,soc));
}
//(16) stay playOn In mode , Get the ball and take it to the center of the court , Then pass it to the nearest player .
if ( WM->isBallKickable())
{
if(posAgent.getDistanceTo(posBall)>2.0) {
AngDeg ang=(VecPosition(0,0)-posAgent).getDirection();
soc=dribble(ang,DRIBBLE_WITHBALL);
}
else
soc=leadingPass(WM->getClosestInSetTo(OBJECT_SET_TEAMMATES,posAgent),1.0);
ACT->putCommandInQueue(soc);
ACT->putCommandInQueue( turnNeckToObject(OBJECT_BALL,soc));
}
//(17) stay playOn In mode ,10 No. 1 moves forward with the ball , then 5 Number followed 10 March forward together , The two players are at the same level On , And the distance is 5.
if(WM->getPlayerNumber()!=10)
soc=leadingPass(OBJECT_TEAMMATE_10,1.0);
else soc=dribble(0,DRIBBLE_SLOW);
if(WM->getPlayerNumber()==5) {
VecPosition pos(WM->getBallPos().getX()-5,WM->getBallPos().getY());
soc=moveToPos(pos,20);
}
//(18) stay playOn In mode , 5 The distance between player No. 1 and the opponent holding the ball is always 5.
if(WM->getPlayerNumber()==5) {
VecPosition pos(WM->getBallPos().getX()-5,WM->getBallPos().getY());
soc=moveToPos(pos,20);
}
//(19) stay playOn In mode ,2 Number and 4 Let's go to mark the players who take the ball with each other
if(WM->getAgentObjectType()==OBJECT_TEAMMATE_2){
VecPosition pos(WM->getBallPos().getX()-5,WM->getBallPos().getY())
soc=moveToPos(pos,20);
}
if(WM->getAgentObjectType()==OBJECT_TEAMMATE_4)
{
VecPosition pos(WM->getBallPos().getX(),WM->getBallPos().getY()-5)
soc=moveToPos(pos,20);
}
//(20) stay playon In mode , If it is 10 Number player , In a kickable state , If your own x Axis coordinates are greater than 30, Then shoot directly at the goal point far away from the opposing player .
if ( WM->isBallKickable())
{
if(WM->getPlayerNumber()==10&&posAgent.getX()>30)
{
posGoalie=WM->getGlobalPosition(WM->getOppGoalieType());
ang_goalie=(posGoalie-posAgent).getDirection();
angup=(VecPosition(52.5,6.0)-posAgent).getDirection();
angdown=(VecPosition(52.5,-6.0)-posAgent).getDirection();
if(std::fabs(angup-ang_goalie)>std::fabs(angdown-ang_goalie))
soc=kickTo(VecPosition(52.5,6.0),SS->getBallSpeedMax());
}
ACT->putCommandInQueue(soc);
ACT->putCommandInQueue( turnNeckToObject(OBJECT_BALL,soc));
}
//(21) stay playOn In mode , Take the ball and pass it to the nearest teammate closer to the opponent's goal .
if ( WM->isBallKickable())
{
soc=leadPass(WM->getClosestInSetTo(OBJECT_SET_TEAMMATES,WM->getPosOpponentGoal()),1.0);
ACT->putCommandInQueue(soc);
ACT->putCommandInQueue( turnNeckToObject(OBJECT_BALL,soc));
}
//(22) stay playOn In mode , After taking the ball , Search ahead -30~30 Distance between yourself 20 Does mineI have teammates , If there is, pass it to the teammate , Otherwise, take the ball by yourself .
if ( WM->isBallKickable())
{
VecPosition posTeam;
AngDeg angTeam;
int iIndex;
for(ObjectTo=iterateObjectStart(iIndex,OBJECT_SET_TEAMMATES);o!=OBJECT_ILLEGAL;o=iterateObjectNext(iIndex,OBJECT_SET_TEAMMATES))
{
posTeam=getGlobalPosition(o);
angTeam=(posTeam- posAgent).getDirection();
if(angA<=angTeam&&angTeam<=angB&&posAgent.getDistanceTo(posTeam)< dDist)
soc=leadPass(o,1.0);
ACT->putCommandInQueue(soc);
ACT->putCommandInQueue( turnNeckToObject(OBJECT_BALL,soc));
}
//(23). stay playOn In mode , If you get the ball in our half , Then kick to the midfield line at the maximum speed , If you get the ball in the enemy half , Then kick at the enemy's goal at the maximum speed
if ( WM->isBallKickable())
{
if(WM->getBallPos().getX()<=0)
{
VecPosition pos(0,WM->grtBallPos().getY());
soc=kickTo(pos,SS->getBallSpeedMax());
}
else
soc=kickTo(VecPosition(52.5,0),SS->getBallSpeedMax());
ACT->putCommandInQueue(soc);
ACT->putCommandInQueue( turnNeckToObject(OBJECT_BALL,soc));
}
//(24). stay playOn In mode , If it is 9 No. 1 gets the ball , Then order 9 Number and 10 No. 1 rushed to the enemy goal at the same time , In front of the goal ,9 Pass the number to 10 Number , from 10 Shoot on the th
if (WM->getPlayerNumber()==9&& WM->isBallKickable())
{
AngDeg ang=(VecPositoin(52.5,0)-posAgent).getDirection();
soc=dribble(ang,DRIBBLE_FAST);
if(WM->getAgentObjectType()==OBJECT_TEANMATE_10)
soc=moveToPos(VecPosition(52.5,0),20);
if(WM->isInTheirPenaltyArea(WM->getBallPos()))
{
soc=leadingPass(OBJECT_TEAMMATE_10,1.0);
if(WM->getAgentObjectType()==OBJECT_TEANMATE_10)
soc=kickTo(VecPosition(52.5,0),SS->getBallSpeedMax());
}
}
//(25). stay playOn In mode , If I were 4 Player No. 1 and got the ball , To 7 Number player , meanwhile 7 Player No. 1 passes it to 9 Number player ,9 Player No. 1 continues to rush to the goal with maximum speed and shoot .
if(WM->getPlayerNumber()==4&&WM->isBallKickable())
soc=leadingPass(OBJECT_TEAMMATE_7,1);
if(WM->getPlayerNumber()==7&&WM->isBallKickable())
soc=leadingPass(OBJECT_TEAMMATE_9,1);
if(WM->getPlayerNumber()==9&&WM->isBallKickable())
{
if(WM->getBallPos().getX()<40)
soc=dribble((VecPosition(40,0)-posAgent).getDirection(),DRIBBLE_FAST);
else soc=ShootToGoalex(OBJECT_GOAL_L);
}
//(26) stay playon In mode , Find out y Axis equals 0 The number of opposing players on both sides of , Pass the ball to the side with less opponents , also x The teammate with the largest axis value .
//WorldModel.cpp
ObjectT WorldModel::getMaxXTeammateInSide(bool isOwnSize)
{
int iIndex;
ObjectT maxMate = OBJECT_ILLEGAL;
for (ObjectT o = iterateObjectStart(iIndex, OBJECT_SET_TEAMMATES);
o != OBJECT_ILLEGAL;
o = iterateObjectNext(iIndex, OBJECT_SET_TEAMMATES))
{
VecPosition oPos = getGlobalPosition(o);
if((isOwnSize && oPos.getY() >= 0) ||
(!isOwnSize && oPos.getY() <= 0))
{
if (maxMate == OBJECT_ILLEGAL || oPos.getX() > getGlobalPosition(maxMate).getX())
maxMate = o;
}
}
iterate ObjectDone(iIndex);
return maxMate;
}
bool WorldModel:: isOwnSideOpponentMost()
{
int ownSideCount = 0;
int count = 0;
int iIndex;
ObjectT maxMate = OBJECT_ILLEGAL;
for (ObjectT o = iterateObjectStart(iIndex, OBJECT_SET_OPPONENTS);
o != OBJECT_ILLEGAL;
o = iterateObjectNext(iIndex, OBJECT_SET_OPPONENTS))
{
if (getGlobalPosition(o).getY() > 0)
ownSideCount++;
count++;
}
return ownSideCount > count - ownSideCount;
}
//PlayerTeams.cpp
else if( WM->isBallKickable())
{
ObjectT mate = WM->getMaxXTeammateInSide(!WM->isOwnSideOpponentMost());
soc = leadingPass(mate, 1, DIR_CENTER);
ACT->putCommandInQueue(soc);
ACT->putCommandInQueue( turnNeckToObject(OBJECT_BALL,soc));
return soc;
}
//(27) stay playon In mode , If you are 7 If there are two or more opponents within meters , Pass to x The teammate with the largest axis value .
if(WM->isBallKickable()){
Circle cir(posAgent,7);
int num=WM->getNrInSetInCircle(OBJECT_SET_OPPONENTS,cir);
if(num>=2){
ObjectT ClosestG;
ClosestG=WM->getClosestInSetTo(OBJECT_SET_TEAMMATES,VecPosition(52.5,0));
soc=leadingPass(ClosestG,1);
ACT->putCommandInQueue(soc);
ACT->putCommandInQueue( turnNeckToObject( OBJECT_BALL, soc ) );
}
}
//(28) stay playon In mode , Find your offside line , If there are teammates who can play football , If you are 10 Number . that 10 The player runs vertically to the offside line x Axis value -2 rice ,y The point where the axis does not change .
if(WM->isBallInOurPossesion() && WM->getPlayerNumber==10)
soc=moveToPos(WM->getOffsideX()-2,posAgent.getY(),20);
//(29) stay playon In the mode of , Find the linear equation of the ball's motion direction , And find the distance from yourself to the straight line , If the distance is less than 4 Words , Then run vertically to the straight line .
Line ballRun = Line::makeLineFromPositionAndAngle(WM->getBallPos(),WM>getBallDirection());
if (ballRun.getDistanceWithPoint(WM->getAgentGlobalPosition()) < 4)
{
soc = moveToPos(ballRun.getPointOnLineClosestTo(WM->getAgentGlobalPosition()), 20);
ACT->putCommandInQueue(soc);
ACT->putCommandInQueue( turnNeckToObject(OBJECT_BALL,soc));
return soc;
}
//(30) stay playon In the mode of , If you can play football , If you are 7 If there is no other player in mineI , Then quickly dribble , The direction of dribbling is towards the point (53,0) Direction .
if(WM->isBallKickable()){
Circle cir(posAgent,7);
int num=WM->getNrInSetInCircle(OBJECT_SET_OPPONENTS,cir);
if(num==0){
AngDeg angDribble=(VecPosition(53.0,0)-posAgent).getDirection();
soc=dribble(angDribble,DRIBBLE_FAST);
ACT->putCommandInQueue(soc);
ACT->putCommandInQueue( turnNeckToObject( OBJECT_BALL, soc ) );
}
}
//(31) stay playon In the mode of , If our teammates are the closest to the ball , If my x Coordinates less than 30 Words , And I am 10 Number , Then I run to the coordinates of the ball and add (0,10) Coordinate position of .
if(WM->isBallInOurPossesion() && WM->getPlayerNumber==10 && posAgent.getX()<30)
VecPosition pos=WM->getBallPos()+VecPosition(0,10);
moveToPos(pos,20);
//(32) stay playon In the mode of , When you find no teammates ahead , If you are 5 If Mi Nei has two or more opponents , Then pass the ball to the nearest teammate .
Circle cir(posAgent,7);
int num=WM->getNrInSetInCircle(OBJECT_SET_OPPONENTS,cir);
if(WM->isTeammateAtAngle(-30,30)==false && num>=2)
{
leadingPass(WM->getClosestInSetTo(OBJECT_SET_TEAMMATES,posAgent),1.0);
}
//(33 ) In our corner mode , If you are 10 Number player , Then run to the corner , And kick off ( The ball can be kicked , Then kick the ball to 9 Number ); If you are 9 Number player , Then run near the corner ( Choose one at random ), Get ready to catch the ball , Other players are running away from home .
else if (WM->isCornerKickUs())
{
if (WM->getAgentObjectType() == OBJECT_TEAMMATE_10)
{
if (WM->isBallKickable())
soc = leadingPass(OBJECT_TEAMMATE_9, 1);
else
soc = moveToPos(WM->getBallPos(), PS->getPlayerWhenToTurnAngle());
}
if (WM->getAgentObjectType() == OBJECT_TEAMMATE_9)
{
VecPosition ball = WM->getBallPos();
VecPosition pos(-(ball.getX())/fabs(ball.getX()) * 5 + ball.getX(),
-(ball.getY())/fabs(ball.getY()) * 5 + ball.getY());
soc = moveToPos(pos, PS->getPlayerWhenToTurnAngle());
}
ACT->putCommandInQueue( soc );
ACT->putCommandInQueue( turnNeckToObject( OBJECT_BALL, soc ) );
}
//34 In our lineball mode , If you are the player closest to the ball , Run to the ball ; And kick off ( When the ball is at your feet, pass it to your nearest teammate ).
else if(WM->isOffsideUs()) {
if(WM->getFastestInSetTo( OBJECT_SET_TEAMMATES, OBJECT_BALL, &iTmp )
== WM->getAgentObjectType()) {
if(WM->isBallKickable()) {
ObjectT objTea =WM->getClosestInSetTo(OBJECT_SET_TEAMMATES,WM->getAgentObjectType(),&dist);
VecPosition posTea=WM->getGlobalPosition(objTea);
soc=kickTo(posTea,SS->getBallSpeedMax());
}
else {
soc=moveToPos(WM->getBallPos(),20);
}
ACT->putCommandInQueue(soc);
}
}
//35 In our lineball mode , On the left side of our half , By 2 Send it on the th ; If it is the right side of our half , By 5 Send it on the th ; The ball is in 2 Number or 5 At the foot of number , Then kick to the teammate closest to you .
else if(WM->isOffsideUs()) {
VecPosition posBall=WM->getBallPos();
if((posBall.getX()<0 && posBall.getY()<0 && WM->getPlayerNumber()==2)||
((posBall.getX()<0 && posBall.getY()>0 && WM->getPlayerNumber()==5)))
{
if(WM->isBallKickable()) {
ObjectT objTea =WM->getClosestInSetTo(OBJECT_SET_TEAMMATES,WM->getAgentObjectType(),&dist);
VecPosition posTea=WM->getGlobalPosition(objTea);
soc=kickTo(posTea,SS->getBallSpeedMax());
}
else {
soc=moveToPos(WM->getBallPos(),20);
}
ACT->putCommandInQueue(soc);
}
}
//36. In the mode of our sideline , If I'm the second closest teammate , Then I also run towards the position of the ball , Until the distance ball 7 Range of meters
else if(WM->isOffsideUs())
{
ObjectT o=WM->getSecondClosestInSetTo(OBJECT_SET_TEAMMATES,OBJECT_BALL) ;
double myPosx=WM->getAgentGlobalPosition().getX();;
double myposy=WM->getAgentGlobalPosition().getY();;
double ballposx=WM->getBallPos().getX();;
double ballposy=WM->getBallPos().getY();;
double dis=sqrt(pow(ballposx-myPosx,2)+pow(ballposy-myposy,2));
if(WM->getAgentObjectType()==o&&dis>7)
{
soc=moveToPos( VecPosition(ballposx,ballposy ) , 20 );
ACT->putCommandInQueue( soc );
}
}
//37 In the mode of our sideline , If I were 4 No , And the teammate closest to the ball is not me , Then I will run to the coordinates of the ball plus (5,0) In the right place .
else if(WM->isOffsideUs())
{
if((WM->getPlayerNumber()==4)&&(WM-> getClosestInSetTo( OBJECT_SET_TEAMMATES, OBJECT_BALL)!=OBJECT_TEAMMATE_4))
soc=moveToPos((WM->getBallPos()+VecPosition(5,0)),20);
ACT->putCommandInQueue( soc ); // Put it in the command queue
ACT->putCommandInQueue( turnNeckToObject( OBJECT_BALL, soc ) );
}
//38 In the mode of our sideline , If I'm the second closest teammate to the ball , Then I run to the distance ball 12 Within meters , And away from the opponent's goal point (53,0) Some recent .
else if ( WM->isOffsideUs() )
{
ObjectT o = WM -> getSecondClosestInSetTo(OBJECT_SET_TEAMMATES , OBJECT_BALL) ;
if ( WM ->getAgentObjectType() == o )
{
double a = WM->getBallPos().getX() ;
double b = WM->getBallPos().getY() ;
double t ,m ,x2,y1,d,x1,y2;
t=b/( a-53);
m=53*t+b;
d=pow( 2*a+2*t*m,2) -4*( pow( t,2)+1) *(pow(a,2)+pow(m,2)-144) ;
x1 = ( ( 2*a+2*t*m) +sqrt( d) ) /( 2*( pow( t,2) +1)) ;
x2 = ( ( 2*a+2*t*m) -sqrt( d) ) /( 2*( pow( t,2) +1)) ;
y1 = t*x1-53*t ;
y2 =t*x2-53*t ;
double y ,x;
if( y1<y2)
{
y=y1 ;x=x1;
}
else
y=y2;x=x2;
soc = moveToPos( VecPosition( x,y) ,20);
}
ACT->putCommandInQueue( soc ); // Put it in the command queue
}
//39 In the mode of our sideline , The teammate closest to the ball runs to the ball and kicks off , If I'm not the second closest teammate to the ball , Then I vector myself (5,0) Run in the direction of .
else if ( WM->isOffsideUs( ) )
{
ObjectT o1 = WM->getClosestInSetTo( OBJECT_SET_TEAMMATES , OBJECT_BALL) ;
if( WM->getAgentObjectType() == o1 )
{
if( WM->getGlobalPosition( o1) != WM->getBallPos() )
soc = moveToPos( WM->getBallPos() ,20) ;
else
{
ObjectT o3 = WM->getClosestInSetTo( OBJECT_SET_TEAMMATES ,posAgent) ;
soc = leadingPass( o3 , 1) ;
}
}
ObjectT o2 = WM->getSecondClosestInSetTo(OBJECT_SET_TEAMMATES , OBJECT_BALL) ;
if( WM->getAgentObjectType() != o2)
{
double y = posAgent.getY() ;
VecPosition pos( 52.5, y);
soc = moveToPos( pos,20) ;
}
ACT->putCommandInQueue( soc );
}
//40 In the mode of our sideline , The teammate closest to the ball runs to the ball and kicks off , If I'm not the second closest teammate to the ball , Then find the coordinates of the teammate who is the second closest to the ball and add (10,5) Click to run . If the point is on the court , Then run to this point .
else if(WM->isOffsideUs())
{
ObjectT o1=WM->getClosestInSetTo(OBJECT_SET_TEAMMATES,OBJECT_BALL) ;
ObjectT o2=WM->getSecondClosestInSetTo(OBJECT_SET_TEAMMATES,OBJECT_BALL) ;
double o2Posx;
double o2posy;
o2Posx=WM->getGlobalPosition(o2).getX();
o2posy=WM->getGlobalPosition(o2).getY();
if (WM->getAgentObjectType()==o1 )
{
if(WM->getGlobalPosition(o1)!=WM->getBallPos())
{
soc=moveToPos(WM->getBallPos(),20);
}
else
{
ObjectT o3 = WM->getClosestInSetTo( OBJECT_SET_TEAMMATES , o1) ;
soc = leadingPass(o3,1);
}
}
if(WM->getAgentObjectType()!=o1&&WM->getAgentObjectType()!=o2&&o2Posx<=42.5&&o2posy<=29)
{
soc=moveToPos(VecPosition(o2Posx+10,o2posy+5),20);
}
ACT->putCommandInQueue( soc );
}
//41 stay playOn In mode , If the other party 10 No. 1 take the ball , If I were 2、3、4 Number , Then mark 10 Number
int num=WM->getPlayerNumber();
if(WM->getClosestInSetTo(OBJECT_SET_OPPONENTS,WM->getBallPos())==OBJECT_OPPONENT_10&&
(num==2||num==3||num==4))
{
VecPosition pos=WM->getMarkingPosition(OBJECT_OPPONENT_10,2.0,MARK_BALL);
soc=moveToPos(WM->getGlobalPosition(OBJECT_OPPONENT_10),PS->getPlayerWhenToTurnAngle());
ACT->putCommandInQueue( soc );
}
//42 stay playOn In mode , Such as the other party 9 No. 1 take the ball , We 2、3、4 The player closest to the ball goes to mark 9 Number , Other players mark the opponent who is closest to them
if(WM->getClosestInSetTo(OBJECT_SET_OPPONENTS,WM->getBallPos())==OBJECT_OPPONENT_9)
{
ObjectT closestObject=OBJECT_TEAMMATE_2;
VecPosition team=WM->getGlobalPosition(closestObject);
double minDis=team.getDistanceTo(WM->getGlobalPosition(OBJECT_OPPONENT_9));
team=WM->getGlobalPosition(OBJECT_TEAMMATE_3);
double dis=team.getDistanceTo(WM->getGlobalPosition(OBJECT_OPPONENT_9));
if(dis<minDis)
{
minDis=dis;
closestObject=OBJECT_TEAMMATE_3;
}
team=WM->getGlobalPosition(OBJECT_TEAMMATE_4);
dis=team.getDistanceTo(WM->getGlobalPosition(OBJECT_OPPONENT_9));
if(dis<minDis)
{
closestObject=OBJECT_TEAMMATE_4;}
if(WM->getAgentObjectType()==closestObject)
{
VecPosition pos=WM->getMarkingPosition(OBJECT_OPPONENT_9,2.0,MARK_BALL);
soc=moveToPos(WM->getGlobalPosition(OBJECT_OPPONENT_9),PS->getPlayerWhenToTurnAngle());
}
else
{
ObjectT opp=WM->getClosestInSetTo(OBJECT_SET_OPPONENTS,WM->getAgentObjectType());
VecPosition oppPos=WM->getMarkingPosition(opp,2.0,MARK_BALL);
soc=moveToPos(oppPos,40);
}
}
//43 stay playOn In mode , If the other side approaches the ball before me , Then the player closest to the ball watches the ball , Other players mark the opponent who is closest to them
double *dDist1,*dDist2;
WM->getClosestInSetTo(OBJECT_SET_TEAMMATES,OBJECT_BALL,dDist1);
WM->getClosestInSetTo(OBJECT_SET_OPPONENTS,OBJECT_BALL,dDist2);
if((* dDist1)>(* dDist2))
{
if(WM->getAgentObjectType()==WM->getClosestInSetTo(OBJECT_SET_TEAMMATES,OBJECT_BALL))
soc=mark(OBJECT_BALL,5,MARK_GOAL);
else
soc=mark(WM->getClosestInSetTo(OBJECT_SET_OPPONENTS,WM->getPlayerNumber()),5,MARK_BISECTOR);
ACT->putCommandInQueue( soc = searchBall() ); // if ball pos unknown // Perform the ball finding action ! And put it into the command queue
ACT->putCommandInQueue( alignNeckWithBody( ) ); // search for it // At the same time, turn your neck with your body
}
//44 stay playOn In mode , If the other party 11 No. 1 gets the ball , be 7 Player No. 1 breaks the ball from the left ,8 Player No. 2 breaks the ball from the right
if(!WM->isBallKickable()){
if(WM->getPlayerType()==OBJECT_OPPONENT_11)
if(WM->getPlayerNumber()==7)
soc=moveToPos(WM->getGlobalPosition(OBJECT_OPPONENT_11)+VecPosition(0,-3),1);
soc=intercept(true);
if(WM->getPlayerNumber()==8)
soc=moveToPos(WM->getGlobalPosition(OBJECT_OPPONENT_11)+VecPosition(0,3),1);
soc=intercept(true);
ACT->putCommandInQueue(soc);
ACT->putCommandInQueue( turnNeckToObject( OBJECT_BALL, soc ) );
}
//45 stay playOn In mode , In defensive mode , We 6 Player No. 1 always follows the enemy 9 Number , We 7 No. 1 always follows the enemy 10 Number ,8 Player No. 1 always follows the enemy 11 Number player
if(WM->getPlayerNumber()==6)
{
VecPostion vOpp=WM->getGlobalPosition(OBJECT_OPPONENT_9);
soc=moveToPos(vOpp);
}
if(WM->getPlayerNumber()==7)
{
VecPostion vOpp=WM->getGlobalPosition(OBJECT_OPPONENT_10);
soc=moveToPos(vOpp);
}
if(WM->getPlayerNumber()==8)
{
VecPostion vOpp=WM->getGlobalPosition(OBJECT_OPPONENT_11);
soc=moveToPos(vOpp);
}
ACT->putCommandInQueue(soc);
ACT->putCommandInQueue(turnNeckToObject(OBJECT_BALL),soc);
//46. In the other side's lineball mode , If I were 4 Number , Then I will run to the opponent who is closest to the ball .
if(WM->offsidethem)
if(WM->getPlayerNumber()==4)
{
ObjectT oOpp=WM->getClosestInSetTo(OBJECT_SET_OPPONENTS,OBJECT_BALL);
VecPosition vOPP=WM->getGlobalPosition(oOpp);
soc=moveToPos(vOpp);
ACT->putCommandInQueue(soc);
ACT->putCommandInQueue(turnNeckToObject(OBJECT_BALL),soc);
}
//47. In the other side's lineball mode , If I'm the second closest player to the ball , Then I run to the position of the opposing player who is the second closest to the ball .
if(WM->offsidethem)
ObjectT objTea=WM->getSecondClosestInSetTo(OBJECT_SET_TEAMMATE,OBJECT_BALL);
if(WM->getAgentObjectType()==objTea)
{
ObjectT objOpp=WM->getSecondClosestInSetTo(OBJECT_SET_OPPONENTS,OBJECT_BALL);
VecPosition vOpp=WM->getGlobalPosition(objOpp);
soc=moveToPos(vOpp,PS->getPlayWhenToTurnaAngle());
ACT->putCommandInQueue(soc);
ACT->putCommandInQueue(turnNeckToObject(OBJECT_BALL),soc);
}
//48. In the other side's lineball mode , If I'm not the teammate closest to the ball , And my x Axis coordinates are greater than 0 Words , Then I run to my position and add (-10,0) Go to the location of the point .
if(WM->offsidethem)
{
ObjectT closeball,Myanget;
closeball=WM->getSecondClosestInSetTo(OBJECT_SET_TEAMMATES,OBJECT_BALL);// Get the current distance and find the nearest player
// Myanget=getAngetGlobalPosition();// The current player won
if(WM->getAgentObjectType() !=closeball&&WM->getGlobalPosition(WM->getAgentObjectType()).getX()>0)// Judge
{
soc=moveToPos(WM->getGlobalPosition(WM->getAgentObjectType())+(-10,0),20);
ACT->putCommandInQueue( soc );
ACT->putCommandInQueue( turnNeckToObject( OBJECT_BALL, soc ) ); // Turn your neck to the ball , That is, watching the ball all the time
}
}
//49. In the other side's lineball mode , If my side 5 If there are other players in mineI , Then I run to the position of the opposing player beside me , And my x The value of the axis coordinate is larger than that of the other party 2.
if(WM->isKickInThem())
{
Circle cir(posAgent,5);
int num=WM->getNrInSetInCircle(OBJECT_SET_OPPONENTS,cir);
if(num>0)
{
VecPosition pos=WM->getClosestInSetTo(OBJECT_SET_OPPONENTS,WM->getAgentObjectType());
pos.setX(pos.getX()+2);
soc=moveToPos(pos,0);
ACT->putCommandInQueue(soc);
ACT->putCommandInQueue(turnNeckToObject(OBJECT_BALL,soc));
}
}
//50. In the other side's lineball mode , If the position of the ball is x Axis less than 0, If I were 4 Number or 5 No , Run together to the position of the opposing player who is the second closest to the ball .
if (WM->isOffsideThem() )
{
VecPosition pos;
double x;
pos = WM -> getBallPos();
x = pos.getX();
if ( x<0)
{
if( WM ->getPlayerNumber() == 4 || WM ->getPlayerNumber() == 5 )
{
ObjectT ClosestBall;
double DisBall;
AngDeg ang;
ClosestBall = WM -> getSecondClosestInSetTo ( OBJECT_SET_OPPONENTS , &DisBall );
ang = WM -> getRelativeAngle ( ClosestBall, true );
soc = SoccerCommand ( CMD_DASH , 80, ang );
}
}
}
As it comes ~
Praise it ~
边栏推荐
- 机器人技术(RoboCup 2D)实验五十题及主要函数含义
- SQL Server 2016 learning records - data update
- 10. The penultimate node in the linked list
- Vulnerability analysis hevd-0x8.integeroverflow[win7x86]
- brief introduction
- ACM winter vacation training 7
- 机器学习--手写英文字母2--导入与处理数据
- 发力大核、独显!英众科技2020十代酷睿独显产品发布
- a different object with the same identifier value was already associated with the session
- 3. Print the linked list in reverse order with the array
猜你喜欢

Aqua Data Studio 18.5.0 export insert statement
![Database security - create login user + configure permissions [notes]](/img/02/0c3eb542593e8e0a3a62db75c52850.png)
Database security - create login user + configure permissions [notes]

AP AUTOSAR platform design 1-2 introduction, technical scope and method

Yarn报错:Exception message: /bin/bash: line 0: fg: no job control

Record a parent-child project in idea, modify the name of project and module, and test it personally!

Uni app project directory, file function introduction and development specification

IDEA打包jar包及运行jar包命令

Machine learning -- handwritten English alphabet 1 -- classification process

【栈的应用】--- 中缀表达式转后缀表达式
![Implement a queue with two stacks [C language]](/img/8a/679575bb0a562eff7e4317e64b4790.png)
Implement a queue with two stacks [C language]
随机推荐
Database security - create login user + configure permissions [notes]
LIBCMTD.lib
PHP generates QR code (learning)
Alibaba cloud image address
CentOS7下安装mysql5.7
pt-kill 查询中包含中文字符 导致工具失效的排查
Ie compatibility problem handling
ACM寒假集训#4
Troubleshooting of tool failure caused by Chinese characters in PT kill query
India plans to ban China Telecom equipment! Can we really do without Huawei and ZTE?
15. Judge whether the target value exists in the two-dimensional array
20200229训练赛 L2 - 2 树种统计 (25分)
Qt生成.exe文件 并 在无Qt环境下运行(Enigma Virtual Box进行绿色可执行软件封装)图文教程
SDUT 2446 最终排名
机器学习--手写英文字母3--工程特点
16. String inversion
Inverse element & combinatorial number & fast power
SDUT Round 9 2020 Spring Festival campaign
Match file names from file paths using regular expressions
Small knowledge in Oracle