Panda3D
 All Classes Functions Variables Enumerations
randomizer.h
1 // Filename: randomizer.h
2 // Created by: drose (18Jan07)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef RANDOMIZER_H
16 #define RANDOMIZER_H
17 
18 #include "pandabase.h"
19 #include "mersenne.h"
20 
21 #include <time.h>
22 #include <math.h>
23 
24 ////////////////////////////////////////////////////////////////////
25 // Class : Randomizer
26 // Description : A handy class to return random numbers.
27 ////////////////////////////////////////////////////////////////////
28 class EXPCL_PANDA_MATHUTIL Randomizer {
29 PUBLISHED:
30  INLINE Randomizer(unsigned long seed = 0);
31  INLINE Randomizer(const Randomizer &copy);
32  INLINE void operator = (const Randomizer &copy);
33 
34  INLINE int random_int(int range);
35  INLINE double random_real(double range);
36  INLINE double random_real_unit();
37 
38  INLINE static unsigned long get_next_seed();
39  INLINE unsigned long get_seed();
40 
41 private:
42  Mersenne _mersenne;
43  static Mersenne _next_seed;
44  static bool _got_first_seed;
45 };
46 
47 #include "randomizer.I"
48 
49 #endif
A handy class to return random numbers.
Definition: randomizer.h:28