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:
Simon Tatham
2004-05-03 09:10:52 +00:00
parent 6e42ddd31b
commit aa9a8e8c7e
12 changed files with 39 additions and 45 deletions

View File

@ -103,7 +103,7 @@ void status_bar(frontend *fe, char *text);
/*
* midend.c
*/
midend_data *midend_new(frontend *fe);
midend_data *midend_new(frontend *fe, void *randseed, int randseedsize);
void midend_free(midend_data *me);
void midend_set_params(midend_data *me, game_params *params);
void midend_size(midend_data *me, int *x, int *y);
@ -138,13 +138,13 @@ char *dupstr(char *s);
/*
* misc.c
*/
int rand_upto(int limit);
void free_cfg(config_item *cfg);
/*
* random.c
*/
random_state *random_init(char *seed, int len);
unsigned long random_bits(random_state *state, int bits);
unsigned long random_upto(random_state *state, unsigned long limit);
void random_free(random_state *state);
@ -160,7 +160,7 @@ game_params *dup_params(game_params *params);
config_item *game_configure(game_params *params);
game_params *custom_params(config_item *cfg);
char *validate_params(game_params *params);
char *new_game_seed(game_params *params);
char *new_game_seed(game_params *params, random_state *rs);
char *validate_seed(game_params *params, char *seed);
game_state *new_game(game_params *params, char *seed);
game_state *dup_game(game_state *state);