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

📄 tackle.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 <cmath>#include <Tackle.h>#include <Degree.h>#include <BasicDash.h>#include <Logger.h>using namespace std;float Tackle::getValue(){	LOG << "Tackle getValue()" << endl;	if (worldModel->getPlayMode() == PM_PENALTY_SETUP ||		worldModel->getPlayMode() == PM_PENALTY_SETUP_OPP ||		worldModel->getPlayMode() == PM_PENALTY_READY_OPP ||		worldModel->getPlayMode() == PM_PENALTY_READY)	{		LOG << "TACKLE : penalty AD_MIN_VALUE" << endl;			return AD_MIN_VALUE;	}		if ((worldModel->getBallStatus() != BS_KICKABLE_OPP &&		worldModel->getBallStatus() != BS_FREE_BALL_OPP) ||		fabs(worldModel->getBall().getBodyVec().getDirection()) > 85)	{		LOG << "TACKLE : AD_MIN_VALUE" << endl;			return AD_MIN_VALUE;			}		if (lastDecide == DT_SRPDRIBBLE || lastDecide == DT_DRIBBLE_INTERCEPT)		if (worldModel->getBallStatus() != BS_KICKABLE_OPP)		{			LOG << "bayad 1 tackle zamime mikardam vali chon hooshmad shodam, nakardam." << endl;			return AD_MIN_VALUE;		}			float failTackleProb, succTackleProb;		failTackleProb = pow((worldModel->getBall().getBodyVec().getX() / 					worldModel->getServerParam()["tackle_dist"].asFloat()), 6) +					pow((fabs(worldModel->getBall().getBodyVec().getY()) / 					worldModel->getServerParam()["tackle_width"].asFloat()), 6);	if (failTackleProb > 1)		failTackleProb = 1;	if (failTackleProb < 0)		failTackleProb = 0;		succTackleProb = 1 - failTackleProb;		LOG << "TACKLE : failTackleProb : " << failTackleProb << endl;	if (succTackleProb > .5)	{		if (fabs(worldModel->getBody().getBodyDir()) < 90)  			tackleCommand = new TackleCommand(100);		else			tackleCommand = new TackleCommand(-100);		return AD_ALWAYS_RUN_VALUE;		} 		return AD_MIN_VALUE;}Tackle::Tackle(const WorldModel *worldModel): AdvancedAction(worldModel){}void Tackle::execute(SayDecisionFlags &sayFlags){	LOG << "Tackle::execute" << endl;	command = tackleCommand;}Tackle::~Tackle(){}DecideType Tackle::getType(){	return DT_TACKLE;}void Tackle::giveLastDecide(DecideType lastDecideArg){	lastDecide = lastDecideArg;}

⌨️ 快捷键说明

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