Smoothing the combat curve

oh yeah, you'll need to chuck in another couple of lines to save a potential array out of bounds error.

N=round(100/base_Dammage); //rounded to the nearest integer
if (N==0){
N=1;
return 1; //probability of needing 1 hit to kill is 100%, as you always need at least one hit, even if you are doing over 200 damage/hit.
}
naturally you can't kill someone with half a hit if you are doing more than 200 damage/hit in some extreeme combat ratio situation(i doubt this'll come up often). so it's best to save this potential array out of bounds error.

Note that the present range of damage is 6..59, as far as I can tell.
 
Note that the present range of damage is 6..59, as far as I can tell.

that means we can use array length 17 for the 6 damage case. although it's probably good to make the code robust in case people start modding their code and changing dammage values etc.
 
Sorry if the thoughts are a bit disjoint :D

I think I have a solution which is faster than the one I propose above. Essentially, I view each die as a finite dimension, in a geometry where only movements parallel to the directions of the dimensions are valid. Then, each value of the dice is a constant distance from the origin, and the sum of those and lesser values can be obtained through the integral under the curve of all points of that constant distance (back to the origin).

The advantage of using such a geometry in N-space is largely that it makes visualization of what components are useful from one calculation to the next....

Wait - I'm being stupid, aren't I - these are just the N-spacial icosahedral numbers, aren't they? In 2-space, with evenly sized dice, they'd be:
X*(X+1)/2
In 3-space, they'd be:
X*(X+1)*(X+2)/6
So in general, they're:
Where A = the number of dice,
(X*(X+1)*(X+2)*...*(X+A-3)*(X+A-2)*(X+A-1))/(A*(A-1)*(A-2)*...3*2*1)

This obviously only works directly to the mid-way point, but the same series can be used to calculate beyond this point- it merely needs to be used multiple times - once for a superset of the N-space we want to use, then once for each portion of that set we aren't planning to use. Since the maxima is inside the set we're planning to use, we don't need to worry about the overlap beyond that point.

I think that this can even be used for non-evenly sized dice, but I'll have to work at that more. In any case, a direct equation around the order of the square of the number of dice is far better than I expected to be able to obtain.
These are not discrete numbers, so they shouldent be referred to as "icosahedral numbers" or “dice”.

What we are talking about is obtaining a cumulative distribution function of sumation of multiple factors with continuous uniform distribution.

Now for the situation with 2 random numbers we have a triangular distribution case.
If we normalize to get x=random_number_required/random_range. So 0<=x<=1

Therefore we get a probability density function
f(x)=4x for 0<=x<=0.5
f(x)=4-4x for 0.5<=x<=1

and integrating for the cumulative distribution function
F(x)= 2*x^2 for 0<=x<0.5
F(x)= 1-2(1-x)^2 for 0.5<=x<=1
This is for P(X<x)

we also have E(X)=0.5
and Variance(X)=1/24

Now if we want to create a probability_over(x) function then we are looking at the opposite than the probability under.
F(x)= 1-2*x^2 for 0<=x<0.5
F(x)= 2*(1-x)^2 for 0.5<=x<=1

If you want to go for 3 or more random values then a n&#8217;th dimensional spherical distribution function can be used.
 
Back
Top Bottom