📄 soccertypes.h
字号:
/*****************************************************************************/
/*! 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 $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 );
bool makeTackleCommand ( char *str );
bool makePointToCommand ( 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 a command be sent */
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
bool getCommandString( char *str, ServerSettings *ss );
} ;
/*****************************************************************************/
/********************* CLASS FEATURE *****************************************/
/*****************************************************************************/
/*! This class contains information for one specific feature (e.g., fastest
teammate to the ball. A feature corresponds to a specific time and is often
related to a specific object and a specific value. Therefore, these values
are stored in this class. */
class Feature
{
Time m_timeSee; /*!< see time corresponding to stored information*/
Time m_timeSense;/*!< sense time corresponding to stored info */
Time m_timeHear; /*!< hear time corresponding to stored info */
ObjectT m_object; /*!< object information stored with this feature */
double m_dInfo; /*!< information stored with this feature */
VecPosition m_vec; /*!< information stored with this feature */
SoccerCommand m_soc; /*!< command stored with this feature */
public:
// standard get and set methods
Feature( );
Feature( Time timeSee,
Time timeSense,
Time timeHear,
ObjectT object,
double dInfo = UnknownDoubleValue,
SoccerCommand soc = SoccerCommand(CMD_ILLEGAL),
VecPosition pos = VecPosition(0,0) );
bool setFeature ( Time timeSee,
Time timeSense,
Time timeHear,
ObjectT object,
double dInfo = UnknownDoubleValue,
SoccerCommand soc = SoccerCommand(CMD_ILLEGAL),
VecPosition pos = VecPosition(0,0) );
bool setTimeSee ( Time time );
Time getTimeSee ( );
bool setTimeSense( Time time );
Time getTimeSense( );
bool setTimeHear ( Time time );
Time getTimeHear ( );
bool setObject ( ObjectT obj );
ObjectT getObject ( );
bool setInfo ( double d );
double getInfo ( );
bool setVec ( VecPosition pos );
VecPosition getVec ( );
bool setCommand ( SoccerCommand soc );
SoccerCommand getCommand ( );
} ;
/*****************************************************************************/
/********************** 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 *strTe=NULL);
static ObjectT getObjectFromStr ( char **str,
bool *isGoalie,
const char *strTeam );
static bool isInSet ( ObjectT o,
ObjectSetT o_s,
ObjectT objectGoalie=
OBJECT_TEAMMATE_1 );
static bool isPlayerTypeInSet ( PlayerT p,
PlayerSetT p_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 );
static AngDeg getAngleFromDirection ( DirectionT dir );
} ;
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -