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

📄 soccerscene.cpp

📁 浙江大学 RoboCup3D 2006 源代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/*************************************************************************** *   Copyright (C) 2004 - 2006 by ZJUBase                                  *
 *                                National Lab of Industrial Control Tech. * *                                Zhejiang University, China               * *                                                                         * *   Achievements of ZJUBase in RoboCup Soccer 3D Simulation League:       *
 *    In RoboCup championship,                                             *
 *      - June 2006 - 3rd place in RoboCup 2006, Bremen, Germany (lost     * *        the semi-final with a coin toss)                                 *
 *      - July 2005 - 3rd place in RoboCup 2005, Osaka, Japan (share the   * *        3rd place with team Caspian)                                     *
 *    In RoboCup local events,                                             *
 *      - April 2006 - 2nd place in RoboCup Iran Open 2006, Tehran, Iran   * *        (lost the final with a coin toss)                                *
 *      - December 2005 - 2nd place in AI Games 2005, Isfahan, Iran        *
 *      - July 2005 - champion in China Robot Competition 2005, Changzhou, * *        China                                                            *
 *      - October 2004 - champion in China Soccer Robot Competition 2004,  * *        Guangzhou, China                                                 *
*                                                                         * *   Team members:                                                         *
 *    Currently the team leader is,                                        * *           Hao JIANG (jianghao@iipc.zju.edu.cn; riveria@gmail.com)       *
 *    In the next season, the leader will be                               * *           Yifeng ZHANG (yfzhang@iipc.zju.edu.cn)                        *
 *    ZJUBase 3D agent is created by                                       * *           Dijun LUO (djluo@iipc.zju.edu.cn)                             *
 *    All the members who has ever contributed:                            * *           Jun JIANG                                                     *
 *           Xinfeng DU (xfdu@iipc.zju.edu.cn)                             *
 *           Yang ZHOU (yzhou@iipc.zju.edu.cn)                             *
 *           Zhipeng YANG                                                  *
 *           Xiang FAN                                                     *
 *                                                                         *
 *   Team Manager:                                                          *
 *      Ms. Rong XIONG (rxiong@iipc.zju.edu.cn)                            *
 *                                                                         *
 *   If you met any problems or you have something to discuss about        * *   ZJUBase. Please feel free to contact us through EMails given below.   * *                                                                         * *   This program is free software; you can redistribute it and/or modify  * *   it under the terms of the GNU General Public License as published by  * *   the Free Software Foundation; either version 2 of the License, or     * *   (at your option) any later version.                                   * *                                                                         * *   This program is distributed in the hope that it will be useful,       * *   but WITHOUT ANY WARRANTY; without even the implied warranty of        * *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * *   GNU General Public License for more details.                          * *                                                                         * *   You should have received a copy of the GNU General Public License     * *   along with this program; if not, write to the                         * *   Free Software Foundation, Inc.,                                       * *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * ***************************************************************************/#include "Global.h"
#include "SoccerScene.h"
#include "Strategy.h"
#include "ActionSystem.h"

#define cornerDegree 90.0
#define throwInDegree 30.0
#define distAround 0.4
#define distApart 1.1

Situation* SoccerScene::ST = NULL;
ServerSettings* SoccerScene::SS = NULL;

////////////////////////////////////////////
//Scene Class
////////////////////////////////////////////

SoccerScene::SoccerScene()
{
}

SoccerScene::~SoccerScene()
{
}

bool SoccerScene::isValid()
{
	return false;
}

void SoccerScene::Execute()
{
}

void SoccerScene::reset()
{
}

void SoccerScene::AddCommand(SoccerCommand cmd)
{
	Angle panAngInc;
	Angle tiltAngInc;
	SoccerCommand cmd_panTilt;
	ST->getAngInc(panAngInc,tiltAngInc);
	cmd_panTilt=SoccerCommand(CT_PANTILT, panAngInc, tiltAngInc);/////yzp0527

	global.commands[global.nCommand].push_back(cmd_panTilt);
  	global.commands[global.nCommand].push_back(cmd);
	global.nCommand ++;
}

void SoccerScene::AddCommand(SoccerCommand cmd1,SoccerCommand cmd2)
{
	Angle panAngInc;
	Angle tiltAngInc;
	SoccerCommand cmd_panTilt;
	ST->getAngInc(panAngInc,tiltAngInc);
	cmd_panTilt=SoccerCommand(CT_PANTILT, panAngInc, tiltAngInc);/////yzp0527

	global.commands[global.nCommand].push_back(cmd_panTilt);
   	global.commands[global.nCommand].push_back(cmd1);
   	global.commands[global.nCommand].push_back(cmd2);
	global.nCommand ++;
}

void SoccerScene::AddCommandQueue(CommandQueue cmds)
{
	Angle panAngInc;
	Angle tiltAngInc;
	SoccerCommand cmd_panTilt;
	CommandList list;
	ST->getAngInc(panAngInc,tiltAngInc);
	cmd_panTilt=SoccerCommand(CT_PANTILT, panAngInc, tiltAngInc);//////yzp0527
	cmds[0].push_back(cmd_panTilt);				

	for(int i=0;i<cmds.size()&&i<COMMAND_MAX;i++) {
		global.commands[global.nCommand++]=cmds[i];
	}
}

//////////////////////////////////////////////
//SCENE_before_kick_off Class
//////////////////////////////////////////////

SCENE_before_kick_off::SCENE_before_kick_off()
{
}

SCENE_before_kick_off::~SCENE_before_kick_off()
{
}

bool SCENE_before_kick_off::isValid()
{
	return false;
}

void SCENE_before_kick_off::Execute()
{
}

/////////////////////////////////////////////////
// SCENE_long_pass Class
/////////////////////////////////////////////////
SCENE_long_pass::SCENE_long_pass()
{
}

SCENE_long_pass::~SCENE_long_pass()
{
}

bool SCENE_long_pass::isValid()
{
	return false;
}

void SCENE_long_pass::Execute()
{
}


/////////////////////////////////////////////////
//SCENE_short_pass Class
/////////////////////////////////////////////////
SCENE_short_pass::SCENE_short_pass()
{
}

SCENE_short_pass::~SCENE_short_pass()
{
}

bool SCENE_short_pass::isValid()
{
	return false;
}

void SCENE_short_pass::Execute()
{
}


/////////////////////////////////////////////////
//SCENE_intercept Class
/////////////////////////////////////////////////

SCENE_intercept::SCENE_intercept()
{
}

SCENE_intercept::~SCENE_intercept()
{
}

bool SCENE_intercept::isValid()
{
	return false;
}

void SCENE_intercept::Execute()
{
}


//////////////////////////////////////////////////
//SCENE_dribbling Class:盘球带球
//////////////////////////////////////////////////
SCENE_dribbling::SCENE_dribbling()
{
}

SCENE_dribbling::~SCENE_dribbling()
{
}

bool SCENE_dribbling::isValid()
{
	return false;
}

void SCENE_dribbling::Execute()
{
}


//////////////////////////////////////////////////
//SCENE_normal Class
//////////////////////////////////////////////////

SCENE_normal::SCENE_normal()
{
	valid = true;
	enoughReturn = true;
}

SCENE_normal::~SCENE_normal()
{
}

bool SCENE_normal::isValid()
{
	return valid;
}

void SCENE_normal::Execute()
{
	double power=100;
	Angle theta=30;
	bool isShoot=false;
	bool res=true;
	bool turn=false;
	bool dribble=false;
	Vector3 turnToP;
	CommandQueue cmds;

	if(global.wm.noball>=2){
		theta=0;
		power=1;
		AddCommand(SoccerCommand(CT_KICK,theta,power));
		return;
	}

	/////////////for emergent kick///////////////
	if((global.wm.myPos-global.wm.ballPos).mod()<2) {
		res=ST->getPassVel(power, theta, isShoot);
	}

	if(global.wm.myNumber>=6&&global.wm.myNumber<=11&&(global.wm.myPos-global.wm.ballPos).mod()<2&&ST->isDribbleSafe()&&((dribble=ST->shouldIDribble(isShoot))||ST->shouldITurn(isShoot))){
		if(dribble) {
			as.dribbleForward( cmds);

⌨️ 快捷键说明

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