1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-12-14 18:18:05 +00:00

moved chance from sag to main

This commit is contained in:
Zeno Rogue
2025-12-04 23:35:21 +01:00
parent 58d944c2e1
commit aa808bf77d
2 changed files with 10 additions and 9 deletions

View File

@@ -68,6 +68,16 @@ EX ld randf_from(std::mt19937& r) {
EX ld hrandf() { return randf_from(hrngen); }
/** returns true with probability p */
EX bool chance(double p) {
p *= double(hrngen.max()) + 1;
auto l = hrngen();
auto pv = (decltype(l)) p;
if(l < pv) return true;
if(l == pv) return chance(p-pv);
return false;
}
/** Returns an integer corresponding to the current state of \link hrngen \endlink.
*/
EX int hrandstate() {

View File

@@ -20,15 +20,6 @@ long long numiter = 0;
int vizsa_start;
int vizsa_len = 5;
bool chance(double p) {
p *= double(hrngen.max()) + 1;
auto l = hrngen();
auto pv = (decltype(l)) p;
if(l < pv) return true;
if(l == pv) return chance(p-pv);
return false;
}
bool twoway = false;
int moves, nomoves;