aboutsummaryrefslogtreecommitdiff
path: root/midend.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2005-05-23 12:02:37 +0000
committerSimon Tatham <anakin@pobox.com>2005-05-23 12:02:37 +0000
commit49fdcd1ed465e2ad2b8622eb1647eb5e0f8d6608 (patch)
tree0922ae6cd6bee567304156844e219743e023b85f /midend.c
parent80aa8bafb1d20bc0b2fea6b5c928db58a93c851f (diff)
downloadpuzzles-49fdcd1ed465e2ad2b8622eb1647eb5e0f8d6608.zip
puzzles-49fdcd1ed465e2ad2b8622eb1647eb5e0f8d6608.tar.gz
puzzles-49fdcd1ed465e2ad2b8622eb1647eb5e0f8d6608.tar.bz2
puzzles-49fdcd1ed465e2ad2b8622eb1647eb5e0f8d6608.tar.xz
Avoid leading zeroes on internally generated random seeds, _just_ in
case they confuse anyone who expects the same seed without the leading zero to be equivalent. [originally from svn r5838]
Diffstat (limited to 'midend.c')
-rw-r--r--midend.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/midend.c b/midend.c
index 1d7087a..070f4f3 100644
--- a/midend.c
+++ b/midend.c
@@ -135,11 +135,16 @@ void midend_new_game(midend_data *me)
/*
* Generate a new random seed. 15 digits comes to about
* 48 bits, which should be more than enough.
+ *
+ * I'll avoid putting a leading zero on the number,
+ * just in case it confuses anybody who thinks it's
+ * processed as an integer rather than a string.
*/
char newseed[16];
int i;
newseed[15] = '\0';
- for (i = 0; i < 15; i++)
+ newseed[0] = '1' + random_upto(me->random, 9);
+ for (i = 1; i < 15; i++)
newseed[i] = '0' + random_upto(me->random, 10);
sfree(me->seedstr);
me->seedstr = dupstr(newseed);