?? worldmodel.c
字號:
/*! This method returns the goal difference. When this value is below zero, the team of agent is behind, 0 means that the score is currently the same for both teams and a value higher than zero means that you're winning!. \return goal difference */int WorldModel::getGoalDiff( ) const{ return iGoalDiff;}/*!This method adds one goal to the goal difference. Call this method when your team has scored a goal \return new goal difference */int WorldModel::addOneToGoalDiff( ){ return ++iGoalDiff;}/*!This method subtracts one from the goal difference. Call this method when you're team has conceided a goal \return new goal difference */int WorldModel::subtractOneFromGoalDiff(){ return --iGoalDiff;}/*! This method returns the amount of commands c performed by the agent. This is supplied in the sense_body message. \param c CommandT of which number of commands should be returned. \return amount of commands c performed by the soccerserver. */int WorldModel::getNrOfCommands( CommandT c ) const{ return iCommandCounters[ (int) c ];}/*! This method sets the number of commands c that were performed by the agent. This is supplied in the sense_body message and can be used to check whether an action is actually performed by the soccer server, since the corresponding counter should be one higher than the previous sense_body message. When this is the case the corresponding index of the PerformedCommands array is set to true. \param c CommandT of which the number of commands should be set. \param i number of commands that are performed of this command \return bool indicating whether update was performed. */bool WorldModel::setNrOfCommands( CommandT c, int i ){ int iIndex = (int) c; // if counter is the same as before, no command is performed, otherwise it is performedCommands[iIndex] = ( iCommandCounters[iIndex] == i ) ? false : true; iCommandCounters [iIndex] = i; return true;}/*! This method returns the time the status of the ball was last checked (coach only). \return server cycle the status of the ball was last checked. */Time WorldModel::getTimeCheckBall( ) const{ return timeCheckBall;}/*! This method sets the time the ball was checked for the last time (coach only). \param time server time ball was checked. \return bool indicating whether update was succesfull. */bool WorldModel::setTimeCheckBall( Time time ){ timeCheckBall = time; return true;}/*! This method returns the status of the ball. This value is derived from the check_ball command that can only be used by the coach. The status of the ball corresponds to the server time returned by getTimeCheckBall. \return BallStatus status of the ball. */BallStatusT WorldModel::getCheckBallStatus( ) const{ return bsCheckBall;}/*! This method sets the status of the ball. The status of the ball corresponds to the server time returned by getTimeCheckBall. This method is only useful for the coach, since only he can sent a check_ball message. \return BallStatus status of the ball. */bool WorldModel::setCheckBallStatus( BallStatusT bs ){ bsCheckBall = bs; return true;}/*!This method starts an iteration over an object set g. This method will return the first ObjectT in an ObjectSetT that has a confidence higher than dConf. After this call use the method iterateObjectNext with the same argument to get the other objects that belong to this set. \param iIndex index that should be used in consecutive cycles. \param g ObjectSetT of which the ObjecT should be returned. \param dConf minimum confidence needed for ObjectT to be returned. \return ObjectT that is first in the set g. */ObjectT WorldModel::iterateObjectStart(int& iIndex,ObjectSetT g,double dConf){ iIndex = -1; return iterateObjectNext( iIndex, g, dConf);}/*!This method gets the next object in the iteration over an object set g. iterateObjectStart should have been called first. Only ObjectT with a confidence higher than dConf will be returned. When no more objects are available OBJECT_ILLEGAL is returned. \param iIndex same argument as was supplied to iterateObjectStart. \param g ObjectSetT of which the ObjecT should be returned. \param dConf minimum confidence needed for ObjectT to be returned. \return ObjectT that is next in the set g. */ObjectT WorldModel::iterateObjectNext(int& iIndex,ObjectSetT g, double dConf){ ObjectT o = OBJECT_ILLEGAL;; if( iIndex < 0 ) iIndex = -1; // when dConf is not specified it has the default value of -1.0, in this // case set it to the confidence threshold defined in PlayerSetting, but // only do this for dynamic objexts, not for flags, lines, etc. since all // should be returend. if( dConf == -1.0 && (g==OBJECT_SET_OPPONENTS || g==OBJECT_SET_PLAYERS || g==OBJECT_SET_TEAMMATES) ) dConf = PS->getPlayerConfThr(); for( int i = iIndex + 1 ; i < OBJECT_MAX_OBJECTS; i ++ ) { o = (ObjectT) i; if( SoccerTypes::isInSet( o, g ) ) { if( getConfidence( o ) >= dConf ) { iIndex = i; return o; } else if( dConf == 1.0 && getTimeLastSeeMessage() == getTimeLastSeen( o ) ) { iIndex = i; // confidence of 1.0 can only be in same cycle as see return o; // message. Therefore first test should succeed normally; } // in cases where this method is called after see message, // but new sense has already arrived, confidence is lowered } // but we want to return object that was seen in last see } // message; this compensates for those cases. return OBJECT_ILLEGAL;}/*!This method finsished the iteration. It should be called after iterateObjectNext has returned OBJECT_ILLEGAL indicating no more objects are available that satisfy the constraints. \param iIndex index of iteration */void WorldModel::iterateObjectDone( int &iIndex ){ iIndex = -1;}/*! This method returns the ObjectType of the agent. This is an ObjectT between OBJECT_TEAMMATE_1 and OBJECT_TEAMMATE_11 \return ObjectT that represent the type of the agent */ObjectT WorldModel::getAgentObjectType( ) const{ return agentObject.getType();}/*! This method sets the ObjectType of the agent. This is an objectT between OBJECT_TEAMMATE_1 and OBJECT_TEAMMATE_11 \param ObjectT that represent the type of the agent \return bool indicating whether the update was succesful */bool WorldModel::setAgentObjectType( ObjectT o ){ agentObject.setType( o ); return true;}/*! This method returns the body angle relative to the neck of the agent. \return AngDeg representing the body angle relative to the neck */AngDeg WorldModel::getAgentBodyAngleRelToNeck( ) const{ return agentObject.getBodyAngleRelToNeck();}/*! This method returns the global neck angle of the agent in the world. \return global neck angle agent */AngDeg WorldModel::getAgentGlobalNeckAngle( ) const{ return agentObject.getGlobalNeckAngle( );}/*! This method returns the global body angle of the agent in the world. \return global body angle agent */AngDeg WorldModel::getAgentGlobalBodyAngle( ){ return agentObject.getGlobalBodyAngle( );}/*! This method returns the stamina information of the agent \return Stamina stamina of the agent */Stamina WorldModel::getAgentStamina( ) const{ return agentObject.getStamina();}/*! This method returns a TiredNessT value that indicates how tired the agent is. \return TiredNessT value that indicates how tired the agent is. */TiredNessT WorldModel::getAgentTiredNess( ) const{ return getAgentStamina().getTiredNess( SS->getRecoverDecThr(), SS->getStaminaMax() );}/*! This method returns the effort information of the agent \return double effort of the agent */double WorldModel::getAgentEffort( ) const{ return agentObject.getStamina().getEffort();}/*! This method returns the global velocity information of the agent \return global velocity of the agent */VecPosition WorldModel::getAgentGlobalVelocity( ) const{ return agentObject.getGlobalVelocity();}/*! This method returns the speed of the agent \return speed of the agent */double WorldModel::getAgentSpeed( ) const{ return agentObject.getSpeed();}/*! This method returns the global position of the agent \return global position of the agent */VecPosition WorldModel::getAgentGlobalPosition( ) const{ return agentObject.getGlobalPosition();}/*! This method returns the view angle of the agent. \return ViewAngleT view angle of the agent (VA_NARROW, VA_NORMAL, VA_WIDE)*/ViewAngleT WorldModel::getAgentViewAngle( ) const{ return agentObject.getViewAngle();}/*! This method returns the view quality of the agent \return ViewQualityT of the agent (VA_LOW, VA_HIGH). */ViewQualityT WorldModel::getAgentViewQuality( ) const{ return agentObject.getViewQuality();}/*! This method returns the view frequency of see messages for the agent relative to the time of the sense_body interval. So 0.5 means a see message arrives twice in every simulation cycle. \return double representing the view frequency */double WorldModel::getAgentViewFrequency( ViewAngleT va, ViewQualityT vq ) { double dViewQualityFactor = 0.0; double dViewWidthFactor = 0.0; if( va == VA_ILLEGAL ) va = getAgentViewAngle(); if( vq == VQ_ILLEGAL ) vq = getAgentViewQuality(); switch( va ) { case VA_NARROW: dViewWidthFactor = 0.5; break; case VA_NORMAL: dViewWidthFactor = 1.0; break; case VA_WIDE: dViewWidthFactor = 2.0; break; case VA_ILLEGAL: default: dViewWidthFactor = 0.0; break; } switch( vq ) { case VQ_LOW: dViewQualityFactor = 0.5; break; case VQ_HIGH: dViewQualityFactor = 1.0; break; case VQ_ILLEGAL: default: dViewQualityFactor = 0.0; break; } return dViewQualityFactor*dViewWidthFactor;}/*! This method returns the global position of the ball. The method getConfidence with as argument OBJECT_BALL should be called to check the confidence of this global position. \return global position bal. */VecPosition WorldModel::getBallPos(){ return getGlobalPosition( OBJECT_BALL );}/*! This method returns the current estimate of the speed of the ball. \return speed of the ball (magnitude of the global velocity vector). */double WorldModel::getBallSpeed(){ return Ball.getGlobalVelocity().getMagnitude();}/*! This method returns the global direction of the ball velocity. \return global direction of the ball velocity */AngDeg WorldModel::getBallDirection(){ return Ball.getGlobalVelocity().getDirection();}/*! This method returns the time of the global position of the specified object. \param ObjectT that represent the type of the object to check \return time corresponding to the global position of 'o' */Time WorldModel::getTimeGlobalPosition( ObjectT o ){ PlayerObject *object = (PlayerObject*) getObjectPtrFromType( o ); if( object != NULL ) return object->getTimeGlobalPosition(); return UnknownTime;}/*! This method returns the global position of an objectType. This method is normally used for the objects on the field (player, opponents and the ball). When the global position cannot be determined, a VecPosition with both the x and y coordinate are set to 'UnknownDoubleValue'. \param ObjectT that represent the type of the object to check \return VecPosition containing the global position. */VecPosition WorldModel::getGlobalPosition( ObjectT o ){ Object *object = getObjectPtrFromType( o ); if( object != NULL ) { if( SoccerTypes::isFlag( o ) || SoccerTypes::isGoal( o ) ) return SoccerTypes::getGlobalPositionFlag(o,getSide(),SS->getGoalWidth()); else return object->getGlobalPosition(); } return VecPosition( UnknownDoubleValue, UnknownDoubleValue);}/*! This method returns the time of the global velocity of the specified object. \param ObjectT that represent the type of the object to check \return time corresponding to the global velocity of 'o' */Time WorldModel::getTimeGlobalVelocity( ObjectT o ){ PlayerObject *object = (PlayerObject*) getObjectPtrFromType( o ); if( object != NULL ) return object->getTimeGlobalVelocity(); return UnknownTime;}/*! This method returns the global velocity of an objectType. When the global position cannot be determined, a VecPosition is returned with both the x and y coordinate set to 'UnknownDoubleValue'.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -