Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IceRandom.h File Reference

Go to the source code of this file.

Classes

class  BasicRandom
 

Functions

ICECORE_API void SRand (udword seed)
 
udword Rand ()
 
inline_ float UnitRandomFloat ()
 Returns a unit random floating-point value. More...
 
ICECORE_API udword GetRandomIndex (udword max_index)
 Returns a random index so that 0<= index < max_index. More...
 

Detailed Description

Contains code for random generators.

Author
Pierre Terdiman
Date
August, 9, 2001

Definition in file IceRandom.h.

Function Documentation

ICECORE_API udword GetRandomIndex ( udword  max_index)

Returns a random index so that 0<= index < max_index.

Definition at line 30 of file IceRandom.cpp.

References gRandomGenerator, and BasicRandom::Randomize().

31 {
32  // We don't use rand() since it's limited to RAND_MAX
34  return Index % max_index;
35 }
udword Rand ( )

Definition at line 22 of file IceRandom.cpp.

Referenced by UnitRandomFloat().

23 {
24  return rand();
25 }
ICECORE_API void SRand ( udword  seed)

Definition at line 17 of file IceRandom.cpp.

18 {
19  srand(seed);
20 }
inline_ float UnitRandomFloat ( )

Returns a unit random floating-point value.

Definition at line 19 of file IceRandom.h.

References float, ONE_OVER_RAND_MAX, and Rand().

19 { return float(Rand()) * ONE_OVER_RAND_MAX; }