📄 soccertypes.h
字号:
/*! The TiredNessT enumeration contains different values that indicate how tired an agent is. */enum TiredNessT { TIREDNESS_ILLEGAL, /*!< illegal tiredness value */ TIREDNESS_GOOD, /*!< player is not tired at all */ TIREDNESS_AVERAGE, /*!< average tiredness */ TIREDNESS_BAD, /*!< player starts to get tired */ TIREDNESS_VERY_BAD /*!< player is so tired it can hardly move */} ;/******************************************************************************//********************** CLASS TIME ******************************************//******************************************************************************//*! This class contains the time representation of the soccer server. It is represented by an ordered pair (t,s) where t denotes the current server cycle and s is the number of cycles since the clock has stopped. Here the value for t equals that of the time stamp contained in the last message received from the server, whereas the value for $s$ will always be 0 while the game is in progress. It is only during certain dead ball situations (e.g. an offside call leading to a free kick) that this value will be different, since in these cases the server time will stop while cycles continue to pass (i.e. actions can still be performed). Representing the time in this way has the advantage that it allows the players to reason about the number of cycles between events in a meaningful way. */class Time{ int m_iTime; /*!< Number of cycles, denoting the time */ int m_iStopped; /*!< Number of cycles stopped at m_iTime */public: Time ( int iTime = -1, int iStopped = 0 ); bool updateTime ( int iTime ); bool setTimeStopped ( int iTime ); int getTime ( ); int getTimeStopped ( ); int getTimeDifference( Time t ); bool isStopped ( ); Time getTimeAddedWith ( int iCycles ); bool addToTime ( int iCycles ); void show ( ostream &os = cout ); // overloaded arithmetic operators Time operator + ( const int &i ); Time operator + ( Time t ); Time operator - ( const int &i ); int operator - ( Time t ); void operator = ( const int &i ); void operator += ( Time t ); void operator += ( const int &i ); void operator -= ( Time t ); void operator -= ( const int &i ); bool operator != ( Time t ); bool operator != ( const int &i ); bool operator == ( Time t ); bool operator == ( const int &i ); bool operator < ( Time t ); bool operator < ( const int &i ); bool operator <= ( Time t ); bool operator <= ( const int &i ); bool operator > ( Time t ); bool operator > ( const int &i ); bool operator >= ( Time t ); bool operator >= ( const int &i ); // methods for producing output friend ostream& operator << ( ostream &os, Time t );} ;/******************************************************************************//********************** CLASS SOCCERCOMMAND ***********************************//******************************************************************************//*!This class resembles a SoccerCommand that contains all the information about a command that can be sent to the server, but the format is independent from the server implementation. A SoccerCommand can be created and before it is sent to the server, be converted to the actual string representation understood by the server. */class SoccerCommand{ ServerSettings *SS; /*!< ServerSettings are used to check ranges of command*/ // private methods to generate text string to sent to server bool makeCatchCommand ( char *str ); bool makeChangeViewCommand ( char *str ); bool makeDashCommand ( char *str ); bool makeKickCommand ( char *str ); bool makeMoveCommand ( char *str ); bool makeSayCommand ( char *str ); bool makeSenseBodyCommand ( char *str ); bool makeTurnCommand ( char *str ); bool makeTurnNeckCommand ( char *str ); bool makeChangePlayerCommand( char *str ); bool makeAttentionToCommand ( char *str );public: // different variables that are used by the different possible commands // only the variables that are related to the current commandType have // legal values Time time; /*!< command time, will be set by worldmodel */ CommandT commandType; /*!< type of this command */ double dAngle; /*!< angle of this command (for turn,turn_neck) */ double dPower; /*!< power of this command (for kick,dash) */ ViewQualityT vq; /*!< view quality (for change_view) */ ViewAngleT va; /*!< view angle (for change_view) */ double dX; /*!< x coordinate (for move) */ double dY; /*!< y coordinate (for move) */ char str[MAX_SAY_MSG];/*!< str (for say) */ int iTimes; /*!< how many cycles will command be sent in a row*/ SoccerCommand( CommandT com = CMD_ILLEGAL, double d1=UnknownDoubleValue, double d2=UnknownDoubleValue, double d3=UnknownDoubleValue ); SoccerCommand( CommandT com, char *msg ); // command to set the different values of the SoccerCommand void makeCommand( CommandT com, double d1 = UnknownDoubleValue, double d2 = UnknownDoubleValue, double d3 = UnknownDoubleValue ); void makeCommand( CommandT com, ViewAngleT v, ViewQualityT q ); void makeCommand( CommandT com, char *msg ); bool isIllegal ( ); void show ( ostream& os ); // used to return the string representation of this SoccerCommand char* getCommandString( char *str, ServerSettings *ss );} ;/******************************************************************************//********************** CLASS SOCCERTYPES *************************************//******************************************************************************//*! The class SoccerTypes contains different methods to work with the different enumerations defined in SoccerTypes.h. It is possible to convert soccertypes to strings and strings to soccertypes. It is also possible to get more specific information about some of the soccertypes. All methods are static so it is possible to call the methods without instantiating the class. */class SoccerTypes{ public: // methods that deal with the differen objects static char* getObjectStr ( char *strBuf, ObjectT o, const char *strTeam ); static ObjectT getObjectFromStr ( char **str, bool *isGoalie, const char *str ); static bool isInSet ( ObjectT o, ObjectSetT o_s ); static bool isFlag ( ObjectT o ); static bool isLine ( ObjectT o ); static bool isGoal ( ObjectT o ); static ObjectT getOwnGoal ( SideT s ); static ObjectT getGoalOpponent ( SideT s ); static bool isBall ( ObjectT o ); static bool isTeammate ( ObjectT o ); static bool isOpponent ( ObjectT o ); static bool isGoalie ( ObjectT o ); static bool isPlayer ( ObjectT o ); static bool isKnownPlayer ( ObjectT o ); static int getIndex ( ObjectT o ); static ObjectT getTeammateObjectFromIndex( int iIndex ); static ObjectT getOpponentObjectFromIndex( int iIndex ); static VecPosition getGlobalPositionFlag ( ObjectT o, SideT s, double dGoalWidth = 14.02); static AngDeg getGlobalAngleLine ( ObjectT o, SideT s ); // methods that deal with the differen play modes static PlayModeT getPlayModeFromStr ( char *str ); static PlayModeT getPlayModeFromRefereeMessage( RefereeMessageT rm ); static char* getPlayModeStr ( PlayModeT p ); static char* getRefereeMessageStr ( RefereeMessageT r ); static RefereeMessageT getRefereeMessageFromStr ( char *str ); // methods that deal with the frequency of the visual information static char* getViewAngleStr ( ViewAngleT v ); static ViewAngleT getViewAngleFromStr ( char *str ); static AngDeg getHalfViewAngleValue ( ViewAngleT va ); static char* getViewQualityStr ( ViewQualityT v ); static ViewQualityT getViewQualityFromStr ( char *str ); // methods that deal with the commands static char* getCommandStr ( CommandT com ); static bool isPrimaryCommand ( CommandT com ); // methods that deal with the side information static char* getSideStr ( SideT s ); static SideT getSideFromStr ( char* str ); // methods that deal with the status of the ball. static char* getBallStatusStr ( BallStatusT bs ); static BallStatusT getBallStatusFromStr ( char *str );} ;#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -