4 * The geeky little puzzle game with a big noodly crunch!
6 * gPlanarity copyright (C) 2005 Monty <monty@xiph.org>
7 * Original Flash game by John Tantalo <john.tantalo@case.edu>
8 * Original game concept by Mary Radcliffe
10 * gPlanarity is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2, or (at your option)
15 * gPlanarity is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with Postfish; see the file COPYING. If not, write to the
22 * Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
29 // Portable 32 bit random number generator. It's not crypto-grade,
30 // but we don't need crypto-grade. We need complete control over the
31 // result sequence and reproducability, so we can't use any local
32 // generator. As long as it's 100% consistent across
33 // platforms/OSes/compilers and fairly uniform (doesn't always return
34 // 17), we're all set.
36 // This is a C derivative of the PASCAL "Integer Version 2" minimal
37 // standard number generator thich appears in the article:
38 // Park, Steven K. and Miller, Keith W., "Random Number
39 // Generators: Good Ones are Hard to Find", Communications of the
40 // ACM, October, 1988.
43 static int32_t next
= 123456789;
45 void random_seed(int32_t seed
){
53 int32_t random_number(){
54 int32_t hival
, loval
, testval
;
56 hival
= next
/ MOBYMP
;
57 loval
= next
% MOBYMP
;
58 testval
= MPLIER
*loval
- MOMDMP
*hival
;
62 next
= testval
+ MAX_G_RAND
;
67 int random_yes(int per128_yes
){
68 u_int32_t num
= (u_int32_t
)random_number();
69 return (num
< (unsigned int)per128_yes
<< 24U);