Wednesday, August 02, 2006

Dice Wars

I have been addicted to this Flash based game Dice Wars this week. It is pretty similar to Risk. Lots of fun but tough to play just one.

I was having a trouble estimating the odds of winning any given battle, so I decided to figure them out. My probability is a little rusty, so I couldn't figure it out mathematically and had to go all Monte Carlo on this biyotch (I can remember all the the stuff with coins or balls and urns but can't figure out how to do dice).

This table shows the odds of winning a battle. The number of dice the attacker has is on top and number of dice for the defender on the side. A tie goes to the defender.



2345678
10.84180.9720.99620.9998111
20.4480.77980.94060.98840.99760.99981
30.14940.45440.73640.90560.97580.99360.9992
40.03620.19120.44820.71940.88760.96240.9904
50.00780.06060.21840.46580.6940.86340.9538
60.00060.01580.08040.25080.46420.6890.8432
700.00380.02340.10460.260.47140.6792
800.00060.00660.03840.120.27020.4564


For example, if you have 5 dice taking on someone with 3 you have a 90.56% chance of winning. This table is really handy when trying to figure out your strategy.

Anyway, the game is good stuff, give it a try.

via Digg

Update: The Kdice Wikispace has probabilities as well, and probably more accurate than the table above.

4 comments:

Anonymous said...

I have found a problem with the numbers above. You show a 100% chance of 8 dice defeating 2 dice, but it's obvious that 8 dice could roll 8,9,10,11 or 12 which is within reach of two dice. I've done the calculations and the percent should actually be .999877 which rounds to .9999 and not 1.

Fat Knowledge said...

Anon,

Wow, I am impressed! I couldn't remember how to do the math, so I just used the random number generator in my computer and ran like 1 million instances to get close to the real thing. I am not sure how accurate the numbers are, but they are more than good enough for what I wanted to use them for (figuring out what my chances of winning are on a move). I later found this site that has the probabilities, and I bet they are more accurate than mine.

Anonymous said...

Close, but it would have been more accurate to simply run for-loops for every combination and add everything up. would only take moments on a desktop to computer to churn through the tables.

eg: pseudo-code for 2 dice against 3 dice:

wins = 0;
battles = 0;

for a1 =1 to 6
for a2 = 1 to 6
for d1 = 1 to 6
for d2 = 1 to 6
for d3 = 1 to 6
battles = battles + 1
attack = a1+a2
defense = d1+d2+d3
if (attack > defense) wins = wins+1
endloop
endloop
endloop
endloop
endloop
print 'chance of 2 dice beating 3 dice is' (wins/battles * 100)

This might get a little sluggish testing 8 dice against 8 dice (2.3 billion iterations of the inner loop) so the next optimization would be to build summary tables for each number of dice, but thats another lesson ;)
Happy computing..


-Rob

Anonymous said...

eeks. i meant 2.3 trillion... so those summary tables would be useful...

Post a Comment

Note: Only a member of this blog may post a comment.