⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 playerteams.cpp~

📁 对于2D ROBOCUP底层传球和定位球方面进行了严格的修改该
💻 CPP~
📖 第 1 页 / 共 3 页
字号:
/*Copyright (c) 2000-2003, Jelle Kok, University of AmsterdamAll rights reserved.Redistribution and use in source and binary forms, with or withoutmodification, are permitted provided that the following conditions are met:1. Redistributions of source code must retain the above copyright notice, thislist of conditions and the following disclaimer.2. Redistributions in binary form must reproduce the above copyright notice,this list of conditions and the following disclaimer in the documentationand/or other materials provided with the distribution.3. Neither the name of the University of Amsterdam nor the names of itscontributors may be used to endorse or promote products derived from thissoftware without specific prior written permission.THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THEIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AREDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLEFOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIALDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ORSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVERCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USEOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*//*! \file PlayerTeams.cpp<pre><b>File:</b>          PlayerTest.cpp<b>Project:</b>       Robocup Soccer Simulation Team: UvA Trilearn<b>Authors:</b>       Jelle Kok<b>Created:</b>       10/12/2000<b>Last Revision:</b> $ID$<b>Contents:</b>      This file contains the class definitions for the                      Player that are used to test the teams' high level                      strategy.<hr size=2><h2><b>Changes</b></h2><b>Date</b>             <b>Author</b>          <b>Comment</b>10/12/2000        Jelle Kok       Initial version created</pre>*/#include "Player.h"/*!This method is the first complete simple team and defines the actions taken   by all the players on the field (excluding the goalie). It is based on the   high-level actions taken by the simple team FC Portugal that it released in   2000. The players do the following:   - if ball is kickable       kick ball to goal (random corner of goal)   - else if i am fastest player to ball        intercept the ball   - else       move to strategic position based on your home position and pos ball */SoccerCommand Player::deMeer5(  )                 //主要是改这个函数 //坐标原点在球场中心球门坐标 52,50   X坐标轴是相同的Y坐标轴是相反的 关于球队布局 看一下 球队一直在左边 如果队伍在右边的话SERVER会自动调整坐标轴  黑线是身体方向 红线是头的方向。。。{  SoccerCommand soc(CMD_ILLEGAL);  VecPosition   posAgent = WM->getAgentGlobalPosition();  VecPosition   posBall  = WM->getBallPos();  int           iTmp;  if( WM -> getPlayerNumber() == 2 || WM -> getPlayerNumber() == 3 || WM -> getPlayerNumber() == 4 || WM -> getPlayerNumber() == 5)	  WM->setPlayerType( PS_DEFENDERS);  else if ( WM -> getPlayerNumber() == 6 || WM -> getPlayerNumber() == 7 || WM -> getPlayerNumber() == 8)	  WM->setPlayerType( PS_MIDFIELDERS);  else if ( WM -> getPlayerNumber() == 9 || WM -> getPlayerNumber() == 10 || WM -> getPlayerNumber() == 11 )	  WM->setPlayerType( PS_ATTACKERS);  if( WM->isBeforeKickOff( ) )         //开球时候的动作 9号去开球 将球回传后场组织进攻 10号进行掩护  {    if( WM->isKickOffUs( ) && WM->getPlayerNumber() == 9 ) // 9 takes kick    {	if( posAgent.getMagnitude() > 0.1) 	{		soc = moveToPos( WM -> getGlobalPosition( OBJECT_BALL),PS->getPlayerWhenToTurnAngle());		Log.log( 100, "NO.9 move to ball to take kick-off" );	}	 	else	{		VecPosition posGoal( -10,10);			/*( PITCH_LENGTH/2.0,		(-1 + 2*(WM->getCurrentCycle()%2)) * 		0.4 * SS->getGoalWidth() );*/		soc = kickTo( posGoal, 2.2 ); // kick maximal		Log.log( 100, "NO.9 take kick off" );        		ACT->putCommandInQueue( soc );		ACT->putCommandInQueue( turnNeckToPoint( posGoal, soc) );		return soc;	}	Log.log( 100, "take kick off" );                ACT->putCommandInQueue( soc );        ACT->putCommandInQueue( turnNeckToObject( OBJECT_BALL, soc ) );        return soc;    }    else if( WM->isKickOffUs( ) && WM->getPlayerNumber() == 7 ) // 7号提前做掩护   {	VecPosition posGoal( 4,10);	soc = moveToPos( WM -> getGlobalPosition( OBJECT_BALL) + posGoal,PS->getPlayerWhenToTurnAngle());	Log.log( 100, "NO.7 ..." );	ACT->putCommandInQueue( soc );	ACT->putCommandInQueue( turnNeckToObject( OBJECT_BALL, soc ) );	return soc;   }    if( formations->getFormation() != FT_INITIAL || // not in kickoff formation        posAgent.getDistanceTo( WM->getStrategicPosition() ) > 2.0 )      {      formations->setFormation( FT_INITIAL );       // go to kick_off formation      ACT->putCommandInQueue( soc=teleportToPos( WM->getStrategicPosition() ));    }    else                                            // else turn to center    {      ACT->putCommandInQueue( soc=turnBodyToPoint( VecPosition( 0, 0 ), 0 ) );      ACT->putCommandInQueue( alignNeckWithBody( ) );    }  }  else if( WM -> isDeadBallUs() )  // include isKickInUs  ( pm ) || isFreeKickUs  ( pm ) || isCornerKickUs     ( pm)	                            // || isKickOffUs ( pm ) || isOffsideThem ( pm ) || isFreeKickFaultThem( pm)			            // || isGoalKickUs( pm ) || isBackPassThem( pm )  {	  if(WM -> isKickInUs() && WM -> getGlobalPosition(OBJECT_BALL).isLeftOf(0.00) //前场左边界外球		    		&& WM -> getGlobalPosition(OBJECT_BALL).isInFrontOf(0.00))	  {		  if( WM->getPlayerNumber() == 8)		{			VecPosition temp1( 0.6,-0.6);			VecPosition posGoal1 = WM -> getGlobalPosition ( OBJECT_BALL) + temp1 ;			VecPosition distance;			distance = posAgent - posGoal1;			if( distance.getMagnitude() > 0.3) 			{				soc = moveToPos(posGoal1,PS->getPlayerWhenToTurnAngle());				Log.log( 100, "NO.8 move to ball to take left kick-in" );			}	 		   	  else			{				VecPosition temp2( 0,8);				VecPosition posGoal = WM -> getGlobalPosition ( OBJECT_BALL) + temp2;					/*( PITCH_LENGTH/2.0,						(-1 + 2*(WM->getCurrentCycle()%2)) * 							0.4 * SS->getGoalWidth() );*/				if( WM -> isVisible( OBJECT_TEAMMATE_11))					soc = kickTo( posGoal, 1.0 ); // kick ball				else					soc = searchBall();				Log.log( 100, "NO.8 take left kick in" );        				ACT->putCommandInQueue( soc );				ACT->putCommandInQueue( turnNeckToPoint( WM -> getGlobalPosition (OBJECT_BALL) + temp2, soc) );				return soc;			}		}				  else if(WM -> getPlayerNumber() == 11)		{			if( WM->isVisible( OBJECT_BALL) )			{				VecPosition t( 0,5);				VecPosition posGoal = WM -> getGlobalPosition ( OBJECT_BALL) + t ;				soc = moveToPos(posGoal,PS->getPlayerWhenToTurnAngle());			}			else			{				soc = intercept( false );    // intercept the ball //false是指对象是不是门将			}			Log.log( 100, "NO.11 move to receive the ball" );			ACT->putCommandInQueue( soc );			ACT->putCommandInQueue( turnNeckToObject( OBJECT_BALL, soc ) );		 }	  }	  else if(WM -> isKickInUs() && WM -> getGlobalPosition(OBJECT_BALL).isLeftOf(0.00) //后场左边界外球		    		      && WM -> getGlobalPosition(OBJECT_BALL).isBehindOf(0.00))	  {		  if(WM->getPlayerNumber() == 5)		  {			  VecPosition temp1( 0.6,-0.6);			  VecPosition posGoal1 = WM -> getGlobalPosition ( OBJECT_BALL) + temp1 ;			  VecPosition distance;			  distance = posAgent - posGoal1;			  if( distance.getMagnitude() > 0.3) 			  {				  soc = moveToPos(posGoal1,PS->getPlayerWhenToTurnAngle());				  Log.log( 100, "NO.5 move to ball to take left kick-in" );			  }	 			  else			  {				  VecPosition temp2( 0,8);				  VecPosition posGoal = WM -> getGlobalPosition ( OBJECT_BALL) + temp2;					/*( PITCH_LENGTH/2.0,				  (-1 + 2*(WM->getCurrentCycle()%2)) * 				  0.4 * SS->getGoalWidth() );*/				  if( WM -> isVisible( OBJECT_TEAMMATE_8))					  soc = kickTo( posGoal, 1.0 ); // kick ball				  else					  soc = searchBall();				  Log.log( 100, "NO.5 take left kick in" );        				  ACT->putCommandInQueue( soc );				  ACT->putCommandInQueue( turnNeckToPoint( WM -> getGlobalPosition (OBJECT_BALL) + temp2, soc) );				  return soc;			  }		  }				  else if(WM -> getPlayerNumber() == 8)		  {			  if( WM->isVisible( OBJECT_BALL) )			  {				  VecPosition t( 0,5);				  VecPosition posGoal = WM -> getGlobalPosition ( OBJECT_BALL) + t ;				  soc = moveToPos(posGoal,PS->getPlayerWhenToTurnAngle());			  }			  else			  {				  soc = intercept( false );    // intercept the ball //false是指对象是不是门将			  }			  Log.log( 100, "NO.8 move to receive the ball" );			  ACT->putCommandInQueue( soc );			  ACT->putCommandInQueue( turnNeckToObject( OBJECT_BALL, soc ) );		  }	  }    	  else if(WM -> isKickInUs() && WM -> getGlobalPosition(OBJECT_BALL).isRightOf(0.00) //前场右侧界外球				      && WM -> getGlobalPosition(OBJECT_BALL).isInFrontOf(0.00))	  {		  if(WM->getPlayerNumber() == 7)		  {			  VecPosition temp1( -0.6,0.6);			  VecPosition posGoal1 = WM -> getGlobalPosition ( OBJECT_BALL) + temp1 ;			  VecPosition distance;			  distance = posAgent - posGoal1;			  if( distance.getMagnitude() > 0.3) 			  {				  soc = moveToPos(posGoal1,PS->getPlayerWhenToTurnAngle());				  Log.log( 100, "NO.7 move to ball to take right kick-in" );			  }	 			  else			  {				  VecPosition temp2( 0,-5);				  VecPosition posGoal = WM -> getGlobalPosition ( OBJECT_BALL) + temp2;					/*( PITCH_LENGTH/2.0,				  (-1 + 2*(WM->getCurrentCycle()%2)) * 				  0.4 * SS->getGoalWidth() );*/				  if( WM -> isVisible( OBJECT_TEAMMATE_10))					  soc = kickTo( posGoal, 1.0 ); // kick ball				  else					  soc = searchBall();				  Log.log( 100, "NO.7 take right kick in" );        				  ACT->putCommandInQueue( soc );				  ACT->putCommandInQueue( turnNeckToPoint( WM -> getGlobalPosition (OBJECT_BALL) + temp2, soc) );				  return soc;			  }		  }		  else if(WM -> getPlayerNumber() == 10)		  {			  if( WM->isVisible( OBJECT_BALL) )			  {				  VecPosition temp( 0,-8);				  VecPosition posGoal = WM -> getGlobalPosition ( OBJECT_BALL) + temp ;				  soc = moveToPos(posGoal,PS->getPlayerWhenToTurnAngle());			  }			  else			  {				  soc = intercept( false );    // intercept the ball //false是指对象是不是门将 			  }			Log.log( 100, "NO.10 move to receive the ball" );			ACT->putCommandInQueue( soc );			ACT->putCommandInQueue( turnNeckToObject( OBJECT_BALL, soc ) );			return soc;		  }	  }	  else if(WM -> isKickInUs() && WM -> getGlobalPosition(OBJECT_BALL).isRightOf(0.00) //后场右侧界外球			 && WM -> getGlobalPosition(OBJECT_BALL).isBehindOf(0.00))	  {		  if(WM->getPlayerNumber() == 2)		  {			  VecPosition temp1( -0.6,0.6);			  VecPosition posGoal1 = WM -> getGlobalPosition ( OBJECT_BALL) + temp1 ;			  VecPosition distance;			  distance = posAgent - posGoal1;			  if( distance.getMagnitude() > 0.3) 			  {				  soc = moveToPos(posGoal1,PS->getPlayerWhenToTurnAngle());				  Log.log( 100, "NO.2 move to ball to take right kick-in" );			  }	 			  else			  {				  VecPosition temp2( 0,-5);				  VecPosition posGoal = WM -> getGlobalPosition ( OBJECT_BALL) + temp2;					/*( PITCH_LENGTH/2.0,				  (-1 + 2*(WM->getCurrentCycle()%2)) * 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -