mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-23 00:42:13 -07:00
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]
This commit is contained in:
7
midend.c
7
midend.c
@ -135,11 +135,16 @@ void midend_new_game(midend_data *me)
|
|||||||
/*
|
/*
|
||||||
* Generate a new random seed. 15 digits comes to about
|
* Generate a new random seed. 15 digits comes to about
|
||||||
* 48 bits, which should be more than enough.
|
* 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];
|
char newseed[16];
|
||||||
int i;
|
int i;
|
||||||
newseed[15] = '\0';
|
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);
|
newseed[i] = '0' + random_upto(me->random, 10);
|
||||||
sfree(me->seedstr);
|
sfree(me->seedstr);
|
||||||
me->seedstr = dupstr(newseed);
|
me->seedstr = dupstr(newseed);
|
||||||
|
Reference in New Issue
Block a user