a3e68a4b529c86a481b3a1aa47d6094d3f013d57
[tagua/yd.git] / src / random.h
bloba3e68a4b529c86a481b3a1aa47d6094d3f013d57
1 /*
2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@gmail.com>
3 (c) 2006 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9 */
11 #ifndef RANDOM_H
12 #define RANDOM_H
14 #include <boost/random/mersenne_twister.hpp>
15 #include <boost/random/variate_generator.hpp>
16 #include <boost/random/uniform_smallint.hpp>
17 #include <boost/random/uniform_real.hpp>
19 class Random {
20 public:
21 typedef boost::mt19937 RandomGenerator;
22 typedef boost::uniform_smallint<> IntegerDistribution;
23 typedef boost::uniform_real<float> RealDistribution;
24 typedef boost::variate_generator<RandomGenerator*, IntegerDistribution> IntegerGenerator;
25 typedef boost::variate_generator<RandomGenerator*, RealDistribution> RealGenerator;
26 private:
27 RandomGenerator m_generator;
29 Random(); // singleton
30 static Random* m_instance;
31 public:
32 IntegerGenerator rand(int min, int max);
33 RealGenerator rand(float min, float max);
34 RealGenerator rand(double min, double max);
36 static Random& instance();
39 #endif // RANDOM_H