klangner / mapgen.rs

Map generator for games.
https://klangner.github.io/mapgen.rs/
Apache License 2.0
44 stars 5 forks source link

Upgrade to rand 0.8. #34

Closed ndarilek closed 3 years ago

ndarilek commented 3 years ago

There is a failing test: src/random.rs:50. If you have any insight on to why this is failing, I'll gladly fix it. Looks like it is averaging a random sequence, which seems a bit fragile to me as it gets 6 rather than 7, though the min and max seem right. But I need rand 0.8, so figured I'd submit a PR and use my fork until this lands.

Thanks!

klangner commented 3 years ago

Hi, Thanks for the PR. Regarding the problem: Since I use seed to create RNG it is not really random and I was expecting that it should be ok. But It looks that it doesn't always work across new version of the random lib.

Probably the best fix would be to change seed. for example this should work:

let mut rng = StdRng::seed_from_u64(100);

Change seed to 100 in line 45.

The other possible solution would to use more samples. You can change line 44 to:

let num_op = 10_000;

The second solution is probably better but the first one should be faster.

ndarilek commented 3 years ago

Thanks for that. Bumping the sample count seems to have done it. Probably takes a bit longer, but I don't imagine the tests are run often enough to make that a significant issue.