/****************************************************************************************


	MCRandom.h

	Copyright: (c) 2001 Eovia Corp. All rights reserved.

	Author:		Ray Dream 
	Date:		3/2/98

	Revision History

  	when		who			what & why
	==========	==========	======================================================
	7/21/99		cph			Fixed bug in RealRand()
	10/16/98	Nba			Added Rand for real32
	10/07/98	Nba			Added MCRandomStep, TMCRandom
	3/5/98		Greg		Initial conversion

*****************************************************************************************/

#ifndef __MCRANDOM__
#define __MCRANDOM__

#include "MCBasicTypes.h"
#include "MCBasicDefines.h"


int32	MCRandomStep	(int32 before);
int32 	MCRandom		();
void 	MCSetRandomSeed	(int32 seed);
void	MCCleanRandom	();

/// \addtogroup MCCore
/// \{

/// Random Number Generator
///
class TMCRandom
{
	int32 fSeed;
public:
	TMCRandom			() : fSeed(0)		 {}
	TMCRandom			(int32 seed)
	{
		SetSeed(seed);
	}

	void  SetSeed		(int32 seed) {fSeed = seed;}
	int32 GetSeed		() const	 { return fSeed; }
	int32 Rand			()
	{
		fSeed = MCRandomStep(fSeed);
		return fSeed;
	}
	real32 RealRand		()
	{ 
		return real32(uint32(Rand())) / (real32) kUINT32_MAX;	// there must be somthing better than that
	}

	/// Returns a nicely distributed random number between 0 and 1.
	///
	real FloatAbs()
	{
		int32 intValue = (Rand() & 0x7fffff);
		return real(intValue) / 0x7fffff;
	}
};
/// \}

#endif