📄 tackle.cpp
字号:
/* * Copyright 2002-2005, Mersad Team, Allameh 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. * * This file is created by: Meisam Vosoughpour * * Released on Monday 1 August 2005, 10 Mordad 1384 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>#include <AdvancedAgent.h>using namespace std;float Tackle::getValue(const Library &library){ 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 (library.lastBodyCycleCommand->getCreator() == AT_SRPDRIBBLE || library.lastBodyCycleCommand->getCreator() == AT_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(AT_TACKLE, 100); else tackleCommand = new TackleCommand(AT_TACKLE, -100); return AD_ALWAYS_RUN_VALUE; } return AD_MIN_VALUE;}Tackle::Tackle(const WorldModel *worldModel): AdvancedAction(worldModel){}void Tackle::execute(Form &form, const Library &library){ LOG << "Tackle::execute" << endl; command = tackleCommand;}Tackle::~Tackle(){}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -