.com.unity Forums
  The Official e-Store of Shrapnel Games

This Month's Specials

Raging Tiger- Save $9.00
winSPMBT: Main Battle Tank- Save $5.00

   







Go Back   .com.unity Forums > Illwinter Game Design > Dominions 2: The Ascension Wars

Reply
 
Thread Tools Display Modes
  #1  
Old December 31st, 2003, 08:16 PM
Saber Cherry's Avatar

Saber Cherry Saber Cherry is offline
Major General
 
Join Date: Oct 2003
Location: Crystal Tokyo
Posts: 2,453
Thanks: 0
Thanked 0 Times in 0 Posts
Saber Cherry is on a distinguished road
Default Dominions Dice Roll Chart

The old thread got deleted accidentally, but here's the crucial element

This is a chart of the probability that the difference between two dice rolls will meet or exceed the listed number. Each dice roll is a 2d6*, or 2d6 upwardly-open pair.

How to use the chart: An example.

What is the probability that a light infantry (att=10) will hit a soulless (def=2, after applying the "fist" penalty)? The difference is (2-10) = -8, but hitting requires you to beat, not just meet, the enemy defense roll. So the roll difference must be at least (2-10)+1 = -7. Looking at the "-7+" row, you see that a light infantry has an 91.8% chance of hitting a soulless.

The reverse case:

Soulless has att=3 after applying the fist -1 att penalty, and a light infantry has def=12. So for a soulless to hit, it must score a differential roll of (12-3)+1 = 10. Looking at the "10+" row, a soulless has a 4.6% chance of striking a light infantry.

The chart can also be used for damage versus protection rolls, poison rolls, and probably morale and magic resist rolls. Almost all Dominions dice rolls seem to be of the form ((2d6* + attacker's modifier) - (2d6* + defender's modifier)), which this chart describes.


Testing (2d6*, labelled 0-5, offset=2) over 200000000 rolls.

Reverse-Cumulative Difference Statistics:

-30+: 99.994%
-29+: 99.992%
-28+: 99.988%
-27+: 99.984%
-26+: 99.978%
-25+: 99.969%
-24+: 99.957%
-23+: 99.941%
-22+: 99.918%
-21+: 99.887%
-20+: 99.844%
-19+: 99.785%
-18+: 99.705%
-17+: 99.596%
-16+: 99.447%
-15+: 99.244%
-14+: 98.969%
-13+: 98.601%
-12+: 98.106%
-11+: 97.442%
-10+: 96.554%
-9+: 95.373%
-8+: 93.822%
-7+: 91.805%
-6+: 89.194%
-5+: 85.852%
-4+: 81.605%
-3+: 76.281%
-2+: 69.830%
-1+: 62.391%
0+: 54.222%
1+: 45.773%
2+: 37.605%
3+: 30.165%
4+: 23.714%
5+: 18.388%
6+: 14.145%
7+: 10.802%
8+: 8.191%
9+: 6.174%
10+: 4.624%
11+: 3.444%
12+: 2.556%
13+: 1.894%
14+: 1.399%
15+: 1.031%
16+: 0.755%
17+: 0.553%
18+: 0.404%
19+: 0.295%
20+: 0.215%
21+: 0.156%
22+: 0.113%
23+: 0.082%
24+: 0.060%
25+: 0.043%
26+: 0.031%
27+: 0.023%
28+: 0.016%
29+: 0.012%
30+: 0.008%


-Cherry
__________________
Cherry
Reply With Quote
  #2  
Old January 1st, 2004, 01:13 AM

alexti alexti is offline
First Lieutenant
 
Join Date: Dec 2003
Location: Calgary, Canada
Posts: 762
Thanks: 0
Thanked 0 Times in 0 Posts
alexti is on a distinguished road
Default Re: Dominions Dice Roll Chart

Interesting... The chart doesn't exactly match the numbers I got myself. The numbers are quite close though. I would post my formula, but I can't even think of trying to type in HTML

===========================================
Probability of roll of 2 being greater than (%) another roll of 2 by at least:
0000 = 0.542274 (54.227)
0001 = 0.457726 (45.773)
0002 = 0.376093 (37.609)
0003 = 0.301668 (30.167)
0004 = 0.237204 (23.720)
0005 = 0.183916 (18.392)
0006 = 0.141480 (14.148)
0007 = 0.108034 (10.803)
0008 = 0.081930 ( 8.193)
0009 = 0.061737 ( 6.174)
0010 = 0.046242 ( 4.624)
0011 = 0.034446 ( 3.445)
0012 = 0.025564 ( 2.556)
0013 = 0.018930 ( 1.893)
0014 = 0.013990 ( 1.399)
0015 = 0.010305 ( 1.031)
0016 = 0.007552 ( 0.755)
0017 = 0.005520 ( 0.552)
0018 = 0.004034 ( 0.403)
0019 = 0.002948 ( 0.295)
0020 = 0.002151 ( 0.215)
0021 = 0.001560 ( 0.156)
0022 = 0.001130 ( 0.113)
0023 = 0.000819 ( 0.082)
0024 = 0.000594 ( 0.059)
0025 = 0.000431 ( 0.043)
0026 = 0.000310 ( 0.031)
0027 = 0.000223 ( 0.022)
0028 = 0.000161 ( 0.016)
0029 = 0.000116 ( 0.012)
0030 = 0.000084 ( 0.008)
0031 = 0.000060 ( 0.006)
0032 = 0.000043 ( 0.004)
0033 = 0.000031 ( 0.003)
0034 = 0.000022 ( 0.002)
0035 = 0.000016 ( 0.002)
0036 = 0.000011 ( 0.001)
0037 = 0.000008 ( 0.001)
0038 = 0.000006 ( 0.001)
0039 = 0.000004 ( 0.000)
Reply With Quote
  #3  
Old January 1st, 2004, 05:52 AM
Saber Cherry's Avatar

Saber Cherry Saber Cherry is offline
Major General
 
Join Date: Oct 2003
Location: Crystal Tokyo
Posts: 2,453
Thanks: 0
Thanked 0 Times in 0 Posts
Saber Cherry is on a distinguished road
Default Re: Dominions Dice Roll Chart

Quote:
Originally posted by alexti:
Interesting... The chart doesn't exactly match the numbers I got myself. The numbers are quite close though. I would post my formula, but I can't even think of trying to type in HTML
Well, they're the same to 4 digits, which is about all I'd expect with 200 million rolls. You actually have a statistical formula that predicts the outcome, without simulation? That would be quite useful and speed up the combat simulator a lot

Oh... also... it seems that the rounding of the Last digit may differ... all my numbers are rounded up for 5-9, and down for 0-4.

[ January 01, 2004, 03:55: Message edited by: Saber Cherry ]
__________________
Cherry
Reply With Quote
  #4  
Old January 1st, 2004, 07:21 AM

alexti alexti is offline
First Lieutenant
 
Join Date: Dec 2003
Location: Calgary, Canada
Posts: 762
Thanks: 0
Thanked 0 Times in 0 Posts
alexti is on a distinguished road
Default Re: Dominions Dice Roll Chart

Quote:
Originally posted by Saber Cherry:
quote:
Originally posted by alexti:
Interesting... The chart doesn't exactly match the numbers I got myself. The numbers are quite close though. I would post my formula, but I can't even think of trying to type in HTML
Well, they're the same to 4 digits, which is about all I'd expect with 200 million rolls.
Maybe the difference is down to the random number generator you're using. Pseudo-random number generator does not give exactly correct distribution, I wonder if you'd get a bit different results with another RNG.

Quote:
You actually have a statistical formula that predicts the outcome, without simulation? That would be quite useful and speed up the combat simulator a lot
Yes, here's it:

A(m): { n1, n2: n1+n2=m, where n1,n2 independent illwinter dice rolls }
pA(m) = (q^(u+1))*{u(6-v(1-q)-q)+q(v-1)}, where u and v, such that m=5u+v and, u>=0 and v=1..5

B(m): { n1, n2: n1+n2>=m, where n1,n2 independent illwinter dice rolls }
pB(m) = (q^(u+1)*{u(20-5(v-1)(14-v)/12)+6-(v-1)(v-2)/12}

D(m): { n1, n2, n3, n4: n1+n2>=n3+n4+m, where n1,n2,n3,n4 independent illwinter dice rolls }
pD(m) = sum[s=1..5-v]f[s,u,s+v] + sum[s=6-v..5]f(s,u+1,s+v-5)
where u and v, such that m=5u+v and, u>=0 and v=1..5
and f(s,u,w) = (q^(u+2)){c2(q^2)*a1(s)*b2(u,w)+c1(q^2)*(a1(s)*b2( u,w)+a2(s)*b1(w))+c0(q^2)*a2(s)*b2(u,w)},
and
a1(s) = 6-s(1-q)-q
a2(s) = q(s-1)
b1(w) = 20 - 5(w-1)(14-w)/12
b2(u,w) = u*b1(w) + 6 - (w-1)(w-2)/12
c0(q) = 1/(1-q)
c1(q) = q/((1-q)^2)
c2(q) = (q+q^2)/((1-q)^3)

Hard to write formulas here I had to be creative in a few places. Hopefully it's understandable. For interested, I was just writing sequences of probabilities of various outcomes, writing roll results in 5u+v form and then getting summing by v in from of summing by u, summing by u is from 0 to infinity so I could roll it in (see c0,c1,c2 constants) and only leave summing from 1 to 5.

If you want I can send you code that implements it too.

Quote:
Oh... also... it seems that the rounding of the Last digit may differ... all my numbers are rounded up for 5-9, and down for 0-4.
I'm using double float precision (15 digits) and only round when outputing the text, rounding is mathematical (same as yours).

P.S. Edited: fixed missed parametrization of Ci(q)

[ January 01, 2004, 05:58: Message edited by: alexti ]
Reply With Quote
  #5  
Old January 1st, 2004, 08:39 AM
Saber Cherry's Avatar

Saber Cherry Saber Cherry is offline
Major General
 
Join Date: Oct 2003
Location: Crystal Tokyo
Posts: 2,453
Thanks: 0
Thanked 0 Times in 0 Posts
Saber Cherry is on a distinguished road
Default Re: Dominions Dice Roll Chart

In contrast, my inexact code is quite short=)

For a single open or closed die:
code:
	//rolls a closed die, "sides" sides, numbered (low) to (low+sides-1)
private int rollDie(){return rand(sides)+low;}

//rolls an open die
private int rollDieOpen(){
face=total=rollDie();
while(face>=high){total+=(face=rollDie());}
return total;
}

//returns a random number, 0 to max-1
private int rand(int max){return (randy.nextInt()&mask)%max;}

Unfortunately, I do not know how slow the pseudorandomizer is, so I don't know how much avoiding it would help. I was considering pregenerating a lookup table that I could reference with a single random number, instead of multiple random numbers like 2d6*-2d6* simulation requires... but the table would be huge to be accurate. A table covering 99.999% of rolls would need 100,000 bytes, which would hurt Cache performance. Alternately, storing the probability table you provided and looking up the value would require minimum n(log(n)) steps to look up a roll from a probability.

A single formula, in this form:

code:
int convertTo2d6roll(double probability){
return something;
}

...assuming the code was fairly short...

...would speed up things a lot.

Of course, the ultimate distribution would still be entirely dependant on Java's pseudorandomizer

However, from examining what you wrote below, which I do not very much understand (but I think I should if I remembered my stats class)... it looks like it has a lot of expensive double-precision floating point division.

Regardless of speed, I would love to see code that implements it, if you have time! And I'll try to figure out what you wrote below, tomorrow=)

-Cherry

P.S. To post code on these forums: Use ["code"] blah blah ["/code"] format. Without the quotes
__________________
Cherry
Reply With Quote
  #6  
Old January 1st, 2004, 04:34 PM
Whismerhill's Avatar

Whismerhill Whismerhill is offline
Corporal
 
Join Date: Nov 2003
Posts: 70
Thanks: 0
Thanked 0 Times in 0 Posts
Whismerhill is on a distinguished road
Default Re: Dominions Dice Roll Chart

>>>>haven't understood the smallest part of alexi code
Reply With Quote
Reply

Bookmarks


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 10:45 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2025, Shrapnel Games, Inc. - All Rights Reserved.