| 1 |
/* |
| 2 |
* libmowgli: A collection of useful routines for programming. |
| 3 |
* random.h: Portable mersinne-twister based psuedo-random number generator. |
| 4 |
* |
| 5 |
* Copyright (c) 2007 William Pitcock <nenolod -at- sacredspiral.co.uk> |
| 6 |
* |
| 7 |
* Permission to use, copy, modify, and/or distribute this software for any |
| 8 |
* purpose with or without fee is hereby granted, provided that the above |
| 9 |
* copyright notice and this permission notice is present in all copies. |
| 10 |
* |
| 11 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 12 |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 13 |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 14 |
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, |
| 15 |
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 16 |
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 17 |
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 18 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 19 |
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
| 20 |
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 21 |
* POSSIBILITY OF SUCH DAMAGE. |
| 22 |
*/ |
| 23 |
|
| 24 |
#ifndef MOWGLI_SRC_LIBMOWGLI_BASE_RANDOM_H_INCLUDE_GUARD |
| 25 |
#define MOWGLI_SRC_LIBMOWGLI_BASE_RANDOM_H_INCLUDE_GUARD 1 |
| 26 |
|
| 27 |
/* mowgli_random_t contains state data which is private */ |
| 28 |
struct mowgli_random_; |
| 29 |
|
| 30 |
typedef struct mowgli_random_ mowgli_random_t; |
| 31 |
|
| 32 |
/* construction and destruction. */ |
| 33 |
extern mowgli_random_t *mowgli_random_create(void); |
| 34 |
extern mowgli_random_t *mowgli_random_create_with_seed(unsigned int seed); |
| 35 |
|
| 36 |
/* reset seed */ |
| 37 |
extern void mowgli_random_reseed(mowgli_random_t *self, unsigned int seed); |
| 38 |
|
| 39 |
/* number retrieval */ |
| 40 |
extern unsigned int mowgli_random_int(mowgli_random_t *self); |
| 41 |
extern int mowgli_random_int_ranged(mowgli_random_t *self, int begin, int end); |
| 42 |
|
| 43 |
#endif /* MOWGLI_SRC_LIBMOWGLI_BASE_RANDOM_H_INCLUDE_GUARD */ |