Skip to main content
gamedev.net
🔒 Locked

Probabilities

Started by ToohrVyk Aug 7, 2006 at 2:51 PM 8 replies 900+ views
Original Post
ToohrVyk
ToohrVyk
I am writing a dice roller for pen&paper Vampire : The Masquerade, and I wanted to add the ability to create probability tables. I have stumbled upon some probability problems I cannot seem to solve. In this game, you throw N 10-sided dice. Each die that is greater than the difficulty D counts as a success, each die equal to 1 counts as a negative success. I want to compute the probability of a certain number of successes, given D and N, but how? A particular situation (in the case of specialities) is where a 10 also has a special meaning: it allows you to throw an additional die. Again, what is the probability of a certain number of successes?
SiCrane
SiCrane
It's possible to work these probabilities out with your basic decision trees, but it's sometimes not worth the effort to do so. If you only are giving answers to a finite number of decimal places, it'd probably be easier to determine things by simulation. Just roll N dice 1,000,000 times and see how often you get X successes against a difficulty of D. You can always do this offline, write out the results to a file and load that at runtime as a data file.
ToohrVyk
ToohrVyk
I will try this, although short of a full enumeration there will probably be errors due to the nature of pseudorandom numbers.

Thank you.
SiCrane
SiCrane
Of course, but if your number of repititions is a lot larger than your degree of accuracy than it shouldn't be an issue. For example, it's not really that useful to list probabilities out to more than one hundreth of one percent (0.01%) for an RPG dice table; this only represents one in 10,000. If you do 1,000,000 samples, then chances are it'll be good enough. And computers are pretty fast at this kind of raw number crunching thing.
ToohrVyk
ToohrVyk
True. I'll try out both methods (random rolling, and full enumeration). Both seem fast enough, I can let the computer run all night if necessary.
Raghar
Raghar
If you want to show some probability tables, but don't use them for computation.
Probability to roll higher than 4 on 6 sided dice is 1/3. Probability of rolling two ones on two six sided dices is (1/6)^2. If you don't seem to grasp it out, try to imagine a simple situation and properly analyse it. A little question what is probability to roll only one two on a 3 six sides dices.

You would be however in a big problem if you'd not use properly seeded Mersene Twister.
LorenzoGatti
LorenzoGatti
On the back of an envelope, 9 different difficulty levels (2 to 10) and a pool of n dice, not including rerolls on a ten have 9*10^n cases (greatly reduced by symmetry), requiring just a few billions of operations for an exact brute force computation without expensive pseudorandom number generators; it would probably run in a few minutes or hours, probably less time that you need to write it.
Omae Wa Mou Shindeiru
Raghar
Raghar
Sure they can be computed quickly. There is even detailed table on the Internet, with full analysis of botches and other stuff.

It's probably even easier to create the correct equation and just let it be solved by a computer.
ToohrVyk
ToohrVyk
I guess you're right: "when in doubt, use google".

I think I could have written a faster program, but I don't really mind letting it run for hours.
ToohrVyk
ToohrVyk
The final solution I have used is:

Probability (S successes with N dice at difficulty D) =     Probability (1 on d10) * Probability (S+1 with N-1 at D)  + Probability (success) * Probability (S-1 with N-1 at D)  + Probability (failure) * Probability (S with N-1 at D)


Where the probability of success and (non-zero) failure depends on D. This evaluates in under a second for the entire table of values.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.