Here is a small
OCaml program computing the percentage of succes of a sequence of actions.
The program
let p x = (float (7 - x) /. 6.)
(* conversion difficulty -> probability of success *)
let rec proba_without (rolls_list : int list) : float =
match rolls_list with
[] -> 1.
| h::t -> (p h) *. (proba_without t)
let rec proba_with_rr (rolls_list : int list) : float =
match rolls_list with
[] -> 1.
| h::t -> (p h) *. (proba_with_rr t) +. (1. -. (p h)) *. (proba_without
rolls_list)
let percentage (px : float) : float =
(floor (px *. 1000.))/. 10.
(* conversion probability -> percentage, rounded down with an accuracy of 0.1 % *)
let proba_calculator (rolls_list : int list) (reroll : bool) : float =
if reroll
then percentage (proba_with_rr rolls_list)
else percentage (proba_without rolls_list)
How to use it ?
First you need to run a Ocaml toplevel and load the definitions I gave here. Then you just have to call the function proba_calculator with the list of rolls you must do and wether you have a re-roll or not. the result is the percentage of success, rounded down. If you must roll 2 actions with a 3+ difficulty each, without reroll, just type
proba_calculator [ 3 ; 3 ] false and the program will answer
44.4%.
Some examples :
proba_calculator [ 2 ] true
97.2
proba_calculator [ 4 ; 4 ] false
25
proba_calculator [ 3 ; 2 ; 2 ; 3 ] true
61.7