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

📄 gamestateperceptor.cpp

📁 ROBOCUP 仿真3D server 源码
💻 CPP
字号:
/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*-   this file is part of rcssserver3D   Fri May 9 2003   Copyright (C) 2002,2003 Koblenz University   Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group   $Id: gamestateperceptor.cpp,v 1.5 2004/06/09 09:22:27 fruit Exp $   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; version 2 of the License.   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 General Public License for more details.   You should have received a copy of the GNU General Public License   along with this program; if not, write to the Free Software   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.*/#include "gamestateperceptor.h"#include <zeitgeist/logserver/logserver.h>#include <soccer/soccerbase/soccerbase.h>#include <soccer/agentstate/agentstate.h>#include <soccer/gamestateaspect/gamestateaspect.h>using namespace zeitgeist;using namespace oxygen;using namespace boost;using namespace std;GameStatePerceptor::GameStatePerceptor() : oxygen::Perceptor(){    mFirstPercept = true;}GameStatePerceptor::~GameStatePerceptor(){}voidGameStatePerceptor::InsertSoccerParam(Predicate& predicate, const std::string& name){    float value;    if (! SoccerBase::GetSoccerVar(*this,name,value))    {        return;    }    ParameterList& element = predicate.parameter.AddList();    element.AddValue(name);    element.AddValue(value);}voidGameStatePerceptor::InsertInitialPercept(Predicate& predicate){    // uniform number    ParameterList& unumElement = predicate.parameter.AddList();    unumElement.AddValue(string("unum"));    unumElement.AddValue(mAgentState->GetUniformNumber());    // team index    std::string team;    switch (mAgentState->GetTeamIndex())    {    case TI_NONE :        team = "none";        break;    case TI_LEFT :        team = "left";        break;    case TI_RIGHT :        team = "right";        break;    }    ParameterList& teamElement = predicate.parameter.AddList();    teamElement.AddValue(string("team"));    teamElement.AddValue(team);    // soccer variables    // field geometry parameter    InsertSoccerParam(predicate,"FieldLength");    InsertSoccerParam(predicate,"FieldWidth");    InsertSoccerParam(predicate,"FieldHeight");    InsertSoccerParam(predicate,"GoalWidth");    InsertSoccerParam(predicate,"GoalDepth");    InsertSoccerParam(predicate,"GoalHeight");    InsertSoccerParam(predicate,"BorderSize");    // agent parameter    InsertSoccerParam(predicate,"AgentMass");    InsertSoccerParam(predicate,"AgentRadius");    InsertSoccerParam(predicate,"AgentMaxSpeed");    // ball parameter    InsertSoccerParam(predicate,"BallRadius");    InsertSoccerParam(predicate,"BallMass");}boolGameStatePerceptor::Percept(boost::shared_ptr<PredicateList> predList){    if (        (mGameState.get() == 0) ||        (mAgentState.get() == 0)        )    {        return false;    }    Predicate& predicate = predList->AddPredicate();    predicate.name = "GameState";    predicate.parameter.Clear();    // with the first GameState percept after the player is assigned    // to a team it receives info about it's team and unum assignment    // along with outher soccer parameters    if (        (mFirstPercept) &&        (mAgentState->GetTeamIndex() != TI_NONE)        )    {        mFirstPercept = false;        InsertInitialPercept(predicate);    }    // time    ParameterList& timeElement = predicate.parameter.AddList();    timeElement.AddValue(string("time"));    timeElement.AddValue(mGameState->GetTime());    // playmode    ParameterList& pmElement = predicate.parameter.AddList();    pmElement.AddValue(string("playmode"));    pmElement.AddValue(SoccerBase::PlayMode2Str(mGameState->GetPlayMode()));    return true;}voidGameStatePerceptor::OnLink(){    SoccerBase::GetGameState(*this,mGameState);    SoccerBase::GetAgentState(*this,mAgentState);}voidGameStatePerceptor::OnUnlink(){    mGameState.reset();    mAgentState.reset();}

⌨️ 快捷键说明

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