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

📄 kicknrun_defensive.cpp

📁 robocup3d源化码 Nexus3D.tar.gz
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*-this file is part of rcssserver3DFri May 9 2003Copyright (C) 2002,2003 Koblenz UniversityCopyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group$Id: kicknrun.cpp,v 1.2 2004/02/12 14:07:21 fruit Exp $This program is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; version 2 of the License.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.*/#include "kicknrun.h"#include <strstream>#include "global.h"using namespace zeitgeist;using namespace std;using namespace boost;using namespace oxygen;using namespace salt;KickNRun::KickNRun() : Soccer(){}KickNRun::~KickNRun(){}void KickNRun::BehaveBeforeKickOff(){	MyPlayer[1].move_radius=20;//30;	MyPlayer[2].move_radius=20;//30;	MyPlayer[3].move_radius=15;//25;	MyPlayer[4].move_radius=15;//25;	MyPlayer[5].move_radius=20;//30;	MyPlayer[6].move_radius=20;//30;	MyPlayer[7].move_radius=15;//20;	MyPlayer[8].move_radius=20;//30;	MyPlayer[9].move_radius=15;//25;	MyPlayer[10].move_radius=15;//20;	MyPlayer[11].move_radius=15;//25;	self.move_radius=MyPlayer[1].move_radius;	MyPlayer[1].home_pos = Vector3f(-47,0,0);	MyPlayer[2].home_pos = Vector3f(-20,-12,0);	MyPlayer[3].home_pos = Vector3f(-23,-5,0);	MyPlayer[4].home_pos = Vector3f(-25,5,0);	MyPlayer[5].home_pos = Vector3f(-20,12,0);	MyPlayer[6].home_pos = Vector3f(-10,-16,0);	MyPlayer[7].home_pos = Vector3f(-15,0,0);	MyPlayer[8].home_pos = Vector3f(-10,16,0);	MyPlayer[9].home_pos = Vector3f(0,20,0);	MyPlayer[10].home_pos = Vector3f(-5,0,0);	MyPlayer[11].home_pos = Vector3f(0,-20,0);	self.home_pos = MyPlayer[MyNumber].home_pos;    switch(MyNumber){    	case 1:		Beam(Vector3f(-47,0,0));		break;	case 2:		Beam(Vector3f(-20,-12,0));		break;    	case 3:		Beam(Vector3f(-23,-5,0));		break;    	case 4:		Beam(Vector3f(-25,5,0));		break;    	case 5:		Beam(Vector3f(-20,12,0));		break;    	case 6:		Beam(Vector3f(-10,-12,0));		break;    	case 7:		Beam(Vector3f(-15,0,0));		break;    	case 8:		Beam(Vector3f(-10,12,0));		break;    	case 9:		Beam(Vector3f(-1,20,0));		break;    	case 10:		Beam(Vector3f(-5,0,0));		break;    	case 11:		Beam(Vector3f(-1,-20,0));		break;    	default:		Beam(Vector3f(-0.1,0,0));		break;    }}void KickNRun::BehaveKickOff(){    TTeamIndex ti = mWM->GetMyTeam();    if (ti == TI_NONE)        {            return;        }    TPlayMode myKickOff = (mWM->GetMyTeam() == TI_LEFT) ?        PM_KickOff_Left : PM_KickOff_Right;    if (mWM->GetPlayMode() == myKickOff)        {            BehaveMyKickOff();            GetLog()->Debug() << "MyKickOff\n";        } else            {                BehaveTheirKickOff();                GetLog()->Debug() << "TheirKickOff\n";            }}void KickNRun::BehaveMyKickOff(){    // for now, just kick and run    //BehaveBeforeKickOff();    if(do_beam_on_kickof){	switch(MyNumber){		case 1:			Beam(Vector3f(-47,0,0));			break;		case 2:			Beam(Vector3f(-20,-12,0));			break;		case 3:			Beam(Vector3f(-23,-5,0));			break;		case 4:			Beam(Vector3f(-25,5,0));			break;		case 5:			Beam(Vector3f(-20,12,0));			break;		case 6:			Beam(Vector3f(-10,-12,0));			break;		case 7:			Beam(Vector3f(-15,0,0));			break;		case 8:			Beam(Vector3f(-10,12,0));			break;		case 9:			Beam(Vector3f(-1,20,0));			break;		case 10:			Beam(Vector3f(-5,0,0));			break;		case 11:			Beam(Vector3f(-1,-20,0));			break;		default:			Beam(Vector3f(-0.1,0,0));			break;        }	do_beam_on_kickof=false;    }    else{    	BehavePlayOn();    }}void KickNRun::BehaveTheirKickOff(){    // do nothing    //BehaveBeforeKickOff();    //Drive(Vector3f(0,0,0));    if(do_beam_on_kickof){        switch(MyNumber){		case 1:			Beam(Vector3f(-47,0,0));			break;		case 2:			Beam(Vector3f(-20,-12,0));			break;		case 3:			Beam(Vector3f(-23,-5,0));			break;		case 4:			Beam(Vector3f(-25,5,0));			break;		case 5:			Beam(Vector3f(-20,12,0));			break;		case 6:			Beam(Vector3f(-10,-12,0));			break;		case 7:			Beam(Vector3f(-15,0,0));			break;		case 8:			Beam(Vector3f(-10,12,0));			break;		case 9:			Beam(Vector3f(0,20,0));			break;		case 10:			Beam(Vector3f(-5,0,0));			break;		case 11:			Beam(Vector3f(0,-20,0));			break;		default:			Beam(Vector3f(0,0,0));			break;        }	do_beam_on_kickof=false;    }    else   BehavePlayOn();}void KickNRun::BehaveKickIn(){    TTeamIndex ti = mWM->GetMyTeam();    if (ti == TI_NONE)        {            return;        }    TPlayMode myKickIn = (mWM->GetMyTeam() == TI_LEFT) ?        PM_KickIn_Left : PM_KickIn_Right;    if (mWM->GetPlayMode() == myKickIn)        {            BehaveMyKickIn();            GetLog()->Debug() << "MyKickIn\n";        } else            {                BehaveTheirKickIn();                GetLog()->Debug() << "TheirKickIn\n";            }}void KickNRun::BehaveMyKickIn(){    // for now just kick and run    BehavePlayOn();}void KickNRun::BehaveTheirKickIn(){    // do nothing    //Drive(Vector3f(0,0,0));        BehavePlayOn();}void KickNRun::BehavePlayOn(){	PredictBallPos();	//estimation of ball pos	DoLog(LOG_GOALIE,"ball.pos=(%f,%f,%f)  kickdist=%f  ball.dist=%f",ball.pos[0],ball.pos[1],ball.pos[2],KickDistance,ball.distance);	DoLog(LOG_GOALIE,"ball.vel=(%f,%f,%f)",ball.vel[0],ball.vel[1],ball.vel[2]);	DoLog(LOG_GOALIE,"FieldLength=%f FieldWidth=%f FieldHeight;=%f GoalWidth=%f GoalDepth=%f GoalHeight=%f BorderSize=%f",FieldLength,FieldWidth,FieldHeight,GoalWidth,GoalDepth,GoalHeight,BorderSize);	DoLog(LOG_GOALIE,"Self.pos=(%f,%f,%f) ",self.pos[0],self.pos[1],self.pos[2]);    	TTeamIndex ti = mWM->GetMyTeam();	if(self.IsGoalie){		goalie.SmartGoalie();	}	else	{	//if (ti == TI_RIGHT) return;		/*int player_num=0;		float min_dist2ball=100;		for(int i=1;i<=11;i++) if(MyPlayer[i].dist2ball<min_dist2ball&&i!=MyNumber) 	min_dist2ball=MyPlayer[i].dist2ball;		if(ball.distance>min_dist2ball){		}		else{			if(ball.distance>4){				action_info.x = ball.pos[0] ;				action_info.y = ball.pos[1] ;				action_info.do_drive = true ;			}			else if(!AdjustKickPos.AdjustNeeded(-179)){				DoLog(LOG_GOALIE,"Kick");				Kick(20,100);			}			else {				Vector3f Pos=AdjustKickPos.MoveAroundBall(-179);				DoLog(LOG_GOALIE,"adjust nedded    pos(%f,%f)",Pos[0],Pos[1]);				action_info.x = Pos[0] ;				action_info.y = Pos[1] ;				action_info.do_drive = true ;			}		}*/	/*	if(MyNumber==11&&self.pos[0]<10){			 GoTo(40,10,0);			action_info.x = 40 ;			action_info.y = 10 ;			action_info.do_drive = true ;		}			DoLog(LOG_GOALIE,"vel(%f,%f,%f)  pos(%f,%f,%f)",self.vel[0],self.vel[1],self.vel[2],self.pos[0],self.pos[1],self.pos[2]);		//DoLog(LOG_GOALIE,"this agent is not goalie");*/		if(!handleball.TryHandle())		{			if(!intercept.TryIntercept())			{				positioning.Position();			}		}	}//////////////  //		action_info.kick_angle=20;//		action_info.kick_direction=0;//		action_info.kick_speed=100;

⌨️ 快捷键说明

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