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

📄 worldmodel.h

📁 机器足球2D比赛程序 对trlen_base_2002的改进
💻 H
📖 第 1 页 / 共 3 页
字号:
/*   Copyright (c) 2000-2002, Jelle Kok, University of Amsterdam   All rights reserved.   Redistribution and use in source and binary forms, with or without    modification, are permitted provided that the following conditions are met:   1. Redistributions of source code must retain the above copyright notice, this    list of conditions and the following disclaimer.    2. Redistributions in binary form must reproduce the above copyright notice,    this list of conditions and the following disclaimer in the documentation    and/or other materials provided with the distribution.    3. Neither the name of the University of Amsterdam nor the names of its    contributors may be used to endorse or promote products derived from this    software without specific prior written permission.    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.   *//*! \file WorldModel.h  <pre>  <b>File:</b>          WorldModel.h  <b>Project:</b>       Robocup Soccer Simulation Team: UvA Trilearn  <b>Authors:</b>       Jelle Kok  <b>Created:</b>       12/02/2001  <b>Last Revision:</b> $ID$  <b>Contents:</b>      class declarations of WorldModel. This class contains  methods that give information about the current and future  state of the world (soccer field).  <hr size=2>  <h2><b>Changes</b></h2>  <b>Date</b>             <b>Author</b>          <b>Comment</b>  12/02/2001       Jelle Kok       Initial version created  </pre>  */#ifndef _WORLD_MODEL_#define _WORLD_MODEL_#include "Objects.h"        // needed for PlayerObject#include "PlayerSettings.h" // needed for getPlayerDistTolerance#include "Logger.h"         // needed for Log#include "Formations.h"     // needed for getStrategicPosition (prediction)#include <pthread.h>        // needed for pthread_mutexextern Logger Log;          // defined in Logger.C/*****************************************************************************//********************** CLASS WORLDMODEL *************************************//*****************************************************************************//*! The Class WorlModel contains all the RoboCup information that is available  on the field. It contains information about the players, ball, flags and  lines. Furthermore it contains methods to extract useful information.  The (large amount of) attributes can be separated into different groups:  - Environmental information: specific information about the soccer server  - Match information: general information about the current state of a match  - Object information: all the objects on the soccer field  - Action information: actions that the agent has performed  The methods can also be divided into different groups:  - Retrieval methods: directly retrieving information of objects  - Update methods: update world based on new sensory information  - Prediction methods: predict future states based on past perceptions  - High-Level methods: deriving high-level conclusions from basic world state  */class WorldModel{	private:		/****************************************************************************/		/*************************** ATTRIBUTES *************************************/		/****************************************************************************/		////////////////////////// ENVIRONMENTAL INFORMATION /////////////////////////		ServerSettings *SS;                     /*!< Reference to all server params */		PlayerSettings *PS;                     /*!< Reference to all client params */		HeteroPlayerSettings pt[MAX_HETERO_PLAYERS]; /*!< info hetero player types  */		Formations     *formations;             /*!< Reference to formation used    */		////////////////////////// CURRENT MATCH INFORMATION /////////////////////////		// time information		Time          timeLastSeeMessage;      /*!< server time of last see msg     */		Time          timeLastSenseMessage;    /*!< server time of last sense msg   */		bool          bNewInfo;                /*!< indicates new info from server  */		Time          timeLastCatch;           /*!< time of last catch by goalie    */		Time          timeLastRefMessage;      /*!< time of last referee message    */		// player information		char          strTeamName[MAX_TEAM_NAME_LENGTH]; /*!< Team name             */		int           iPlayerNumber;           /*!< player number in soccerserver   */		SideT         sideSide;                /*!< side where the agent started    */		// match information		PlayModeT     playMode;                /*!< current play mode in the game   */		int           iGoalDiff;               /*!< goal difference                 */		////////////////////////// OBJECTS ///////////////////////////////////////////		// dynamic objects		BallObject    Ball;                    /*!< information of the ball         */		AgentObject   agentObject;             /*!< information of the agent itself */		PlayerObject  Teammates[MAX_TEAMMATES];/*!< information of all teammates    */		PlayerObject  Opponents[MAX_OPPONENTS];/*!< information of all opponents    */		PlayerObject  UnknownPlayers[MAX_TEAMMATES+MAX_OPPONENTS];		/*!< info unknown players are stored		  here til mapped to known player */		int           iNrUnknownPlayers;       /*!< number of unknown players       */		// fixed objects		FixedObject   Flags[MAX_FLAGS];        /*!< all flag information            */		FixedObject   Lines[MAX_LINES];        /*!< all line information            */		////////////////////////// LOCALIZATION INFORMATION //////////////////////////		static const int iNrParticlesAgent = 100; /*!<nr of particles used to store							    agent position                */		static const int iNrParticlesBall  = 100; /*!<nr of particles used to store							    ball position and velocity    */		VecPosition   particlesPosAgent[iNrParticlesAgent]; /*!< particles to store								      agent position       */		VecPosition   particlesPosBall[iNrParticlesBall];   /*!< particles to store								      ball position        */		VecPosition   particlesVelBall[iNrParticlesBall];   /*!< particles to store								      ball velocity        */		////////////////////////// PREVIOUS ACTION INFORMATION ///////////////////////		// arrays needed to keep track of actually performed actions.		SoccerCommand queuedCommands[CMD_MAX_COMMANDS];   /*!< all performed commands,								    set by ActHandler     */		bool          performedCommands[CMD_MAX_COMMANDS];/*!< commands performed in								    last cycle, index is								    CommandT              */		int           iCommandCounters[CMD_MAX_COMMANDS]; /*!< counters for all								    performed commands    */		////////////////////////// VARIOUS ///////////////////////////////////////////		// attributes only applicable to the coach		Time          timeCheckBall;           /*!< time bsCheckBall applies to     */		BallStatusT   bsCheckBall;             /*!< state of the ball               */		// synchronization		pthread_mutex_t mutex_newInfo;        /*!< mutex to protect bNewInfo        */		pthread_cond_t  cond_newInfo;         /*!< cond variable for bNewInfo       */		// communication		char          m_strPlayerMsg[MAX_MSG];/*!< message communicated by player   */		int           m_iCycleInMsg;          /*!< cycle contained in message       */ 		Time          m_timePlayerMsg;        /*!< time corresponding to player msg */		int           m_iMessageSender;       /*!< player who send message          */		// other		bool          m_bWasCollision;        /*!< Indicates whether it is collision*/  		bool          m_bPerformedKick;       /*!< Indicates whether ball was kicked*/  		// side of penalty shootout		SideT         m_sidePenalty;	public:		// statistics		int           iNrHoles;                /*!< nr of holes recorded            */		int           iNrOpponentsSeen;        /*!< total nr of opponents seen      */		int           iNrTeammatesSeen;        /*!< total nr of teammates seen      */		// last received messages		char          strLastSeeMessage  [MAX_MSG];  /*!< Last see message          */		char          strLastSenseMessage[MAX_MSG];  /*!< Last sense_body message   */		char          strLastHearMessage [MAX_MSG];  /*!< Last hear message         */		/****************************************************************************/		/*************************** OPERATIONS *************************************/		/****************************************************************************/		////////////////////////// DIRECT RETRIEVAL (WorldModel.C) ///////////////////	private:		// private methods		Object*       getObjectPtrFromType       ( ObjectT        o           );	public:         		// get and set methods of attributes in WorldModel itself		void          setTimeLastCatch           ( Time           time        );		int           getTimeSinceLastCatch      (                            );		bool          setTimeLastRefereeMessage  ( Time           time        );		Time          getTimeLastRefereeMessage  (                            );		Time          getCurrentTime             (                            );		int           getCurrentCycle            (                            );		bool          isTimeStopped              (                            );		bool          isLastMessageSee           (                            ) const;		Time          getTimeLastSeeGlobalMessage(                            ) const;		bool          setTimeLastSeeGlobalMessage( Time           time        );		Time          getTimeLastSeeMessage      (                            ) const;		bool          setTimeLastSeeMessage      ( Time           time        );		Time          getTimeLastSenseMessage    (                            ) const ;		bool          setTimeLastSenseMessage    ( Time           time        );		int           getPlayerNumber            (                            ) const;		bool          setPlayerNumber            ( int            i           );		SideT         getSide                    (                            ) const;		bool          setSide                    ( SideT          s           );		const char*   getTeamName                (                            ) const;		bool          setTeamName                ( char           *str        );		PlayModeT     getPlayMode                (                            ) const;		bool          setPlayMode                ( PlayModeT      pm          );		int           getGoalDiff                (                            ) const;		int           addOneToGoalDiff           (                            );		int           subtractOneFromGoalDiff    (                            );		int           getNrOfCommands            ( CommandT       c           ) const;		bool          setNrOfCommands            ( CommandT       c,				int            i           );		Time          getTimeCheckBall           (                            ) const;		bool          setTimeCheckBall           ( Time           time        );		BallStatusT   getCheckBallStatus         (                            ) const;		bool          setCheckBallStatus         ( BallStatusT    bs          );		// iterate over a specific object set		ObjectT       iterateObjectStart         ( int            &iIndex,

⌨️ 快捷键说明

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