-
Notifications
You must be signed in to change notification settings - Fork 12
Handling Probabilities
Vadim Gromov edited this page Jan 10, 2021
·
6 revisions
IMPORTANT: every percents in Zara are measured in 0-100 int scale!
(except the rain intensity value that is in 0..1
scale)
Very often you need to trigger some event according to its probability of happening. For this purpose WillHappen extension method for int type exists. It takes one argument -- probability percent (int, 0 to 100) and returns bool.
For example,
if (50.WillHappen()) {
...
means that condition is satisfied approximately in every 50% of calls.
0.WillHappen()
will always return false
.
100.WillHappen()
will always return true
.
This WillHappen
method calls Zara's randomization function that was set during the engine set up.