mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
Tents: fix bias in tent placement.
In the very first stage of game generation, we're supposed to pick 1/5 of the grid squares to put tents in, in a uniformly random manner. It failed to be uniform, because I had the wrong limit in random_upto - but it was too small rather than too large, so it never overran the buffer in a way that something like ASan or valgrind would have caught.
This commit is contained in:
2
tents.c
2
tents.c
@ -998,7 +998,7 @@ static char *new_game_desc(const game_params *params_in, random_state *rs,
|
|||||||
int dy, dx;
|
int dy, dx;
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
|
|
||||||
which = i + random_upto(rs, j);
|
which = i + random_upto(rs, w*h - i);
|
||||||
tmp = order[which];
|
tmp = order[which];
|
||||||
order[which] = order[i];
|
order[which] = order[i];
|
||||||
order[i] = tmp;
|
order[i] = tmp;
|
||||||
|
Reference in New Issue
Block a user