summaryrefslogtreecommitdiff
path: root/src/isaac.h
diff options
context:
space:
mode:
authorErik Reckase <e.reckase@gmail.com>2010-04-19 19:52:20 +0000
committerScott Draves <spot@draves.org>2015-02-15 12:20:11 -0500
commit0b31b96c55620dcf7c5ca657d3572a8c635c971b (patch)
tree05b3537d9ab91736d00604aebb7c2d71bdaf005e /src/isaac.h
parent238395d5515e30af28983f93075bbcbf248d4903 (diff)
downloadpucket-0b31b96c55620dcf7c5ca657d3572a8c635c971b.tar.gz
pucket-0b31b96c55620dcf7c5ca657d3572a8c635c971b.tar.bz2
pucket-0b31b96c55620dcf7c5ca657d3572a8c635c971b.zip
Initial commit of early-clip branch of flam3 into google code.
git-svn-id: https://flam3.googlecode.com/svn/trunk@3 77852712-ef1d-11de-8684-7d64432d61a3
Diffstat (limited to 'src/isaac.h')
-rw-r--r--src/isaac.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/isaac.h b/src/isaac.h
new file mode 100644
index 0000000..6554569
--- /dev/null
+++ b/src/isaac.h
@@ -0,0 +1,56 @@
+/*
+------------------------------------------------------------------------------
+isaac.h: definitions for a random number generator
+MODIFIED:
+ 960327: Creation (addition of randinit, really)
+ 970719: use context, not global variables, for internal state
+ 980324: renamed seed to flag
+ 980605: recommend RANDSIZL=4 for noncryptography.
+ 991209: modified for inclusion with GNU Backgammon by Gary Wong
+ 070121: modified for inclusion with flam3 by Erik Reckase
+------------------------------------------------------------------------------
+*/
+
+#include "isaacs.h"
+
+#ifndef _ISAAC_H_
+#define _ISAAC_H_
+
+#define RANDSIZL (4) /* I recommend 8 for crypto, 4 for simulations */
+#define RANDSIZ (1<<RANDSIZL)
+
+/* context of random number generator */
+struct randctx
+{
+ ub4 randcnt;
+ ub4 randrsl[RANDSIZ];
+ ub4 randmem[RANDSIZ];
+ ub4 randa;
+ ub4 randb;
+ ub4 randc;
+};
+typedef struct randctx randctx;
+
+/*
+------------------------------------------------------------------------------
+ If (flag==TRUE), then use the contents of randrsl[0..RANDSIZ-1] as the seed.
+------------------------------------------------------------------------------
+*/
+void irandinit( randctx *r, word flag );
+
+void isaac( randctx *r );
+
+
+/*
+------------------------------------------------------------------------------
+ Call irand(/o_ randctx *r _o/) to retrieve a single 32-bit random value
+------------------------------------------------------------------------------
+*/
+#define irand(r) \
+ (!(r)->randcnt-- ? \
+ (isaac(r), (r)->randcnt=RANDSIZ-1, (r)->randrsl[(r)->randcnt]) : \
+ (r)->randrsl[(r)->randcnt])
+
+#endif
+
+