Panda3D
|
00001 // Filename: randomizer.h 00002 // Created by: drose (18Jan07) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef RANDOMIZER_H 00016 #define RANDOMIZER_H 00017 00018 #include "pandabase.h" 00019 #include "mersenne.h" 00020 00021 #include <time.h> 00022 00023 //////////////////////////////////////////////////////////////////// 00024 // Class : Randomizer 00025 // Description : A handy class to return random numbers. 00026 //////////////////////////////////////////////////////////////////// 00027 class EXPCL_PANDA_MATHUTIL Randomizer { 00028 PUBLISHED: 00029 INLINE Randomizer(unsigned long seed = 0); 00030 INLINE Randomizer(const Randomizer ©); 00031 INLINE void operator = (const Randomizer ©); 00032 00033 INLINE int random_int(int range); 00034 INLINE double random_real(double range); 00035 INLINE double random_real_unit(); 00036 00037 INLINE static unsigned long get_next_seed(); 00038 INLINE unsigned long get_seed(); 00039 00040 private: 00041 Mersenne _mersenne; 00042 static Mersenne _next_seed; 00043 static bool _got_first_seed; 00044 }; 00045 00046 #include "randomizer.I" 00047 00048 #endif