File: random.h

package info (click to toggle)
tworld 1.3.0-5
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 6,620 kB
  • ctags: 1,407
  • sloc: ansic: 12,442; perl: 2,465; makefile: 191; sh: 16
file content (45 lines) | stat: -rw-r--r-- 1,061 bytes parent folder | download | duplicates (6)
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
43
44
45
/* random.h: The game's random-number generator.
 *
 * Copyright (C) 2001-2006 by Brian Raiter, under the GNU General Public
 * License. No warranty. See COPYING for details.
 */

#ifndef	_random_h_
#define	_random_h_

#include	"defs.h"

/* Create a fresh PRNG.
 */
extern prng createprng(void);

/* Mark an existing PRNG as beginning a new sequence.
 */
extern void resetprng(prng *gen);

/* Restart an existing PRNG upon a predetermined sequence.
 */
extern void restartprng(prng *gen, unsigned long initial);

/* Retrieve the original seed value of the current sequence.
 */
#define	getinitialseed(gen)	((gen)->initial)

/* Return a random integer between zero and three, inclusive.
 */
extern int random4(prng *gen);

/* Randomly select one of the three integer arguments as the return
 * value.
 */
extern int randomof3(prng *gen, int a, int b, int c);

/* Randomly permute an array of three integers.
 */
extern void randomp3(prng *gen, int *array);

/* Randomly permute an array of four integers.
 */
extern void randomp4(prng *gen, int *array);

#endif