diff options
| author | Simon Tatham <anakin@pobox.com> | 2005-06-01 12:46:27 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2005-06-01 12:46:27 +0000 |
| commit | ad3abd9867962c94feeb09956e53c6fde886df0e (patch) | |
| tree | bce40d5df313cb7764ffef66c347c5880f08087c | |
| parent | b8197684f345d7b294a84eaf948dce9ba3dfce6e (diff) | |
| download | puzzles-ad3abd9867962c94feeb09956e53c6fde886df0e.zip puzzles-ad3abd9867962c94feeb09956e53c6fde886df0e.tar.gz puzzles-ad3abd9867962c94feeb09956e53c6fde886df0e.tar.bz2 puzzles-ad3abd9867962c94feeb09956e53c6fde886df0e.tar.xz | |
Arrange that random seeds are as harmonised as they can reasonably
be between interactive and batch use.
[originally from svn r5896]
| -rw-r--r-- | mines.c | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -2041,12 +2041,24 @@ static char *new_mine_layout(int w, int h, int n, int x, int y, int unique, static char *new_game_desc(game_params *params, random_state *rs, game_aux_info **aux, int interactive) { + /* + * We generate the coordinates of an initial click even if they + * aren't actually used. This has the effect of harmonising the + * random number usage between interactive and batch use: if + * you use `mines --generate' with an explicit random seed, you + * should get exactly the same results as if you type the same + * random seed into the interactive game and click in the same + * initial location. (Of course you won't get the same grid if + * you click in a _different_ initial location, but there's + * nothing to be done about that.) + */ + int x = random_upto(rs, params->w); + int y = random_upto(rs, params->h); + if (!interactive) { /* * For batch-generated grids, pre-open one square. */ - int x = random_upto(rs, params->w); - int y = random_upto(rs, params->h); signed char *grid; char *desc; |