/*
 * Random.cpp
 *
 *  Created on: Dec 31, 2010
 *      Author: cpresser
 */

#include "Random.h"

#include <cstdlib>
#include <ctime>

Random::Random() {
        srand(time(0));
}

Random::Random(unsigned int seed) {
        srand(seed);
}

Random::~Random(){

}

int Random::maxInt(){
        return RAND_MAX;
}

//pseudorandom number between 0 and RAND_MAX)
int Random::nextInt(){
        return rand();
}

//pseudorandom number between 0 and max-1
int Random::nextInt(int max){
        return rand() % max;
}

//pseudorandom number between min and max-1
int Random::nextInt(int min, int max){
        int range = max-min;
        //value between 0 and range-1
        int n = nextInt(range);

        return min + n;
}

//pseudorandom number between 0.0 (inclusive) and 1.0 (exclusive)
float Random::nextFloat(){
        int n = nextInt();
        return n / (float)RAND_MAX;
}

//pseudorandom number between 0.0 (inclusive) and 1.0 (exclusive)
double Random::nextDouble(){
        int n = nextInt();
        return n / (double)RAND_MAX;

}