?? waitplan.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: Sassan Haradji * * Released on Monday 1 August 2005, 10 Mordad 1384 by Mersad RoboCup Team. * For more information please read README file.*/#include <AdvancedAgent.h>#include <WaitPlan.h>#include <DribblePlan.h>#include <PassPlan.h>#include <InterceptPlan.h>#include <OffensePosPlan.h>#include <Logger.h>#include <Basics.h>#include <cassert>using namespace std;using namespace Basics;WaitPlan::WaitPlan(const WorldModel *wm, Form &form, const Library &library, Side side): Plan("Wait", wm, form, library), side(side), minSuccessRate(.24 + reRate(wm->getBody().getPos().getX(), 10, 40, 0, .03)){ switch (wm->getBody().getUniNum()) { case 2: fPlayer = 10; bPlayer = 7; break; case 10: fPlayer = 2; bPlayer = 7; break; case 7: fPlayer = 2; bPlayer = 10; break; case 4: fPlayer = 11; bPlayer = 8; break; case 11: fPlayer = 4; bPlayer = 8; break; case 8: fPlayer = 4; bPlayer = 11; break; default: fPlayer = BPN_ALL; bPlayer = BPN_ALL; }}WaitPlan::~WaitPlan(){}void WaitPlan::decide(){ if (side == SI_LEFT) LOG << "WaitPlan::decide (Side : Left)" << endl; else LOG << "WaitPlan::decide (Side : Right)" << endl; Plan::decide(); if (wm->isBallKickable()) { startPlan(bestPlan(2, true, new PassPlan(wm, form, library, BPM_SECUREBALL, fPlayer, -180, 180, -180, 180), new PassPlan(wm, form, library, BPM_SECUREBALL, bPlayer, -180, 180, -180, 180)), minSuccessRate); LOG << name << " Plan WARNING!!! : " << "All WithBall Plans Finished Without Return Any Command." << endl; LOG << name << " Plan : " << "Now Run Dribble Plan Without Check SuccessRate or isFinished" << "(Urgent State)." << endl; DribblePlan dribblePlan(wm, form, library); dribblePlan.decide(); } else { if (library.gwSelection == WOBS_INTERCEPT) startPlan(new InterceptPlan(wm, form, library)); startPlan(new OffensePosPlan(wm, form, library)); } LOG << "WaitPlan Now Kill Program" << endl; assert(0);}double WaitPlan::successRate(){ return 1.0;}bool WaitPlan::isFinished(){ if (!wm->isBallKickable()) return false; Plan *tempPlan = bestPlan(2, true, new PassPlan(wm, form, library, BPM_SECUREBALL, fPlayer, -180, 180, -180, 180), new PassPlan(wm, form, library, BPM_SECUREBALL, bPlayer, -180, 180, -180, 180)); bool finished = true; if (tempPlan->successRate() >= minSuccessRate) finished = false; delete tempPlan; return finished;}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -