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

This Month's Specials

Air Command 3.0- Save $12.00
War Plan Pacific- Save $7.00

   







Go Back   .com.unity Forums > Illwinter Game Design > Dominions 3: The Awakening

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #12  
Old May 11th, 2008, 09:23 PM
lch's Avatar

lch lch is offline
General
 
Join Date: Feb 2007
Location: R'lyeh
Posts: 3,861
Thanks: 144
Thanked 403 Times in 176 Posts
lch is on a distinguished road
Default Re: Maths problem: fatigue vs critical hits

Quote:
cleveland said:
Here's roughly what I did:
1) Constructed a vector A(i) of the explicit probabilities for each single drn outcome i. This is pretty straightforward:
A(1)=A(2)=...=A(5)=1/6
A(6)=A(7)=...=A(10)=(1/6)^2
Etc.
I think this is already where I fail, because the rest is pretty much the same. I was jumping back and forth between modulo 5 and modulo 6 just because the whole thing is offset by 1 and the gaps didn't work out. Let's correct this now...

Let X-1 = 5a + b, 0 <= b < 5. (notice the -1!!) Then the probability that a DRN gives exactly X is p(DRN = X) = (1/6)^(a+1).
The probability that it is X or greater is:


Now, we have two ways of measuring all the (x,y) in IN x IN which sum is equal to or greater than X: Either we take all the (x,y) with x+y < X and subtract the probability of them showing up simultaneously from 1, thus inverting the set, like you did if I understood right, or measure the following (with a loose mathematical notation): Code:
  (1, >= X-1)
(2, >= X-2)
(3, >= X-3)
... etc.
(X-1, >= 1)
(>= X, *)


which should be equal to {(x,y) | x+y >= X}. I implemented both versions in Python again: Code:
#!/usr/bin/env python

# p(DRN) >= x
def p_1(x):
if x < 1:
return 1
b = (x-1) % 5
a = (x-1) / 5
return (6-b)*pow((float(1)/6), a+1)

# p(DRN) == x
def p_2(x):
if x < 1:
return 0
b = (x-1) % 5
a = (x-1) / 5
return pow((float(1)/6), a+1)

# p(2d6oe) >= x
def doubledrn(x):
M = [(a,b) for a in range(1,x-1) for b in range(1,x-a)]
s = 0.0
for (x_1, x_2) in M:
s += p_2(x_1)*p_2(x_2)
return 1-s

# p(2d6oe) >= x (alternate version)
def doubledrn_2(x):
s = p_1(x)
for y in range(1,x):
s += p_2(y)*p_1(x-y)
return s

for x in range(2,20):
print ">= %2d : %f" % (x, doubledrn(x))
print ">= %2d : %f" % (x, doubledrn_2(x))

and huzzah, they both give the same result, and it is: Code:
>=  2 : 1.000000
>= 3 : 0.972222
>= 4 : 0.916667
>= 5 : 0.833333
>= 6 : 0.722222
>= 7 : 0.583333
>= 8 : 0.462963
>= 9 : 0.361111
>= 10 : 0.277778
>= 11 : 0.212963
>= 12 : 0.166667
>= 13 : 0.127315
>= 14 : 0.094907
>= 15 : 0.069444
>= 16 : 0.050926
>= 17 : 0.039352
>= 18 : 0.029578
>= 19 : 0.021605


__________________
Come to the Dom3 Wiki and help us to build the biggest Dominions-centered knowledge base on the net.
Visit my personal user page there, too!
Pretender file password recovery
Emergency comic relief
Reply With Quote
 

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 12:26 AM.


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