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

📄 random.h

📁 在LINUX下运行的仿真机器人服务器源代码
💻 H
字号:
// -*-c++-*-/***************************************************************************                                  random.h                            Random Number Generator                             -------------------    begin                : 17-JAN-2002    copyright            : (C) 2002 by The RoboCup Soccer Server                            Maintainance Group.    email                : sserver-admin@lists.sourceforge.net ***************************************************************************//*************************************************************************** *                                                                         * *   This program is free software; you can redistribute it and/or modify  * *   it under the terms of the GNU LGPL as published by the Free Software  * *   Foundation; either version 2 of the License, or (at your option) any  * *   later version.                                                        * *                                                                         * ***************************************************************************/#ifndef _RCSS_RANDOM_H_#define _RCSS_RANDOM_H_#include <boost/random.hpp>#include <cstdlib>#include <sys/time.h>#include <memory>// old random code#define RANDOMBASE		1000#define IRANDOMBASE		31#define drand(h,l)	(((((h)-(l)) * ((double)(random()%RANDOMBASE) / (double)RANDOMBASE))) + (l))#define	irand(x)	((random() / IRANDOMBASE) % (x))#include <boost/random.hpp>namespace rcss {  namespace random   {      class DefaultRNG          : public boost::mt19937      {      public:          static          DefaultRNG&          instance ()          { static DefaultRNG the_instance; return the_instance; }                    static          DefaultRNG&#if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x520)          // Work around overload resolution problem (Gennadiy E. Rozental)          instance( const boost::mt19937::result_type& value )#else          instance( boost::mt19937::result_type value )#endif          { instance().seed( value ); return instance(); }          // For GCC, moving this function out-of-line prevents inlining, which may          // reduce overall object code size.  However, MSVC does not grok          // out-of-line definitions of member function templates.          template<class Generator>          static          DefaultRNG&          instance( Generator& gen )          { instance().seed( gen ); return instance(); }      private:          DefaultRNG()              : boost::mt19937()          {}      };       class UniformRNG          : public boost::random_number_generator< rcss::random::DefaultRNG >      {      public:          static          UniformRNG&          instance ()          { static UniformRNG the_instance; return the_instance; }                 private:          UniformRNG()              : boost::random_number_generator< rcss::random::DefaultRNG >( DefaultRNG::instance() )          {}      };    } // namespace random} // namespace rcss#endif // _RCSS_RANDOM_H_

⌨️ 快捷键说明

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