added support for BD game engine to Makefile for Android
[rocksndiamonds.git] / src / game_bd / bd_random.h
1 /* GLIB - Library of useful routines for C programming
2  * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
4  * SPDX-License-Identifier: LGPL-2.1-or-later
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18  */
19
20 /* Originally developed and coded by Makoto Matsumoto and Takuji
21  * Nishimura.  Please mail <matumoto@math.keio.ac.jp>, if you're using
22  * code from this file in your own programs or libraries.
23  * Further information on the Mersenne Twister can be found at
24  * http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
25  * This code was adapted to glib by Sebastian Wilhelmi.
26  */
27
28 /*
29  * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
30  * file for a list of people on the GLib Team.  See the ChangeLog
31  * files for a list of changes.  These files are distributed with
32  * GLib at ftp://ftp.gtk.org/pub/gtk/.
33  */
34
35 #ifndef BD_RANDOM_H
36 #define BD_RANDOM_H
37
38
39 typedef struct _GdRand GdRand;
40
41 /* GdRand - a good and fast random number generator: Mersenne Twister
42  * see http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html for more info.
43  * The range functions return a value in the interval [begin, end).
44  * int          -> [0..2^32-1]
45  * int_range    -> [begin..end-1]
46  * double       -> [0..1)
47  * double_range -> [begin..end)
48  */
49
50 GdRand      *gd_rand_new_with_seed(unsigned int seed);
51 GdRand      *gd_rand_new_with_seed_array(const unsigned int *seed, unsigned int seed_length);
52 GdRand      *gd_rand_new(void);
53 void         gd_rand_free(GdRand *rand);
54 GdRand      *gd_rand_copy(GdRand *rand);
55 void         gd_rand_set_seed(GdRand *rand, unsigned int seed);
56 void         gd_rand_set_seed_array(GdRand *rand_, const unsigned int *seed, unsigned int seed_length);
57 #define      gd_rand_boolean(rand_) ((gd_rand_int (rand_) & (1 << 15)) != 0)
58 unsigned int gd_rand_int(GdRand *rand_);
59 int          gd_rand_int_range(GdRand *rand_, int begin, int end);
60 double       gd_rand_double(GdRand *rand_);
61 double       gd_rand_double_range(GdRand *rand_, double begin, double end);
62
63 void         gd_random_set_seed(unsigned int seed);
64 #define      gd_random_boolean() ((gd_random_int () & (1 << 15)) != 0)
65 unsigned int gd_random_int(void);
66 int          gd_random_int_range(int begin, int end);
67
68 double       gd_random_double(void);
69 double       gd_random_double_range(double  begin, double  end);
70
71 #endif  // BD_RANDOM_H