MCPcopy Create free account
hub / github.com/crawl/crawl / bernoulli

Function bernoulli

crawl-ref/source/random.cc:423–428  ·  view source on GitHub ↗

Roll n_trials, return true if at least one succeeded. n_trials might be not integer. [0, 1]

Source from the content-addressed store, hash-verified

421// not integer.
422// [0, 1]
423bool bernoulli(double n_trials, double trial_prob)
424{
425 if (n_trials <= 0 || trial_prob <= 0)
426 return false;
427 return !decimal_chance(pow(1 - trial_prob, n_trials));
428}
429
430bool one_chance_in(int a_million)
431{

Callers 1

polar_vortex_damageFunction · 0.85

Calls 2

decimal_chanceFunction · 0.85
powFunction · 0.85

Tested by

no test coverage detected