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

📄 rootplan.cpp

📁 2006年世界杯足球赛2D仿真组第16名的源代码。在此代码上随便改改
💻 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 *  and is modified by: Ahmad Boorghany * *  Released on Monday 1 August 2005, 10 Mordad 1384 by Mersad RoboCup Team. *  For more information please read README file.*/#include <iostream>#include <Logger.h>#include <Basics.h>#include <RootPlan.h>#include <GoalPlan.h>#include <ClearPlan.h>#include <SayEncoding.h>#include <AdvancedAgent.h>#include <BackToForwardPlan.h>#include <cassert>using namespace std;using namespace Basics;RootPlan::RootPlan(const WorldModel * wm, Form &form, const Library &library):		Plan("Root", wm, form, library){	LOG << "Planing System Start." << endl;	iShouldRestore = false;	crossPair = NULL;}RootPlan::~RootPlan(){}double RootPlan::successRate(){ 	return 1.0;}bool RootPlan::isFinished() {	if (isInPlayers(wm->getBody().getUniNum(), "6789"))	{		resetPlans();		return true;	}	if (wm->getPlayMode() != PM_PLAY_ON)	{		resetPlans();		return true;	}	if (library.gwSelection == WOBS_LOOKFORBALL || wm->getBody().isGoalie() ||			library.gwSelection == WOBS_BLOCK || library.gwSelection == WOBS_DEFENSE)	{		resetPlans();		return true;	}	if (wm->isBallKickable() && wm->getPlayMode() == PM_PLAY_ON &&			!wm->getBody().isGoalie() && library.gwSelection != WOBS_DEFENSE &&			library.gwSelection != WOBS_INTERCEPT)		return false;	return false;}void RootPlan::decide(){	LOG << "RootPlan::decide" << endl;/*	if (wm->isBallKickable())		if (isInPlayers(wm->getBody().getUniNum(), "27"))				form.sayForm.attentionNum = 10;		else if (isInPlayers(wm->getBody().getUniNum(), "48"))			form.sayForm.attentionNum = 11;		else if (wm->getBody().getUniNum() == 3)			form.sayForm.attentionNum = (wm->getBody().getPos().getY() > 0)?10:11;*/	startPlan(new ClearPlan(wm, form, library)); // An urgent plan//LOG << "\tAA  1" << endl;//LOG << "\tAA  iShouldRestore" << iShouldRestore << endl;	if (iShouldRestore)	{//LOG << "\tAA  2" << endl;		resetPlans();		if (crossPair)		{//LOG << "\tAA  3" << endl;			subPlans.push(crossPair);			crossPair = NULL;		}		else		//{//LOG << "\tAA  4" << endl;			startPlan(new CrossPlan(wm, form, library));//}	}	iShouldRestore = false;//LOG << "\tAA  5" << endl;	if (crossPair)	{		delete crossPair;		crossPair = NULL;	}	if (!subPlans.empty() &&		dynamic_cast<CrossPlan *>(subPlans.top()))	{//LOG << "\tAA  6" << endl;		crossPair = new CrossPlan(*(dynamic_cast<CrossPlan *>(subPlans.top())));		crossPair->resetAfterCopy();		iShouldRestore = true;	}//LOG << "\tAA  7" << endl;	if (!subPlans.empty() &&		dynamic_cast<BackToForwardPlan *>(subPlans.top()))	{//LOG << "\tAA  8" << endl;		Plan *cPlan = new CrossPlan(wm, form, library);		float val = cPlan->successRate();		if (val > 0.50)		{			resetPlans();			startPlan(cPlan);		}	}//LOG << "\tAA  9" << endl;	Plan::decide();//LOG << "\tAA  10" << endl;	iShouldRestore = true;		startPlan(new CrossPlan(wm, form, library));//LOG << "\tAA  11" << endl;	startPlan(new BackToForwardPlan(wm, form, library));//LOG << "\tAA  12" << endl;	startPlan(new GoalPlan(wm, form, library));//LOG << "\tAA  13" << endl;	LOG << "RootPlan Now Kill Program." << endl;	assert(0);}	void RootPlan::senseBody(const SExpression &exp){	iShouldRestore = false;}

⌨️ 快捷键说明

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