1 
2 /* "Species" - a CoreWars evolver.  Copyright (C) 2003 'Varfar'
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the Free
6  * Software Foundation; either version 1, or (at your option) any later
7  * version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 675 Mass Ave, Cambridge, MA 02139, USA.
17  */
18 
19 #include "rand.hpp"
20 
21 #include "randomc.h" // random number generator(s)
22 #include <time.h>
23 
24 namespace { // anon
25 
26 	TRandomMersenne rnd(time(0));
27 
28 } // anon namespace
29 
30 /**** CRand class implementation ********************/
31 
32 /* random generators return a (0 >= value < max) */
33 
frand(const float max)34 float CRand::frand(const float max) {
35 	return rnd.Random() * max;
36 }
37 
irand(const int max)38 int CRand::irand(const int max) {
39 	return rnd.IRandom(0,max-1);
40 }
41