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:
10
game.cpp
10
game.cpp
@@ -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() {
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user