[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnugo-devel] arend_1_30.2: random seed in crash report
From: |
Arend Bayer |
Subject: |
[gnugo-devel] arend_1_30.2: random seed in crash report |
Date: |
Fri, 29 Mar 2002 02:00:25 +0100 (CET) |
- "stepped on a bug" message now reports random seed
I don't think there is more to say about this patch.
Arend
Index: engine/printutils.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/printutils.c,v
retrieving revision 1.21
diff -u -r1.21 printutils.c
--- engine/printutils.c 25 Mar 2002 07:39:18 -0000 1.21
+++ engine/printutils.c 29 Mar 2002 00:56:25 -0000
@@ -257,7 +257,8 @@
}
#endif
- fprintf(stderr, "\ngnugo %s: You stepped on a bug.\n", gg_version());
+ fprintf(stderr, "\ngnugo %s (seed %d): You stepped on a bug.\n",
+ gg_version(), gg_get_seed());
if (board_size >= 9 && board_size <= 19) {
fprintf(stderr, "\
Please save this game as an sgf file and mail it to address@hidden
Index: utils/random.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/utils/random.c,v
retrieving revision 1.5
diff -u -r1.5 random.c
--- utils/random.c 4 Mar 2002 06:49:09 -0000 1.5
+++ utils/random.c 29 Mar 2002 00:56:48 -0000
@@ -55,6 +55,7 @@
/* Set when properly seeded. */
static int rand_initialized = 0;
+static unsigned int set_random_seed;
/* We use this to detect whether unsigned ints are bigger than 32
* bits. If they are we need to clear higher order bits, otherwise we
@@ -117,6 +118,7 @@
gg_srand(unsigned int seed)
{
int i;
+ set_random_seed = seed;
for (i=0; i<N; i++) {
#if BIG_UINT
seed &= 0xffffffffU;
@@ -127,6 +129,17 @@
}
k = N-1; /* Force an immediate iteration of the TGFSR. */
rand_initialized = 1;
+}
+
+
+/* Returns the seed that was set with the last call to gg_srand. */
+unsigned int
+gg_get_seed()
+{
+ if (!rand_initialized)
+ return 0;
+ else
+ return set_random_seed;
}
Index: utils/random.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/utils/random.h,v
retrieving revision 1.4
diff -u -r1.4 random.h
--- utils/random.h 4 Mar 2002 06:49:09 -0000 1.4
+++ utils/random.h 29 Mar 2002 00:56:49 -0000
@@ -52,6 +52,11 @@
*/
void gg_srand(unsigned int seed);
+/* Obtain the seed that was used when initializing the random generator
+ * with the last call to gg_srand.
+ */
+unsigned int gg_get_seed(void);
+
/* Obtain one random integer value in the interval [0, 2^31-1]. */
int gg_rand(void);
- [gnugo-devel] arend_1_30.2: random seed in crash report,
Arend Bayer <=