📄 gotosideplan.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 <GotoSidePlan.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;GotoSidePlan::GotoSidePlan(const WorldModel *wm, Form &form, const Library &library, Side side): Plan("GotoSide", wm, form, library), side(side), passCycle(0), getBallCycle(0), minSuccessRate(.24){}GotoSidePlan::~GotoSidePlan(){}void GotoSidePlan::decide(){ if (side == SI_LEFT) LOG << "GotoSidePlan::decide (Side : Left)" << endl; else LOG << "GotoSidePlan::decide (Side : Right)" << endl; Plan::decide(); if (wm->isBallKickable()) { if (!getBallCycle) getBallCycle = wm->getCurCycle(); passCycle = wm->getCurCycle(); switch (side) { case SI_LEFT: if (wm->getBody().getUniNum() == 2) startPlan(new PassPlan(wm, form, library, BPM_BREAKOFFSIDE + BPM_OFFENSE, 10, 70, 110, 60, 120), minSuccessRate); startPlan(bestPlan(6, true, new PassPlan(wm, form, library, BPM_SECUREBALL + BPM_OFFENSE, 2, 0, 120, 0, 120), new PassPlan(wm, form, library, BPM_SECUREBALL + BPM_OFFENSE, 3, 0, 120, 0, 120), new PassPlan(wm, form, library, BPM_SECUREBALL + BPM_OFFENSE, 4, 0, 120, 0, 120), new PassPlan(wm, form, library, BPM_SECUREBALL + BPM_OFFENSE, 7, 0, 120, 0, 120), new PassPlan(wm, form, library, BPM_SECUREBALL + BPM_OFFENSE, 8, 0, 120, 0, 120), new PassPlan(wm, form, library, BPM_SECUREBALL + BPM_OFFENSE, 11, 0, 120, 0, 120)), minSuccessRate); break; case SI_RIGHT: if (wm->getBody().getUniNum() == 4) startPlan(new PassPlan(wm, form, library, BPM_BREAKOFFSIDE + BPM_OFFENSE, 11, -110, -70, -120, -60), minSuccessRate); startPlan(bestPlan(6, true, new PassPlan(wm, form, library, BPM_SECUREBALL + BPM_OFFENSE, 4, -120, 0, -120, 0), new PassPlan(wm, form, library, BPM_SECUREBALL + BPM_OFFENSE, 3, -120, 0, -120, 0), new PassPlan(wm, form, library, BPM_SECUREBALL + BPM_OFFENSE, 2, -120, 0, -120, 0), new PassPlan(wm, form, library, BPM_SECUREBALL + BPM_OFFENSE, 8, -120, 0, -120, 0), new PassPlan(wm, form, library, BPM_SECUREBALL + BPM_OFFENSE, 7, -120, 0, -120, 0), new PassPlan(wm, form, library, BPM_SECUREBALL + BPM_OFFENSE, 10, -120, 0, -120, 0)), minSuccessRate); break; } passCycle = 0; 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 { getBallCycle = 0; if (library.gwSelection == WOBS_INTERCEPT) startPlan(new InterceptPlan(wm, form, library)); startPlan(new OffensePosPlan(wm, form, library)); } LOG << "GotoSidePlan Now Kill Program" << endl; assert(0);}double GotoSidePlan::successRate(){ return 1.0;}bool GotoSidePlan::isFinished(){ if (passCycle == wm->getCurCycle() - 1) { if (side == SI_LEFT) { form.sayForm.planSay = true; form.sayForm.planHeader = "X"; form.sayForm.planInfo = "GSPL"; } else { form.sayForm.planSay = true; form.sayForm.planHeader = "X"; form.sayForm.planInfo = "GSPR"; } return true; } if (!wm->isBallKickable()) return false; if (getBallCycle + 5 >= wm->getCurCycle()) return true; try { switch (side) { case SI_LEFT: if (wm->getBody().getUniNum() == 2) throw (new PassPlan(wm, form, library, BPM_BREAKOFFSIDE + BPM_OFFENSE, 10, 70, 110, 60, 120)); throw (bestPlan(7, true, new PassPlan(wm, form, library, BPM_SECUREBALL + BPM_OFFENSE, 2, 0, 120, 0, 120), new PassPlan(wm, form, library, BPM_SECUREBALL + BPM_OFFENSE, 3, 0, 120, 0, 120), new PassPlan(wm, form, library, BPM_SECUREBALL + BPM_OFFENSE, 4, 0, 120, 0, 120), new PassPlan(wm, form, library, BPM_SECUREBALL + BPM_OFFENSE, 5, 0, 120, 0, 120), new PassPlan(wm, form, library, BPM_SECUREBALL + BPM_OFFENSE, 7, 0, 120, 0, 120), new PassPlan(wm, form, library, BPM_SECUREBALL + BPM_OFFENSE, 8, 0, 120, 0, 120), new PassPlan(wm, form, library, BPM_SECUREBALL + BPM_OFFENSE, 11, 0, 120, 0, 120))); break; case SI_RIGHT: if (wm->getBody().getUniNum() == 4) throw (new PassPlan(wm, form, library, BPM_BREAKOFFSIDE + BPM_OFFENSE, 11, -110, -40, -120, -40)); throw (bestPlan(7, true, new PassPlan(wm, form, library, BPM_SECUREBALL + BPM_OFFENSE, 4, -120, 0, -120, 0), new PassPlan(wm, form, library, BPM_SECUREBALL + BPM_OFFENSE, 3, -120, 0, -120, 0), new PassPlan(wm, form, library, BPM_SECUREBALL + BPM_OFFENSE, 2, -120, 0, -120, 0), new PassPlan(wm, form, library, BPM_SECUREBALL + BPM_OFFENSE, 5, -120, 0, -120, 0), new PassPlan(wm, form, library, BPM_SECUREBALL + BPM_OFFENSE, 8, -120, 0, -120, 0), new PassPlan(wm, form, library, BPM_SECUREBALL + BPM_OFFENSE, 7, -120, 0, -120, 0), new PassPlan(wm, form, library, BPM_SECUREBALL + BPM_OFFENSE, 10, -120, 0, -120, 0))); break; } } catch(Plan *tempPlan) { bool finished = true; if (tempPlan->successRate() >= minSuccessRate) finished = false; delete tempPlan; return finished; } if (((isInPlayers(wm->getBody().getUniNum(), "234578B") && side == SI_LEFT) || (isInPlayers(wm->getBody().getUniNum(), "234578A") && side == SI_RIGHT))) return false; return true;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -