The premise of this is simple: A 10% chance is pretty unlikely, but everyone knows that a one-in-a-million chance is a sure thing!
So, write code that implements the following "dramatic" probability rules:
- Take in a floating point P from 0 to 1 representing the unmodified chance of some plot-related event, and a boolean representing whether we're in the climax or not.
- Determine P' on these conditions:
- If 0 < P ≤ 10-3 then P' = 1.
- If .999 ≤ P < 1 then P' = 0.
- If P = 0 and we're in the climax, then the heroes will likely get a last-minute sudden advantage and P' = .9.
- If P = 1 and we're in the climax, then the villain will unveil an as-yet-unseen superweapon and P' = .1.
- Otherwise, P' = P.
- Return truthy or falsey based on P' as the chance of truth. For example, if P' = .7, then you should return truthy 70% of the time and falsey 30% of the time.
Shortest code in bytes wins!