1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-24 17:10:36 +00:00

added randf_from

This commit is contained in:
Zeno Rogue 2024-06-21 15:01:09 +02:00
parent 83a2168fc1
commit b75c43f7a4

View File

@ -62,10 +62,12 @@ EX vector<int> hrandom_permutation(int qty) {
/** Use \link hrngen \endlink to generate a floating point number between 0 and 1.
*/
EX ld hrandf() {
return (hrngen() - hrngen.min()) / (hrngen.max() + 1.0 - hrngen.min());
EX ld randf_from(std::mt19937& r) {
return (r() - r.min()) / (r.max() + 1.0 - r.min());
}
EX ld hrandf() { return randf_from(hrngen); }
/** Returns an integer corresponding to the current state of \link hrngen \endlink.
*/
EX int hrandstate() {