src/core/random_func.hpp
author skidd13
Wed, 21 Nov 2007 19:13:38 +0000
changeset 8431 68fb2ccbce06
child 8432 e4bee6adc9f9
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
8431
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
     1
/* $Id$ */
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
     2
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
     3
/** @file random_func.h */
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
     4
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
     5
#ifndef RANDOM_FUNC_HPP
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
     6
#define RANDOM_FUNC_HPP
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
     7
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
     8
/**************
68fb2ccbce06 (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
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    10
 *
68fb2ccbce06 (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
68fb2ccbce06 (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
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    13
 *  is to help finding desync problems.
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    14
 *
68fb2ccbce06 (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
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    16
 **************/
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    17
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    18
//#define RANDOM_DEBUG
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    19
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    20
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    21
// Enable this to produce higher quality random numbers.
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    22
// Doesn't work with network yet.
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    23
// #define MERSENNE_TWISTER
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    24
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    25
void SetRandomSeed(uint32 seed);
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    26
#ifdef RANDOM_DEBUG
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    27
	#define Random() DoRandom(__LINE__, __FILE__)
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    28
	uint32 DoRandom(int line, const char *file);
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    29
	#define RandomRange(max) DoRandomRange(max, __LINE__, __FILE__)
68fb2ccbce06 (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);
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    31
#else
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    32
	uint32 Random();
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    33
	uint RandomRange(uint max);
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    34
#endif
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    35
68fb2ccbce06 (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
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    37
uint InteractiveRandomRange(uint max);
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    38
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    39
#endif /* RANDOM_FUNC_HPP */
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    40
/* $Id$ */
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    41
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    42
/** @file random_func.h */
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    43
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    44
#ifndef RANDOM_FUNC_HPP
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    45
#define RANDOM_FUNC_HPP
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    46
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    47
/**************
68fb2ccbce06 (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
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    49
 *
68fb2ccbce06 (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
68fb2ccbce06 (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
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    52
 *  is to help finding desync problems.
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    53
 *
68fb2ccbce06 (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
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    55
 **************/
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    56
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    57
//#define RANDOM_DEBUG
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    58
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    59
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    60
// Enable this to produce higher quality random numbers.
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    61
// Doesn't work with network yet.
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    62
// #define MERSENNE_TWISTER
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    63
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    64
void SetRandomSeed(uint32 seed);
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    65
#ifdef RANDOM_DEBUG
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    66
	#define Random() DoRandom(__LINE__, __FILE__)
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    67
	uint32 DoRandom(int line, const char *file);
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    68
	#define RandomRange(max) DoRandomRange(max, __LINE__, __FILE__)
68fb2ccbce06 (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);
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    70
#else
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    71
	uint32 Random();
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    72
	uint RandomRange(uint max);
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    73
#endif
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    74
68fb2ccbce06 (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
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    76
uint InteractiveRandomRange(uint max);
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    77
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    78
#endif /* RANDOM_FUNC_HPP */
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    79
/* $Id$ */
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    80
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    81
/** @file random_func.h */
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    82
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    83
#ifndef RANDOM_FUNC_HPP
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    84
#define RANDOM_FUNC_HPP
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    85
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    86
/**************
68fb2ccbce06 (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
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    88
 *
68fb2ccbce06 (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
68fb2ccbce06 (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
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    91
 *  is to help finding desync problems.
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    92
 *
68fb2ccbce06 (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
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    94
 **************/
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    95
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    96
//#define RANDOM_DEBUG
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    97
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    98
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    99
// Enable this to produce higher quality random numbers.
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   100
// Doesn't work with network yet.
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   101
// #define MERSENNE_TWISTER
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   102
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   103
void SetRandomSeed(uint32 seed);
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   104
#ifdef RANDOM_DEBUG
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   105
	#define Random() DoRandom(__LINE__, __FILE__)
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   106
	uint32 DoRandom(int line, const char *file);
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   107
	#define RandomRange(max) DoRandomRange(max, __LINE__, __FILE__)
68fb2ccbce06 (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);
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   109
#else
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   110
	uint32 Random();
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   111
	uint RandomRange(uint max);
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   112
#endif
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   113
68fb2ccbce06 (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
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   115
uint InteractiveRandomRange(uint max);
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   116
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   117
#endif /* RANDOM_FUNC_HPP */
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   118
/* $Id$ */
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   119
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   120
/** @file random_func.h */
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   121
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   122
#ifndef RANDOM_FUNC_HPP
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   123
#define RANDOM_FUNC_HPP
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   124
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   125
/**************
68fb2ccbce06 (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
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   127
 *
68fb2ccbce06 (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
68fb2ccbce06 (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
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   130
 *  is to help finding desync problems.
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   131
 *
68fb2ccbce06 (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
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   133
 **************/
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   134
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   135
//#define RANDOM_DEBUG
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   136
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   137
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   138
// Enable this to produce higher quality random numbers.
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   139
// Doesn't work with network yet.
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   140
// #define MERSENNE_TWISTER
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   141
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   142
void SetRandomSeed(uint32 seed);
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   143
#ifdef RANDOM_DEBUG
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   144
	#define Random() DoRandom(__LINE__, __FILE__)
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   145
	uint32 DoRandom(int line, const char *file);
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   146
	#define RandomRange(max) DoRandomRange(max, __LINE__, __FILE__)
68fb2ccbce06 (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);
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   148
#else
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   149
	uint32 Random();
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   150
	uint RandomRange(uint max);
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   151
#endif
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   152
68fb2ccbce06 (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
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   154
uint InteractiveRandomRange(uint max);
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   155
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   156
#endif /* RANDOM_FUNC_HPP */
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   157
/* $Id$ */
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   158
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   159
/** @file random_func.h */
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   160
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   161
#ifndef RANDOM_FUNC_HPP
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   162
#define RANDOM_FUNC_HPP
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   163
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   164
/**************
68fb2ccbce06 (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
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   166
 *
68fb2ccbce06 (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
68fb2ccbce06 (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
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   169
 *  is to help finding desync problems.
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   170
 *
68fb2ccbce06 (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
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   172
 **************/
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   173
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   174
//#define RANDOM_DEBUG
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   175
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   176
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   177
// Enable this to produce higher quality random numbers.
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   178
// Doesn't work with network yet.
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   179
// #define MERSENNE_TWISTER
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   180
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   181
void SetRandomSeed(uint32 seed);
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   182
#ifdef RANDOM_DEBUG
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   183
	#define Random() DoRandom(__LINE__, __FILE__)
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   184
	uint32 DoRandom(int line, const char *file);
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   185
	#define RandomRange(max) DoRandomRange(max, __LINE__, __FILE__)
68fb2ccbce06 (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);
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   187
#else
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   188
	uint32 Random();
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   189
	uint RandomRange(uint max);
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   190
#endif
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   191
68fb2ccbce06 (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
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   193
uint InteractiveRandomRange(uint max);
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   194
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   195
#endif /* RANDOM_FUNC_HPP */
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   196
/* $Id$ */
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   197
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   198
/** @file random_func.h */
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   199
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   200
#ifndef RANDOM_FUNC_HPP
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   201
#define RANDOM_FUNC_HPP
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   202
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   203
/**************
68fb2ccbce06 (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
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   205
 *
68fb2ccbce06 (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
68fb2ccbce06 (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
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   208
 *  is to help finding desync problems.
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   209
 *
68fb2ccbce06 (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
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   211
 **************/
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   212
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   213
//#define RANDOM_DEBUG
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   214
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   215
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   216
// Enable this to produce higher quality random numbers.
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   217
// Doesn't work with network yet.
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   218
// #define MERSENNE_TWISTER
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   219
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   220
void SetRandomSeed(uint32 seed);
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   221
#ifdef RANDOM_DEBUG
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   222
	#define Random() DoRandom(__LINE__, __FILE__)
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   223
	uint32 DoRandom(int line, const char *file);
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   224
	#define RandomRange(max) DoRandomRange(max, __LINE__, __FILE__)
68fb2ccbce06 (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);
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   226
#else
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   227
	uint32 Random();
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   228
	uint RandomRange(uint max);
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   229
#endif
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   230
68fb2ccbce06 (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
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   232
uint InteractiveRandomRange(uint max);
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   233
68fb2ccbce06 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
   234
#endif /* RANDOM_FUNC_HPP */