src/core/random_func.hpp
author skidd13
Wed, 21 Nov 2007 19:13:38 +0000
changeset 7935 c2d1b2f4ecd6
child 7936 3df083e704f2
permissions -rw-r--r--
(svn r11488) -Codechange: Spilt the random functions out to seperate file
-Codechange: Make the mersenne twister more readable
-Codechange: Unify the seeding process of random
7935
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
     1
/* $Id$ */
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
     2
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
     3
/** @file random_func.h */
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
     4
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
     5
#ifndef RANDOM_FUNC_HPP
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
     6
#define RANDOM_FUNC_HPP
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
     7
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
     8
/**************
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
     9
 * Warning: DO NOT enable this unless you understand what it does
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    10
 *
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    11
 * If enabled, in a network game all randoms will be dumped to the
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    12
 *  stdout if the first client joins (or if you are a client). This
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    13
 *  is to help finding desync problems.
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    14
 *
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    15
 * Warning: DO NOT enable this unless you understand what it does
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    16
 **************/
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    17
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    18
//#define RANDOM_DEBUG
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    19
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    20
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    21
// Enable this to produce higher quality random numbers.
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    22
// Doesn't work with network yet.
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    23
// #define MERSENNE_TWISTER
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    24
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    25
void SetRandomSeed(uint32 seed);
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    26
#ifdef RANDOM_DEBUG
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    27
	#define Random() DoRandom(__LINE__, __FILE__)
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    28
	uint32 DoRandom(int line, const char *file);
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    29
	#define RandomRange(max) DoRandomRange(max, __LINE__, __FILE__)
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    30
	uint DoRandomRange(uint max, int line, const char *file);
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    31
#else
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    32
	uint32 Random();
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    33
	uint RandomRange(uint max);
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    34
#endif
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    35
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    36
uint32 InteractiveRandom(); // Used for random sequences that are not the same on the other end of the multiplayer link
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    37
uint InteractiveRandomRange(uint max);
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    38
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    39
#endif /* RANDOM_FUNC_HPP */
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    40
/* $Id$ */
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    41
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    42
/** @file random_func.h */
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    43
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    44
#ifndef RANDOM_FUNC_HPP
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    45
#define RANDOM_FUNC_HPP
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    46
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    47
/**************
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    48
 * Warning: DO NOT enable this unless you understand what it does
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    49
 *
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    50
 * If enabled, in a network game all randoms will be dumped to the
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    51
 *  stdout if the first client joins (or if you are a client). This
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    52
 *  is to help finding desync problems.
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    53
 *
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    54
 * Warning: DO NOT enable this unless you understand what it does
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    55
 **************/
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    56
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    57
//#define RANDOM_DEBUG
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    58
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    59
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    60
// Enable this to produce higher quality random numbers.
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    61
// Doesn't work with network yet.
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    62
// #define MERSENNE_TWISTER
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    63
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    64
void SetRandomSeed(uint32 seed);
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    65
#ifdef RANDOM_DEBUG
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    66
	#define Random() DoRandom(__LINE__, __FILE__)
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    67
	uint32 DoRandom(int line, const char *file);
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    68
	#define RandomRange(max) DoRandomRange(max, __LINE__, __FILE__)
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    69
	uint DoRandomRange(uint max, int line, const char *file);
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    70
#else
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    71
	uint32 Random();
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    72
	uint RandomRange(uint max);
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    73
#endif
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    74
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    75
uint32 InteractiveRandom(); // Used for random sequences that are not the same on the other end of the multiplayer link
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    76
uint InteractiveRandomRange(uint max);
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    77
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    78
#endif /* RANDOM_FUNC_HPP */
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    79
/* $Id$ */
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    80
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    81
/** @file random_func.h */
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    82
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    83
#ifndef RANDOM_FUNC_HPP
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    84
#define RANDOM_FUNC_HPP
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    85
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    86
/**************
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    87
 * Warning: DO NOT enable this unless you understand what it does
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    88
 *
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    89
 * If enabled, in a network game all randoms will be dumped to the
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    90
 *  stdout if the first client joins (or if you are a client). This
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    91
 *  is to help finding desync problems.
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    92
 *
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    93
 * Warning: DO NOT enable this unless you understand what it does
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    94
 **************/
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    95
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    96
//#define RANDOM_DEBUG
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    97
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    98
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    99
// Enable this to produce higher quality random numbers.
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   100
// Doesn't work with network yet.
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   101
// #define MERSENNE_TWISTER
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   102
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   103
void SetRandomSeed(uint32 seed);
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   104
#ifdef RANDOM_DEBUG
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   105
	#define Random() DoRandom(__LINE__, __FILE__)
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   106
	uint32 DoRandom(int line, const char *file);
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   107
	#define RandomRange(max) DoRandomRange(max, __LINE__, __FILE__)
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   108
	uint DoRandomRange(uint max, int line, const char *file);
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   109
#else
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   110
	uint32 Random();
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   111
	uint RandomRange(uint max);
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   112
#endif
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   113
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   114
uint32 InteractiveRandom(); // Used for random sequences that are not the same on the other end of the multiplayer link
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   115
uint InteractiveRandomRange(uint max);
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   116
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   117
#endif /* RANDOM_FUNC_HPP */
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   118
/* $Id$ */
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   119
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   120
/** @file random_func.h */
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   121
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   122
#ifndef RANDOM_FUNC_HPP
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   123
#define RANDOM_FUNC_HPP
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   124
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   125
/**************
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   126
 * Warning: DO NOT enable this unless you understand what it does
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   127
 *
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   128
 * If enabled, in a network game all randoms will be dumped to the
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   129
 *  stdout if the first client joins (or if you are a client). This
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   130
 *  is to help finding desync problems.
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   131
 *
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   132
 * Warning: DO NOT enable this unless you understand what it does
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   133
 **************/
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   134
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   135
//#define RANDOM_DEBUG
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   136
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   137
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   138
// Enable this to produce higher quality random numbers.
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   139
// Doesn't work with network yet.
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   140
// #define MERSENNE_TWISTER
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   141
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   142
void SetRandomSeed(uint32 seed);
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   143
#ifdef RANDOM_DEBUG
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   144
	#define Random() DoRandom(__LINE__, __FILE__)
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   145
	uint32 DoRandom(int line, const char *file);
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   146
	#define RandomRange(max) DoRandomRange(max, __LINE__, __FILE__)
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   147
	uint DoRandomRange(uint max, int line, const char *file);
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   148
#else
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   149
	uint32 Random();
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   150
	uint RandomRange(uint max);
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   151
#endif
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   152
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   153
uint32 InteractiveRandom(); // Used for random sequences that are not the same on the other end of the multiplayer link
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   154
uint InteractiveRandomRange(uint max);
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   155
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   156
#endif /* RANDOM_FUNC_HPP */
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   157
/* $Id$ */
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   158
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   159
/** @file random_func.h */
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   160
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   161
#ifndef RANDOM_FUNC_HPP
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   162
#define RANDOM_FUNC_HPP
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   163
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   164
/**************
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   165
 * Warning: DO NOT enable this unless you understand what it does
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   166
 *
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   167
 * If enabled, in a network game all randoms will be dumped to the
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   168
 *  stdout if the first client joins (or if you are a client). This
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   169
 *  is to help finding desync problems.
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   170
 *
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   171
 * Warning: DO NOT enable this unless you understand what it does
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   172
 **************/
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   173
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   174
//#define RANDOM_DEBUG
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   175
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   176
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   177
// Enable this to produce higher quality random numbers.
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   178
// Doesn't work with network yet.
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   179
// #define MERSENNE_TWISTER
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   180
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   181
void SetRandomSeed(uint32 seed);
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   182
#ifdef RANDOM_DEBUG
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   183
	#define Random() DoRandom(__LINE__, __FILE__)
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   184
	uint32 DoRandom(int line, const char *file);
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   185
	#define RandomRange(max) DoRandomRange(max, __LINE__, __FILE__)
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   186
	uint DoRandomRange(uint max, int line, const char *file);
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   187
#else
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   188
	uint32 Random();
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   189
	uint RandomRange(uint max);
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   190
#endif
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   191
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   192
uint32 InteractiveRandom(); // Used for random sequences that are not the same on the other end of the multiplayer link
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   193
uint InteractiveRandomRange(uint max);
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   194
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   195
#endif /* RANDOM_FUNC_HPP */
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   196
/* $Id$ */
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   197
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   198
/** @file random_func.h */
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   199
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   200
#ifndef RANDOM_FUNC_HPP
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   201
#define RANDOM_FUNC_HPP
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   202
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   203
/**************
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   204
 * Warning: DO NOT enable this unless you understand what it does
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   205
 *
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   206
 * If enabled, in a network game all randoms will be dumped to the
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   207
 *  stdout if the first client joins (or if you are a client). This
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   208
 *  is to help finding desync problems.
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   209
 *
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   210
 * Warning: DO NOT enable this unless you understand what it does
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   211
 **************/
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   212
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   213
//#define RANDOM_DEBUG
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   214
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   215
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   216
// Enable this to produce higher quality random numbers.
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   217
// Doesn't work with network yet.
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   218
// #define MERSENNE_TWISTER
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   219
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   220
void SetRandomSeed(uint32 seed);
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   221
#ifdef RANDOM_DEBUG
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   222
	#define Random() DoRandom(__LINE__, __FILE__)
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   223
	uint32 DoRandom(int line, const char *file);
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   224
	#define RandomRange(max) DoRandomRange(max, __LINE__, __FILE__)
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   225
	uint DoRandomRange(uint max, int line, const char *file);
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   226
#else
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   227
	uint32 Random();
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   228
	uint RandomRange(uint max);
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   229
#endif
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   230
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   231
uint32 InteractiveRandom(); // Used for random sequences that are not the same on the other end of the multiplayer link
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   232
uint InteractiveRandomRange(uint max);
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   233
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   234
#endif /* RANDOM_FUNC_HPP */