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

📄 field.h

📁 在LINUX下运行的仿真机器人服务器源代码
💻 H
📖 第 1 页 / 共 2 页
字号:
// -*-c++-*-/* *Header: *File: field.h (for C++) *Author: Noda Itsuki *Date: 1996/02/16 *EndHeader: *//* *Copyright:    Copyright (C) 1996-2000 Electrotechnical Laboratory.     	Itsuki Noda, Yasuo Kuniyoshi and Hitoshi Matsubara.    Copyright (C) 2000, 2001 RoboCup Soccer Server Maintainance Group.    	Patrick Riley, Tom Howard, Daniel Polani, Itsuki Noda,	Mikhail Prokopenko, Jan Wendler     This file is a part of SoccerServer.    This code is free software; you can redistribute it and/or    modify it under the terms of the GNU Lesser General Public    License as published by the Free Software Foundation; either    version 2.1 of the License, or (at your option) any later version.    This library is distributed in the hope that it will be useful,    but WITHOUT ANY WARRANTY; without even the implied warranty of    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU    Lesser General Public License for more details.    You should have received a copy of the GNU Lesser General Public    License along with this library; if not, write to the Free Software    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA *EndCopyright: */#ifndef _FIELD_H_#define _FIELD_H_#include <cstdio>#include <sys/time.h>#include <deque>#include <fstream>#include <vector>#include <rcssbase/gz/gzfstream.hpp>#include "object.h"#include "resultsaver.hpp"class HetroPlayer;class ServerParamSensor_v8;class ServerParamSensor_v7;class PlayerParamSensor_v8;class PlayerParamSensor_v7;class LandmarkReader;class RemoteClient;#include <algorithm>#include "audio.h"#include "timeable.h"#include <memory>class Monitor;class Player;class Coach;class OnlineCoach;class Referee;namespace rcss{  namespace clang  {    class Msg;  }}extern void write_log(Stadium& stad, Player& p, const char *message, int flag); extern void write_log(Stadium& stad, Coach& p, const char *message, int flag); extern void write_log(Stadium& stad, OnlineCoach& p, const char *message, int flag); /* *=================================================================== *Part: Stadium Class *=================================================================== */class Coach  : public RemoteClient,    public ServerParamSensor_v8,    public PlayerParamSensor_v8,    public PlayerTypeSensor_v8,    public rcss::Listener,    public rcss::InitObserver< rcss::InitSenderOfflineCoach >{protected:  char M_buffer[ MaxMesg ]; public:	Logical	assignedp ;	Stadium *stadium ;	int 	eye ;	int	hear ;        Value version;	int side ;	int done_received; //pfr:SYNCH	Coach(Stadium *stad) { stadium = stad; assignedp = False ; 			      hear = FALSE ; version = 0.0; side = NEUTRAL; } ;	int parse_init ( Stadium& stad, char *command,                      const rcss::net::Addr& addr );	virtual   void parse_command ( const char *command );  	void look(Stadium& stad) ;        void team_names(Stadium& stad) ;        void recover(Stadium& stad) ;	void send_visual_info(void) ;	void check_ball(Stadium& stad) ;  virtual void send ( const char* msg );  virtual  void  parseMsg( const char* msg, const size_t& len )  {    char* str = (char*)msg;    if( str[ len - 1 ] != 0 )      {        if( version >= 8.0 )          send( "(warning message_not_null_terminated)" );        str[ len ] = 0;      }    write_log( *stadium, *this, str, RECV );    parse_command( str );  }	  void  disable();  void send ( const ServerParamSensor_v7::data_t& data );  void send ( const ServerParamSensor_v8::data_t& data );    void send ( const PlayerParamSensor_v7::data_t& data );  void send ( const PlayerParamSensor_v8::data_t& data );    void send ( const PlayerTypeSensor_v7::data_t& data );  void send ( const PlayerTypeSensor_v8::data_t& data );} ;class XPMHolder;class OnlineCoach    :	public Coach,        public rcss::InitObserver< rcss::InitSenderOnlineCoach >{public:	Angle angle ;	OnlineCoach(Stadium *stad);	~OnlineCoach();  void   disable();    virtual   void parse_command( const char *command );	void say(char *message, bool standard = false) ;  void say( const rcss::clang::Msg& message );	/* this deques and says any messages which should come out	   returns the number of messages se nt out */	int  check_message_queue(TheNumber time);		int freeform_messages_said;	int freeform_messages_allowed;	char message_buf[MaxMesg];	std::deque< rcss::clang::Msg* > message_queue;	int define_messages_left;	int advice_messages_left;	int info_messages_left;	int meta_messages_left;	int del_messages_left;	int rule_messages_left;	TheNumber msg_left_update_time;	//returns whether it updated anything	bool update_messages_left(TheNumber time);	virtual void send ( const char* msg )	  {	    int len = strlen ( msg ) + 1;	    if ( RemoteClient::send ( msg, len ) != len )	      {              std::cerr << __FILE__ << ": " << __LINE__ << ": ";              perror ( "Error sending to offline coach" );	      }        else        {            write_log ( *stadium, *this, msg, SEND );        }	  }    void sendPlayerClangVer();  void sendPlayerClangVer( const Player& player );  virtual  void  parseMsg( const char* msg, const size_t& len )  {    char* str = (char*)msg;    if( str[ len - 1 ] != 0 )      {        if( version >= 8.0 )          send( "(warning message_not_null_terminated)" );        str[ len ] = 0;      }    write_log( *stadium, *this, str, RECV );    parse_command( str );  }private:  const rcss::SerializerOnlineCoach* M_serializer;    std::string m_coach_name;public:  const rcss::SerializerOnlineCoach&  setSerializer( const rcss::SerializerOnlineCoach& ser )  { return *(M_serializer = &ser); }  const rcss::SerializerOnlineCoach&  getSerializer() const  { return *M_serializer; }    void    setName( const string& name )    { m_coach_name = name; }    const std::string&    getName() const    { return m_coach_name; }} ;class Field { public:  PObject	goal_l ;  PObject	goal_r ;  PObject	line_l ;  PObject	line_r ;  PObject	line_t ;  PObject	line_b ;  Field ()    : goal_l ( PObject::OT_GOAL ),      goal_r ( PObject::OT_GOAL ),      line_l ( PObject::OT_LINE ),      line_r ( PObject::OT_LINE ),      line_t ( PObject::OT_LINE ),      line_b ( PObject::OT_LINE )  {}  ~Field () {}	void assign(Stadium *stad) ;} ;class Weather { public:	PVector	wind_vector ;	Value	wind_rand ;	void	init(Stadium *stad) ;} ;class Stadium : public virtual Timeable{public:  // These are vectors and not lists, because we need to shuffle them  typedef std::vector< OnlineCoach* > OnlineCoachCont;  typedef std::vector< Player* >  PlayerCont;  typedef std::vector< Monitor* > MonitorCont;  typedef std::vector< Coach* >  OfflineCoachCont;  typedef std::vector< rcss::Listener* > ListenerCont;  // definitions of different timeable methods     void doRecvFromClients( );  void doNewSimulatorStep();  void doSendSenseBody();  void doSendVisuals();  void doSendCoachMessages();  bool doSendThink();  void doQuit();	protected:  rcss::net::UDPSocket M_player_socket;  rcss::net::UDPSocket M_online_coach_socket;  rcss::net::UDPSocket M_offline_coach_socket;		  OnlineCoachCont M_remote_online_coaches;  PlayerCont  M_remote_players;  MonitorCont M_monitors;  OfflineCoachCont M_remote_offline_coaches;  ListenerCont M_listeners;public:  OnlineCoachCont&  onlineCoaches()  { return  M_remote_online_coaches; }  PlayerCont&  players()  { return M_remote_players; }  MonitorCont&  monitors()  { return M_monitors; }  OfflineCoachCont&  offlineCoaches()  { return  M_remote_offline_coaches; }  ListenerCont&  listeners()  { return  M_listeners; }    void    removeListener( const rcss::Listener* listener )    {        M_listeners.erase( remove( M_listeners.begin(),                                    M_listeners.end(),                                    listener ),                           M_listeners.end() );    }    void     addListener( rcss::Listener* listener )    { M_listeners.push_back( listener ); }  void  addOfflineCoach( Coach* coach )  { M_remote_offline_coaches.push_back( coach ); }  static const std::string DEF_TEXT_NAME;  static const std::string DEF_TEXT_SUFFIX;  static const std::string DEF_GAME_NAME;  static const std::string DEF_GAME_SUFFIX;  static const std::string DEF_KAWAY_NAME;  static const std::string DEF_KAWAY_SUFFIX;	Field	field ;	Weather	weather ;	dispinfo_t dinfo ;	dispinfo_t minfo ;  //	displist_t top ;	dispinfo_t2 dinfo2;		MPObjectTable motable ;	/* Movable objects */	PObjectTable votable ;	/* Visible objects */	MPObject *ball ;	PVector prev_ball_pos ;	PVector offside_pos ;	Player **player ;//	TheNumber n_player ;	TheNumber dest[MAX_PLAYER*2] ;	Team *team_l ;	Team *team_r ;	TheNumber time ;	TheNumber after_g_time ;	TheNumber after_offside_time ;  TheNumber drop_ball_time;	TheNumber after_back_pass_time ;  TheNumber M_after_free_kick_fault_time ;  TheNumber m_after_catch_fault_time ;  //	Player *last_touch ;	Player *last_kicker ;        // should be moved to GoalRef    bool m_indirect;	Side kick_off_side ;	PlayMode mode ;	TheNumber startp ;	/* flag for physical simulator */		HetroPlayer **player_types; 		LandmarkReader *landmark_reader;  rcss::gz::gzfstream gz_text_log;  rcss::gz::gzfstream gz_game_log;  std::ofstream text_log ; /* file for command log */  std::ofstream game_log ;   /* file for recording the game */

⌨️ 快捷键说明

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