Choose the Most Dramatic Outcome 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 &lt; P &leq; 10-3 then P' = 1.
If .999 &leq; P &lt; 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!
R, 86 bytes



function(a,b,d=a*(1-a))runif(1)&lt;="if"(d,"if"(d&gt;999e-6,a,1-round(a)),"if"(b,.9-.8*a,a))


Try it online!

a is P' and b is 1 or 0 for "in the climax" or not. 

If a is 0 or 1, then d will be 0, in which case if b is 0 just return a, otherwise .9 minus .8*a.

Otherwise if a is not near 0 or 1, d will be "far" from 0 so return a. Otherwise 1-round(a) will take a to the "opposite" 0 or 1.

Then see if a random selection from [0,1] is less than or equal to the resulting probability. 

The link does a little simulation for all the possible scenarios to demonstrate that it all seems to work.