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

📄 goalieplayondecision.cpp

📁 mersad源码 03年robocup 季军 可以研究一下大家
💻 CPP
字号:
/* *  Copyright 2002-2004, Mersad Team, Allame Helli High School (NODET). * *  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. * *  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 Library General Public License for more details. * *  Created by: Meisam Vosoughpour *  Released on Friday 1 April 2005 by Mersad RoboCup Team. *  For more information please read README file.*/#include <math.h>#include <GoalieIntercept.h>#include <GoaliePositioning.h>#include <Intercept.h>#include <GoaliePlayOnDecision.h>#include <Clear.h>#include <BasicKick.h>#define GOALIE_CATCH_NUM 0#define CLEAR_NUM 1#define GOALIE_INTERCEPT_NUM 2#define INTERCEPT_NUM 3#define GOALIE_POSITIONING_NUM 4using namespace std;GoaliePlayOnDecision::GoaliePlayOnDecision(		const WorldModel *worldModel, SayDecisionFlags &sayFlags,		TurnNeckMode &turnNeckMode):		BodyDecision(worldModel, sayFlags, turnNeckMode){	addAdvancedAction(new GoalieCatch(worldModel),		AdvancedActionWeights(0, 1, 1), 2);	addAdvancedAction(new Clear(worldModel),		AdvancedActionWeights(0, 1, 1), 2);	addAdvancedAction(new GoalieIntercept(worldModel),		AdvancedActionWeights(0, 1, 1), 1);	addAdvancedAction(new Intercept(worldModel),		AdvancedActionWeights(0, 1, 1), 1);	addAdvancedAction(new GoaliePositioning(worldModel),		AdvancedActionWeights(0, 1, 1), 1);}GoaliePlayOnDecision::~GoaliePlayOnDecision(){}bool GoaliePlayOnDecision::isBallOppKickable(float minExtra, float maxExtra){	register int i;	float kickableArea, virtualKickableArea;	kickableArea = worldModel->getBall().getSize() + 			worldModel->getBody().getKickableMargin() + 			worldModel->getBody().getSize();		virtualKickableArea = kickableArea + minExtra;		for (i = 0; i < FULL_PLAYERS_NUM; i++)		if (worldModel->getFullPlayer(TID_OPPONENT, i).isValid())			if(worldModel->getFullPlayer(TID_OPPONENT, i).					getDistance(worldModel->getBall()) 				<=	(virtualKickableArea + min((float)(worldModel->getFullPlayer(					TID_OPPONENT, i).getDistance(worldModel->getBody()) * .08),					maxExtra) ))				return true;						for (i = 0; i < HALF_PLAYERS_NUM; i++)		if (worldModel->getHalfPlayer(TID_OPPONENT, i).isValid())			if(worldModel->getHalfPlayer(TID_OPPONENT, i).					getDistance(worldModel->getBall()) 				<=	(virtualKickableArea + min((float)(worldModel->getHalfPlayer(					TID_OPPONENT, i).getDistance(worldModel->getBody()) * .08), 					maxExtra) ))				return true;	return false;}DecideType GoaliePlayOnDecision::decide(int quickLevel, DecideType lastDecide){	resetQuickLevels();	if (worldModel->getBall().getPos().getX() < -36.4 &&		worldModel->getBody().getPos().getX() < -36.4 &&		fabs(worldModel->getBall().getPos().getY()) < 19.6 &&		fabs(worldModel->getBody().getPos().getY()) < 19.6)	{	}	else if (worldModel->isBallKickable())	{		if (worldModel->getBall().getPos().getY() > 0)			command = FastKickToDir(90, worldModel->getBall(),				worldModel->getBody()).getCommand();		else			command = FastKickToDir(-90, worldModel->getBall(),				worldModel->getBody()).getCommand();		return DT_NONE;	}	quickLevels[GOALIE_CATCH_NUM] = 2;	quickLevels[CLEAR_NUM] = 2;	dynamic_cast<GoalieCatch *>(advancedActions[GOALIE_CATCH_NUM])->				giveLastDecide(lastDecide);	if (worldModel->getCurInterCalculate().existFastestTmmPlayer() && (		(worldModel->getCurInterCalculate().getFastestTmmPlayer().isBody() &&		!isBallOppKickable(.2,1.5)) || 		(worldModel->isOppBallShooted(worldModel->getBall()) && 		!worldModel->isBallInOppKickable())))	{ // Intercept		quickLevels[GOALIE_INTERCEPT_NUM] = 1;		quickLevels[INTERCEPT_NUM] = 1;			}	else	{ // Positioning		quickLevels[GOALIE_POSITIONING_NUM] = 1;	}	if (worldModel->getBall().getAbsVec().getMagnitude() < 20)		turnNeckMode = TNM_LOOK_CAREFULLY_TO_BALL;	else		turnNeckMode = TNM_LOOK_NORMALLY_TO_BALL;	return BodyDecision::decide(quickLevel);}

⌨️ 快捷键说明

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