mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-20 23:51:29 -07:00
The Windows RNG turns out to only give about 16 bits at a time. This
is (a) pretty feeble, and (b) means that although Net seeds transfer between platforms and still generate the same game, there's a suspicious discrepancy in the typical seed _generated_ by each platform. I have a better RNG kicking around in this code base already, so I'll just use it. Each midend has its own random_state, which it passes to new_game_seed() as required. A handy consequence of this is that initial seed data is now passed to midend_new(), which means that new platform implementors are unlikely to forget to seed the RNG because failure to do so causes a compile error! [originally from svn r4187]
This commit is contained in:
6
cube.c
6
cube.c
@ -560,7 +560,7 @@ static void classify_grid_square_callback(void *ctx, struct grid_square *sq)
|
||||
data->squareindex++;
|
||||
}
|
||||
|
||||
char *new_game_seed(game_params *params)
|
||||
char *new_game_seed(game_params *params, random_state *rs)
|
||||
{
|
||||
struct grid_data data;
|
||||
int i, j, k, m, area, facesperclass;
|
||||
@ -605,7 +605,7 @@ char *new_game_seed(game_params *params)
|
||||
|
||||
for (i = 0; i < data.nclasses; i++) {
|
||||
for (j = 0; j < facesperclass; j++) {
|
||||
int n = rand_upto(data.nsquares[i]);
|
||||
int n = random_upto(rs, data.nsquares[i]);
|
||||
|
||||
assert(!flags[data.gridptrs[i][n]]);
|
||||
flags[data.gridptrs[i][n]] = TRUE;
|
||||
@ -653,7 +653,7 @@ char *new_game_seed(game_params *params)
|
||||
/*
|
||||
* Choose a non-blue square for the polyhedron.
|
||||
*/
|
||||
sprintf(p, ":%d", data.gridptrs[0][rand_upto(m)]);
|
||||
sprintf(p, ":%d", data.gridptrs[0][random_upto(rs, m)]);
|
||||
|
||||
sfree(data.gridptrs[0]);
|
||||
sfree(flags);
|
||||
|
Reference in New Issue
Block a user