Help - Search - Members - Calendar
Full Version: The grand unified chances of success formula
Dumpshock Forums > Discussion > Shadowrun
Da9iel
Holy $hit I did it! Here's the formula as best I can write it without proper subscripts, superscripts, etc.

W = chances of success on the roll
T = target number
D = dice used
S = successes needed e.g. threshold +1
C = (truncate (T-1)/6) + 1 (=1 for target numbers 2 through 6, 2 for 7 through 12, etc)
B = 6C+1
A = 6^C-B

K(n,S) = 1*(n-1)*(n-2)*(n-3)...*[n-(S-1)]
.............1*(S-1)*(S-2)*(S-3)...*[S-(S-1)]

W = Sum from n=S to D of K(n,S)*(T-A)^(n-S)*(B-T)^S/6^(C*n)

I also wrote it up in QBasic. I'll edit that in below right after the spoiler test. It's in spoilers for length.
[ Spoiler ]


edit: fixed the last term C*n not 6*n!
Da9iel
Yes it does work for all rational numbers of dice, target numbers and needed successes. Sorry I couldn't properly indent the for:next loops, but DS won't let me. Enjoy. You may copy this without any credit of course (since I don't own math and it's a simple code), but I would bask warmly in any credit given. cool.gif
BitBasher
Um, but doesn't your chance of a sucess have little to do with one actually being rolled when you need it? I don't get it.
draco aardvark
Or, for those of you out there who haven't used QBASIC since they disassembled their 486 for parts...
in Perl!
now with slightly more sane variable names nyahnyah.gif

CODE

#!/usr/bin/perl
use strict;

print "How many dice? ";
my $dice = <STDIN>;
if ($dice < 1){print "Too few dice :-(\n"; exit;}

print "Target number? ";
my $tn = <STDIN>;
if ($tn < 2) {print "Too easy!\n"; exit;}

print "How many successes do you need? ";
#let's make an opposed probability for combat spells next :-)
#oooh! and services from an elemental/spirit
my $suc_need = <STDIN>;
if ($suc_need > $dice) {print "You fail, need more successes than dice\n"; exit;}

my $c = int(($tn-1) / 6)  +1;
my $b = 6*$c +1;
my $a = 6**$c - $b;
my $odds = 0;

my $f = 1;
my $g = 1;

for (my $n = $suc_need; $n <= $dice; $n++)
{
       for (my $e = 1; $e <= $suc_need -1; $e++)
       {      $f *= $n - $e;
               $g *= $suc_need - $e;
       }
       our $K = $f / $g;
       $odds = $odds + $K*($tn+$a)**($n-$suc_need)*($b-$tn)**$suc_need / 6**($c*$n)
}
$odds *= 100;
print "\nChances of winning: $odds \n";


But in all seriousness, thank you Da9iel, I'd been meaning to figure out that formula for quite some time, and just never wanted to crack open my old statistics book. Thanks smile.gif
Also, the "[code]" tag lets you insert spaces
draco aardvark
here's one to calculate the average number of services you'll get from a spirit/elemental:

CODE

#!/usr/bin/perl
use strict;

print "Conjuring skill? ";
my $skill = <STDIN>;
if ($skill < 1){print "You lack the skill!\n"; exit;}

print "Spirit's force? ";
my $tn = <STDIN>;
if ($tn < 2) {print "Target number is 2\n"; $tn=2;}

my $c = int(($tn-1) / 6)  +1;
my $b = 6*$c +1;

my $odds = ($b-$tn) / 6**$c;
$odds *= $skill;
print "\naverage number of services: $odds \n";
draco aardvark
If I did it right, this one should calculate the liklyhood of wining an oposed roll and tell you by how many you'll win it by (for staging)

sorry to clutter up the boards, but apparently "code" can't go within "spoiler" and it's really hard to read loops without indentation

CODE

#!/usr/bin/perl
use strict;

print "This program calculates the odds of you winning an oposed test.\n";
print "Your skill? ";
my $skill = <STDIN>;
if ($skill < 1){print "You lack the skill!\n"; exit;}

print "Your TN? ";
my $tn = <STDIN>;
if ($tn < 2) {print "Target number is 2\n"; $tn=2;}

my $c = int(($tn-1) / 6)  +1;
my $b = 6*$c +1;

my $your_avg_successes = ($b-$tn) / 6**$c;
$your_avg_successes *= $skill;
print "\nyour average successes: $your_avg_successes\n";



#now, what's the probability they'll get that many?

print "How many dice are they oposing you with? ";
my $their_dice = <STDIN>;
if ($their_dice < 1){print "They have no dice, you win!\n(check your math)\n"; exit;}

print "Their target number? ";
my $their_tn = <STDIN>;
if ($their_tn < 2) {print "Their TN is 2\n"; $their_tn = 2;}

my $suc_need = $your_avg_successes;
if ($suc_need > $their_dice)  {print "You average more dice than they have to opose you, you'll almost certainly win\n"; exit;}

$c = int(($their_tn-1) / 6)  +1;
$b = 6*$c +1;
my $a = 6**$c - $b;
my $odds = 0;

my $f = 1;
my $g = 1;

for (my $n = $suc_need; $n <= $their_dice; $n++)
{
      for (my $e = 1; $e <= $suc_need -1; $e++)
      {       $f *= $n - $e;
            $g *= $suc_need - $e;
      }
      our $K = $f / $g;
      $odds = $odds + $K*($their_tn+$a)**($n-$suc_need)*($b-$their_tn)**$suc_need / 6**($c*$n)
}

$odds *= 100;
#that's the odds they'll succeed, we want the odds you'll succeed
$odds = 100 - $odds;
print "\nChances of winning: $odds% \n";

#now we need your average net successes

my $their_odds_success = ($b-$their_tn) / 6**$c;
my $net_successes = $your_avg_successes - ($their_odds_success * $their_dice);
print "Average net successes: $net_successes dice\n";
draco aardvark
Hey Da9iel, can you explain how you got that formula? I don't actually understand what it is, I'm just translating your code and sticking add-ons to it.

I'd like to make a script for an open test, showing probabilities at different numbers, but don't know how to limit it so that we're not finding the likelihood of at least 1 instance of x, but instead finding the likelihood of x as the highest result. (so that I can make a mini-graph to show where most of your results will be)
Da9iel
Actually its a purely empirical formula that exactly matches the probabilities [of getting various numbers of successes] out to target numbers of 24 and up to 5 dice. When it matched that much exactly I assumed that it would match the rest. I know enough about statistics to know that it definitely works, but not enough to find an easier way to express it. It took me several hours of tabulating every possible outcome of up to 7776 dice and looking for patterns.

As far as open tests go, I guess you could come up with an average high value, but those are so volatile that an average high value would mean little. I'll think about it some and get back to you.

What the heck good is a % chance of success? Mostly it's for people who want to know how long on average it takes to learn a force 10 spell.

And it would let you play shadowrun with a couple of d10s (or a d100--I've seen one) instead of d6s. silly.gif
draco aardvark
I made the % chance of success because I have a habit of estimating things very badly. Like taking control actions at force 3, I could get the program to say "they'll probably make that dummy" so I realized I ought to have it higher. That and reminding me how much defaulting sucks smile.gif
basically the same reason I made average number of services from an elemental... "oh, right, I'll get an average of 0.1 services from one that big. I'll just make 2 smaller ones then"

As for playing with percentile dice, that really disturbs me for some reason. Kinda reminds me of Rifts though.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Dumpshock Forums © 2001-2012