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

📄 agent.h

📁 RoboCup 3D 仿真组清华大学2005的源代码
💻 H
字号:
/*************************************************************************** *   Copyright (C) 2005 by Rujia Liu                                       * *   rujialiu@hotmail.com                                                  * *                                                                         * *   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; either version 2 of the License, or     * *   (at your option) any later version.                                   * *                                                                         * *   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.,                                       * *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * ***************************************************************************/#ifndef AGENT_H#define AGENT_H#include <iostream>#include <zeitgeist/leaf.h>#include "logserver.h"const int max_cycle = 80000; // actually 60000const int buffer_size = 8192; // reading from CommServerstruct AgentParam{        bool action_log;    bool wmb_log;    bool wm_log;    bool wm_logvision;    bool wm_logcur;    bool decision_log;    bool skill_log;    bool formation_log;        bool offclient_rec;    bool offclient_do;    char offclient_file[100];    float offclient_time;};class Agent{public:    Agent();    ~Agent();public:    // sense-think-act cycle    int Behave();    void SetTeamName(std::string name) { mTeamName = name; }    void SetTeamUnum(int unum) { mTeamUnum = unum; }        // providing action history    const salt::Vector3f& GetDriveVec() { return mLastDriveVec; }    const salt::Vector3f& GetDriveVec(int t)     { if(t > mLastDriveTime) return mLastDriveVec; else return mDriveVec[t]; }    public:    // simulation    void Kick(const float angle, const float power, bool send = false);    void Beam(const salt::Vector3f& position, bool send = false);    void Drive(const salt::Vector3f& driveVec, bool send = false);        // SPADES    int GetCycleStep() { return CycleStep; }        int SetCycleStep(int cs) { CycleStep = cs; }    int GetThinkingTime();    void RequestTimeNotify(int sim_time);    // log system        void OpenLog();    void LogTime();        // initialization when type (team + unum) is known    bool IsTypeKnown();    int InitPlayer();    protected:        void InitAgent();    void CreateAgent();        bool execBeam;    bool execKick;    bool execDrive;        salt::Vector3f BeamParam;    salt::Vector3f DriveParam;    float kick_angle;    float kick_power;          int mTeamUnum;    int mSensationCount;    salt::Vector3f mLastDriveVec;    salt::Vector3f mDriveVec[max_cycle];    int mLastDriveTime; // last time that sends a drive commandprotected:            bool GetInput();    void PutOutput(const char* out);    void PutOutput(const std::string& str);        const char* GetMsg() const { return mBuffer + sizeof(long); }            bool SelectInput();        int mReadFd;    int mWriteFd;    char mBuffer[buffer_size];public:    LogServer log;    FILE* offclient_fp;    std::string mTeamName;    int CycleStep;    bool PlayerInitialized;};#endif

⌨️ 快捷键说明

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