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

📄 formation.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 FORMATION_H#define FORMATION_H#include <string>#include <zeitgeist/leaf.h>#include "logserver.h"//Formation Mode#define  FS_Normal 0 #define  FS_Open 1#define  FS_Close 2#define  FS_SameWithTeam 3#define  FS_Attack 0#define  FS_Defense 1#define  FS_ShowPass 2#define  FS_Either 0#define  FS_Center 1#define  FS_Side 2#define  FS_Mark 1#define  FS_Position 2//attack Direction#define  FS_All 0#define  FS_BothSide 2#define  FS_Left 3#define  FS_Right 4//Defense Mode#define  FS_Hard 1#define  FS_Easy 2//Attack Mode#define  FS_Risk 1#define  FS_Safe 2#define PENALTY_AREA_WIDTH    16.5#define PENALTY_AREA_LENGTH   40.32#define SBP_Attack 1#define SBP_Defense 2const int SP_team_size = 11;const int Num_playertypes = 20;typedef int SNum;typedef int FNum;extern float SBP_DY[],SBP_DX[];extern float init_x_pos[], init_y_pos[];class Formation{protected:struct tPlayerType{   char Name[256];   int id;   salt::Vector2f BasePosition;                        // through inputfile".fmt"   salt::Vector2f SBPosition[2][SP_team_size][9];      // through inputfile ".sbp"   float AttackRate,DefenseRate;        salt::Vector2f GetStrategicPosition(salt::Vector2f ballposition,salt::Vector2f playerbsp,int situation);};  struct tActivity{    int RunWithBall;    int ControlBall;    int Dribble;    int PreferPassRoute;     // {Either,Center,Side}    int PreferDefense;       // {Either,Mark,Position}    int FormationMode;       // {Normal,Open,Close,SameWithTeam}    float AttackRate,DefenseRate;};  // libraryprotected:    tPlayerType ptype[Num_playertypes + 1];    int GetIndex(const char* s);    int SetPlayerTypes(const char* fileName);// formationprotected:    int iPlayerType[SP_team_size+1];      // index of ptype    salt::Vector2f BaseStrategicPosition[SP_team_size+1];    tActivity Activity[SP_team_size+1];      char Name[256];    float AttackRate,DefenseRate;    int AttackDirection;  //{All,Center,BothSide,Left,Right}    int FormationMode;        //{Normal,Open,Close}    int DefenseMode;          //{Normal,Hard,Easy}    int AttackMode;           //{Normal,Risk,Safe}  public:    Formation();    ~Formation();    char SBPFile[1000];    char FMTFile[1000];    LogServer log;      int Init();    salt::Vector3f GetBSP(int unum)    {        return salt::Vector3f(BaseStrategicPosition[unum][0], BaseStrategicPosition[unum][1], 0.22);    }     int SetFormation(char* filename);      salt::Vector3f GetInitialFormation(int unum)    {        return salt::Vector3f(init_x_pos[unum-1], init_y_pos[unum-1], 0.0);    }      salt::Vector2f GetStrategicPosition(int situation, salt::Vector2f& ballpos, SNum number);      salt::Vector3f GetStrategicPosition(int situation, salt::Vector3f& ballpos, SNum number)    {        salt::Vector2f bp(ballpos[0], ballpos[1]);        salt::Vector2f v = GetStrategicPosition(situation, bp, number);        return salt::Vector3f(v[0], v[1], 0.22);    }      //on the point of calling ,give the  behavior's worldmodel.    const tActivity& GetActivity(SNum no) const    {        return Activity[no];    }                                                  const tPlayerType& GetPlayerType(SNum no) const    {        if(no < 1 || no > SP_team_size) return ptype[Num_playertypes]; // dummy        return ptype[iPlayerType[no]];      }      bool IsGoalie(SNum teamNum)    {         return teamNum == 1;     }    bool IsMiddle(SNum teamNum)    {        char s[256];        strcpy(s, ptype[iPlayerType[teamNum]].Name);        if(s=="ML" || s=="MR" || s=="MC")            return true;        return false;    }    bool IsForward(SNum teamNum)    {        char s[256];        strcpy(s, ptype[iPlayerType[teamNum]].Name);        if( s=="FL" || s=="FR" || s=="SC"|| s=="FC")            return true;        return false;    }    bool IsDefenser(SNum teamNum)    {        char s[256];        strcpy(s, ptype[iPlayerType[teamNum]].Name);        if( s=="DL" || s=="DR" || s=="DC"|| s=="DMC")            return true;        return false;    }  };#endif

⌨️ 快捷键说明

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