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

📄 worldmodel.c

📁 机器足球2D比赛程序 对trlen_base_2002的改进
💻 C
📖 第 1 页 / 共 5 页
字号:
  team has a free kick. When the specified PlayModeT equals   PM_ILLEGAL (default), the current play mode is used.  \param pm play mode to check. In default case (PM_ILLEGAL) the current play  mode is used.   \return bool indicating whether the other team has a free kick. */bool WorldModel::isFreeKickThem( PlayModeT pm ){	if( pm == PM_ILLEGAL ) 		pm = getPlayMode();	return ( pm == PM_FREE_KICK_RIGHT  && getSide() == SIDE_LEFT  ) ||		( pm == PM_FREE_KICK_LEFT   && getSide() == SIDE_RIGHT ) ;}/*! This method checks whether the play mode indicates that there is (or  will be) a before kick off situation. This is the case when the play mode  equals PM_BEFORE_KICK_OFF or either PM_GOAL_LEFT or PM_GOAL_RIGHT since   after the goal the play mode will go to PM_BEFORE_KICK_OFF.  When the specified PlayModeT equals PM_ILLEGAL (default), the   current play mode is used.  \param pm play mode to check. In default case (PM_ILLEGAL) the current play  mode is used.   \return bool indicating whether there is a before kick off situation. */bool WorldModel::isBeforeKickOff( PlayModeT pm ){	if( pm == PM_ILLEGAL ) 		pm = getPlayMode();	return pm == PM_BEFORE_KICK_OFF  || pm == PM_GOAL_LEFT  ||		pm == PM_GOAL_RIGHT ; // || isKickOffUs( pm ) || isKickOffThem( pm );}/*! This method checks whether the play mode indicates that there is  a dead ball situation and our team is allowed to perform the action.  That is our team has either a free kick, kick in, corner kick or a kick in.  When the specified PlayModeT equals PM_ILLEGAL (default), the   current play mode is used.    \param pm play mode to check. In default case (PM_ILLEGAL) the current play  mode is used.   \return bool indicating whether we have a dead ball situation. */bool WorldModel::isDeadBallUs( PlayModeT pm ){	if( pm == PM_ILLEGAL ) 		pm = getPlayMode();	return isKickInUs  ( pm ) || isFreeKickUs  ( pm ) || isCornerKickUs     ( pm ) 		|| isKickOffUs ( pm ) || isOffsideThem ( pm ) || isFreeKickFaultThem( pm )		|| isGoalKickUs( pm ) || isBackPassThem( pm ) ;}/*! This method checks whether the current play mode indicates that there is  a dead ball situation and their team is allowed to perform the action.  That is their team has either a free kick, kick in, corner kick or a kick  in. When the specified PlayModeT equals PM_ILLEGAL (default), the   current play mode is used.  \param pm play mode to check. In default case (PM_ILLEGAL) the current play  mode is used.   \return bool indicating whether they have a dead ball situation. */bool WorldModel::isDeadBallThem( PlayModeT pm ){	if( pm == PM_ILLEGAL ) 		pm = getPlayMode();	return isFreeKickThem( pm ) || isKickInThem  ( pm ) || isCornerKickThem ( pm ) 		||  isKickOffThem ( pm ) || isGoalKickThem( pm ) || isFreeKickFaultUs( pm )		|| isOffsideUs    ( pm ) || isBackPassUs  ( pm ) ; }/*! This method returns the side the penalty kick is taken. */SideT WorldModel::getSidePenalty( ){	return m_sidePenalty;}/*! This method sets the side the penalty kick is taken. */bool WorldModel::setSidePenalty( SideT side ){	m_sidePenalty = side;	return true;}/*! This method checks whether the current play mode indicates that we have  a corner kick. When the specified PlayModeT equals PM_ILLEGAL (default),   the current play mode is used.  \param pm play mode to check. In default case (PM_ILLEGAL) the current play  mode is used.   \return bool indicating whether we have a corner kick. */bool WorldModel::isCornerKickUs( PlayModeT pm ){	if( pm == PM_ILLEGAL ) 		pm = getPlayMode();	return ( pm == PM_CORNER_KICK_LEFT  && getSide() == SIDE_LEFT  ) ||		( pm == PM_CORNER_KICK_RIGHT && getSide() == SIDE_RIGHT ) ;}/*! This method checks whether the current play mode indicates that the other  team has a corner kick. When the specified PlayModeT equals PM_ILLEGAL   (default), the current play mode is used.  \param pm play mode to check. In default case (PM_ILLEGAL) the current play  mode is used.   \return bool indicating whether the other team has a corner kick. */bool WorldModel::isCornerKickThem( PlayModeT pm ){	if( pm == PM_ILLEGAL ) 		pm = getPlayMode();	return ( pm == PM_CORNER_KICK_RIGHT  && getSide() == SIDE_LEFT  ) ||		( pm == PM_CORNER_KICK_LEFT   && getSide() == SIDE_RIGHT ) ;}/*! This method checks whether the current play mode indicates that we stood  offside. When the specified PlayModeT equals PM_ILLEGAL (default), the   current play mode is used.  \param pm play mode to check. In default case (PM_ILLEGAL) the current play  mode is used.   \return bool indicating whether we stood offside. */bool WorldModel::isOffsideUs( PlayModeT pm ){	if( pm == PM_ILLEGAL ) 		pm = getPlayMode();	return ( pm == PM_OFFSIDE_RIGHT  && getSide() == SIDE_RIGHT ) ||		( pm == PM_OFFSIDE_LEFT   && getSide() == SIDE_LEFT );}/*! This method checks whether the current play mode indicates that the other  team stood offside. When the specified PlayModeT equals PM_ILLEGAL   (default), the current play mode is used.  \param pm play mode to check. In default case (PM_ILLEGAL) the current play  mode is used.   \return bool indicating whether the other team stood offside. */bool WorldModel::isOffsideThem( PlayModeT pm ){	if( pm == PM_ILLEGAL ) 		pm = getPlayMode();	return ( pm == PM_OFFSIDE_LEFT  && getSide() == SIDE_RIGHT ) ||		( pm == PM_OFFSIDE_RIGHT && getSide() == SIDE_LEFT );}/*! This method checks whether the current play mode indicates that we have  a kick in. When the specified PlayModeT equals PM_ILLEGAL (default), the   current play mode is used.  \param pm play mode to check. In default case (PM_ILLEGAL) the current play  mode is used.   \return bool indicating whether we have a kick in. */bool WorldModel::isKickInUs( PlayModeT pm ){	if( pm == PM_ILLEGAL ) 		pm = getPlayMode();	return ( pm == PM_KICK_IN_LEFT  && getSide() == SIDE_LEFT  ) ||		( pm == PM_KICK_IN_RIGHT && getSide() == SIDE_RIGHT ) ;}/*! This method checks whether the current play mode indicates that the other  team has a kick in. When the specified PlayModeT equals PM_ILLEGAL   (default), the current play mode is used.  \param pm play mode to check. In default case (PM_ILLEGAL) the current play  mode is used.   \return bool indicating whether the other team has a kick in. */bool WorldModel::isKickInThem( PlayModeT pm ){	if( pm == PM_ILLEGAL ) 		pm = getPlayMode();	return ( pm == PM_KICK_IN_RIGHT  && getSide() == SIDE_LEFT  ) ||		( pm == PM_KICK_IN_LEFT   && getSide() == SIDE_RIGHT ) ;}/*! This method checks whether the current play mode indicates that we have  made a free kick fault. This happens when a player kicks the ball twice   after a free kick or a kick in.   When the specified PlayModeT equals PM_ILLEGAL (default), the   current play mode is used.  \param pm play mode to check. In default case (PM_ILLEGAL) the current play  mode is used.   \return bool indicating whether we have made a free kick fault. */bool WorldModel::isFreeKickFaultUs( PlayModeT pm ){	if( pm == PM_ILLEGAL ) 		pm = getPlayMode();	return ( pm == PM_FREE_KICK_FAULT_LEFT  && getSide() == SIDE_LEFT  ) ||		( pm == PM_FREE_KICK_FAULT_RIGHT && getSide() == SIDE_RIGHT ) ;}/*! This method checks whether the current play mode indicates that the other  team has made a free kick fault. This happens when a player kicks the ball   twice after a free kick or a kick in.   When the specified PlayModeT equals PM_ILLEGAL (default), the   current play mode is used.  \param pm play mode to check. In default case (PM_ILLEGAL) the current play  mode is used.   \return bool indicating whether the other team has made a free kick fault.*/bool WorldModel::isFreeKickFaultThem( PlayModeT pm ){	if( pm == PM_ILLEGAL ) 		pm = getPlayMode();	return ( pm == PM_FREE_KICK_FAULT_RIGHT  && getSide() == SIDE_LEFT  ) ||		( pm == PM_FREE_KICK_FAULT_LEFT   && getSide() == SIDE_RIGHT ) ;}/*! This method checks whether the current play mode indicates that we have  a kick off. When the specified PlayModeT equals PM_ILLEGAL (default), the   current play mode is used.  \param pm play mode to check. In default case (PM_ILLEGAL) the current play  mode is used.   \return bool indicating whether we have a kick off. */bool WorldModel::isKickOffUs( PlayModeT pm ){	if( pm == PM_ILLEGAL ) 		pm = getPlayMode();	return ( pm == PM_KICK_OFF_LEFT  && getSide() == SIDE_LEFT  ) ||		( pm == PM_KICK_OFF_RIGHT && getSide() == SIDE_RIGHT ) ;}/*! This method checks whether the current play mode indicates that the other  team has a kick off. When the specified PlayModeT equals PM_ILLEGAL   (default), the current play mode is used. When the specified PlayModeT   equals PM_ILLEGAL (default), the current play mode is used.  \param pm play mode to check. In default case (PM_ILLEGAL) the current play  mode is used.   \return bool indicating whether the other team has a kick off. */bool WorldModel::isKickOffThem( PlayModeT pm ){	if( pm == PM_ILLEGAL ) 		pm = getPlayMode();	return ( pm == PM_KICK_OFF_RIGHT  && getSide() == SIDE_LEFT  ) ||		( pm == PM_KICK_OFF_LEFT   && getSide() == SIDE_RIGHT ) ;}/*! This method checks whether the current play mode indicates that we have  made a back pass (which is not allowed). This occurs when a teamamte has  passed the ball back to the goalkeeper and he catched it.  When the specified PlayModeT equals PM_ILLEGAL (default), the   current play mode is used.  \param pm play mode to check. In default case (PM_ILLEGAL) the current play  mode is used.   \return bool indicating whether we have made a back pass. */bool WorldModel::isBackPassUs( PlayModeT pm ){	if( pm == PM_ILLEGAL ) 		pm = getPlayMode();	return ( pm == PM_BACK_PASS_LEFT  && getSide() == SIDE_LEFT  ) ||		( pm == PM_BACK_PASS_RIGHT && getSide() == SIDE_RIGHT ) ;}/*! This method checks whether the current play mode indicates that the other  team has made a back pass (which is not allowed). This occurs when an  opponent has passed the ball back to the goalkeeper and he catched it.  When the specified PlayModeT equals PM_ILLEGAL (default), the   current play mode is used.  \param pm play mode to check. In default case (PM_ILLEGAL) the current play  mode is used.   \return bool indicating whether the other team has made a back pass. */bool WorldModel::isBackPassThem( PlayModeT pm ){	if( pm == PM_ILLEGAL ) 		pm = getPlayMode();	return ( pm == PM_BACK_PASS_RIGHT && getSide() == SIDE_LEFT  ) ||		( pm == PM_BACK_PASS_LEFT  && getSide() == SIDE_RIGHT ) ;}/*! This method checks whether the current play mode indicates that we have  a goal kick. When the specified PlayModeT equals PM_ILLEGAL (default), the   current play mode is used.  \param pm play mode to check. In default case (PM_ILLEGAL) the current play  mode is used.   \return bool indicating whether we have a goal kick. */bool WorldModel::isGoalKickUs( PlayModeT pm ){	if( pm == PM_ILLEGAL ) 		pm = getPlayMode();	return ( pm == PM_GOAL_KICK_LEFT  && getSide() == SIDE_LEFT  ) ||		( pm == PM_GOAL_KICK_RIGHT && getSide() == SIDE_RIGHT ) ;}/*! This method checks whether the current play mode indicates that the other  team has a kick off. When the specified PlayModeT equals PM_ILLEGAL   (default), the current play mode is used.  \param pm play mode to check. In default case (PM_ILLEGAL) the current play  mode is used.   \return bool indicating whether the other team has a kick off. */bool WorldModel::isGoalKickThem( PlayModeT pm ){	if( pm == PM_ILLEGAL ) 		pm = getPlayMode();	return ( pm == PM_GOAL_KICK_RIGHT  && getSide() == SIDE_LEFT  ) ||		( pm == PM_GOAL_KICK_LEFT   && getSide() == SIDE_RIGHT ) ;}/*! This method checks whether the current play mode indicates that we have  a penalty. When the specified PlayModeT equals PM_ILLEGAL (default), the  current play mode is used.  \param pm play mode to check. In default case (PM_ILLEGAL) the current play  mode is used.  \return bool indicating whether we have a penalty. */bool WorldModel::isPenaltyUs( PlayModeT pm ){	if( pm == PM_ILLEGAL )		pm = getPlayMode();	return ( (				( pm == PM_PENALTY_SETUP_LEFT ||				  pm == PM_PENALTY_READY_LEFT ||				  pm == PM_PENALTY_TAKEN_LEFT ) && getSide() == SIDE_LEFT  )   ||			(			 ( pm == PM_PENALTY_SETUP_RIGHT ||			   pm == PM_PENALTY_READY_RIGHT ||			   pm == PM_PENALTY_TAKEN_RIGHT ) && getSide() == SIDE_RIGHT  ) );}/*! This method checks whether the current play mode indicates that the other  team takes a penalty. When the specified PlayModeT equals PM_ILLEGAL  (default), the current play mode is used.  \param pm play mode to check. In default case (PM_ILLEGAL) the current play  mode is used.  \return bool indicating whether the other team has a penalty. */bool WorldModel::isPenaltyThem( PlayModeT pm ){	if( pm == PM_ILLEGAL )		pm = getPlayMode();	return ( (				( pm == PM_PENALTY_SETUP_LEFT ||				  pm == PM_PENALTY_READY_LEFT ||				  pm == PM_PENALTY_TAKEN_LEFT ) && getSide() == SIDE_RIGHT  )   ||			(			 ( pm == PM_PENALTY_SETUP_RIGHT ||			   pm == PM_PENALTY_READY_RIGHT ||			   pm == PM_PENALTY_TAKEN_RIGHT ) && getSide() == SIDE_LEFT  ) );}/*! This method prints all the objects and information of the agent to the  specified outputstream. Only the information of the objects that are seen  recently are printed.  \param os output stream to which output is written (default cout). */void WorldModel::show( ostream & os ){	int i;	os << "Worldmodel (" << getCurrentTime() << ")\n" <<		"========================\n";	os << "Teamname: " << getTeamName() << endl;	if( Ball.getTimeLastSeen( ).getTime() != -1 )		Ball.show();	os << "Teammates: " << endl;	for( i = 0; i < MAX_TEAMMATES ; i++ )

⌨️ 快捷键说明

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