-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathRandom.d
More file actions
42 lines (36 loc) · 948 Bytes
/
Random.d
File metadata and controls
42 lines (36 loc) · 948 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/***********************************\
RANDOM
\***********************************/
//========================================
// Zufallsvariablen
//========================================
const int r_val = 0;
//========================================
// Zufallszahl holen
//========================================
func int r_Next() {
r_val = (1103515245 * r_val) + 12345;
if(r_val < 0) {
r_val += 2147483647;
};
return r_val;
};
func int r_Max(var int max) {
return r_Next()%(max+1);
};
func int r_MinMax(var int min, var int max) {
return r_Max(max - min) + min;
};
//========================================
// Zufall initialisieren
//========================================
func void r_Init(var int seed) {
r_val = seed;
r_val = r_Next();
r_val = r_Next();
r_val = r_Next();
};
func void r_DefaultInit() {
CALL__cdecl(sysGetTimePtr);
r_Init(CALL_RetValAsInt());
};