A handy little F# script for computing odds for Dungeon Fantasy/GURPS, such as the odds of a Slow Stone affecting a dragon:
let distribution3d6 =
[for x in 1..6 do
for y in 1..6 do
for z in 1..6 do
(x+y+z), (x,y,z)]
let probabilityOfSuccess attackerSkill defenderSkill =
let mutable n = 0
let mutable success = 0
for x,_ in distribution3d6 do
for y,_ in distribution3d6 do
n <- n + 1
let successMargin =
match attackerSkill - x with
| n when n >= 0 -> Some n
| _ -> None
match defenderSkill - y, successMargin with
| defenderMargin, Some attackerMargin when attackerMargin > defenderMargin ->
success <- success + 1
| _ -> ()
{| attackerSkill = attackerSkill; defenderSkill = defenderSkill; n = n; success = success; successRatio = (float success/float n) |}
probabilityOfSuccess 15 15
--
I could not love thee dear, so much,
Loved I not honor more.
let distribution3d6 =
[for x in 1..6 do
for y in 1..6 do
for z in 1..6 do
(x+y+z), (x,y,z)]
let probabilityOfSuccess attackerSkill defenderSkill =
let mutable n = 0
let mutable success = 0
for x,_ in distribution3d6 do
for y,_ in distribution3d6 do
n <- n + 1
let successMargin =
match attackerSkill - x with
| n when n >= 0 -> Some n
| _ -> None
match defenderSkill - y, successMargin with
| defenderMargin, Some attackerMargin when attackerMargin > defenderMargin ->
success <- success + 1
| _ -> ()
{| attackerSkill = attackerSkill; defenderSkill = defenderSkill; n = n; success = success; successRatio = (float success/float n) |}
probabilityOfSuccess 15 15
--
I could not love thee dear, so much,
Loved I not honor more.
No comments:
Post a Comment