ID:152276
 
While brainstorming systems in a game I am slowly making, I have realized that I like to overcomplicate the math used in games.

I am contemplating using bell curves to balance the game along with sigmoid functions to provide a nice way to determine experience distribution. (When a player beats another player, the level of the winner is used as the inflection point of the graph and then the other players level if evaluated based on that function and the result is the amount, (or multiplier) of experience the winner receives)

Sigmoid: http://en.wikipedia.org/wiki/Sigmoid_function

I know this probably does not make sense, but it works pretty well. Does anyone else over complicate things?

(I know that you can get around normal distribution by using multiple "die rolls" just like to use the equations behind it ex: 2d6 has a less random distribution then 1d12, results are favored towards the average)
Drumersl wrote:
I know this probably does not make sense, but it works pretty well. Does anyone else over complicate things?

(I know that you can get around normal distribution by using multiple "die rolls" just like to use the equations behind it ex: 2d6 has a less random distribution then 1d12, results are favored towards the average)

Sigmoids are a great tool for cases like this. Dan was a big proponent of them himself in his Nightsoil system.

If you're into using bell curves, another good choice is using Gaussian random numbers, which follow a normal distribution. If you want it more like a pen-and-paper system, then you can really just get the equivalent with multiple die rolls. Fudge dice are also a nice idea.

Lummox JR
They seem pretty neat, I was wondering if this formula is correct,

proc
sigmoid(x,y,z)
x = ((x/y*2-1)*z*5
return 1/(1+(-x**2))
In response to Xx Dark Wizard xX
Xx Dark Wizard xX wrote:
They seem pretty neat, I was wondering if this formula is correct,

> proc
> sigmoid(x,y,z)
> x = ((x/y*2-1)*z*5
> return 1/(1+(-x**2))
>


Nope.

A sigmoid really only has two potential variables: The base, and x. The base actually can be changed merely by scaling x, so really it all boils down to x. The official sigmoid is ex/(1+ex), or 1-1/(1+ex), or 1/(1+e-x).

Since exponentiation by e isn't really defined in BYOND, though you could always define it, you can always stick with simpler bases like 2. A sigmoid of base 2 would be very easy to define as 1/(1+0.5**x). One nice feature of base 2 is that for small values of x (-2 to 2) you get very familiar fractions: 1/5, 1/3, 1/2, 2/3, 4/5. For base 3 you get a similar effect with 1/10, 1/4, 1/2, 3/4, 9/10.

Lummox JR
In response to Xx Dark Wizard xX
I tend to use:
a/(1+10^(-b*x+c*b))=y

Because e isnt defined I use 10. Which now that I think about it, it would probably be better to use a smaller number...

a = the range between the upper boundary and the lower one. So if you want numbers between 0 and 10, you would use a=10.

b = how gradual you want the slope to be [0,inf]. The larger the b the steeper the overall slope will be. For a gradual slope, I tend to use something like 1/100.

c = The inflection point. (I use this as the winner’s level)

x = The variable on the curve you want to evaluate. (I use this as the loser’s level)
In response to Lummox JR
Thanks for your input. I had never heard of Fudge dice and I just looked them up. It sounds like an interesting concept.

Do you know of any good Gaussian random number algorithms?
In response to Lummox JR
I was using where x = base, y = scale whereas 1 would be normal and z = steepness whereas 1 would be normal also.
In response to Xx Dark Wizard xX
Xx Dark Wizard xX wrote:
I was using where x = base, y = scale whereas 1 would be normal and z = steepness whereas 1 would be normal also.

Well scale and steepness are intertwined; you can't really affect one without the other. But the biggest problem was your x**2 term, which should've been base**x.

Lummox JR
In response to Drumersl
Drumersl wrote:
Thanks for your input. I had never heard of Fudge dice and I just looked them up. It sounds like an interesting concept.

Do you know of any good Gaussian random number algorithms?

I posted one in [link]:

proc/GaussRand()
var/x,y,rsq
do
x=2*rand()-1
y=2*rand()-1
rsq=x*x+y*y
while(rsq>1 || !rsq)
return y*sqrt(-2*log(rsq)/rsq)


This calculation actually returns two Gaussian random numbers, if you use x*sqrt(-2*log(rsq)/rsq) as well, but you can't return them both from the proc.

Lummox JR
In response to Lummox JR
I notice that returns resuluts with an average range of about 6. (from -3 to 3, but of course it varies)

Is there a way to change the range?

Say I wanted to have the majority of the numbers centered around 10.

I found this, but I do not quiet understand the answer the person provides on the site. (Specifically the use of the "~" ) I know mu is the mean and sigma is the standard deviation.

http://www.linuxquestions.org/questions/ showthread.php?t=215942

Thank you for all your help.
In response to Drumersl
Drumersl wrote:
I notice that returns resuluts with an average range of about 6. (from -3 to 3, but of course it varies)

Is there a way to change the range?

Say I wanted to have the majority of the numbers centered around 10.

Add 10 to the result you get? =) Or if you want to scale it you can multiply it by some number beforehand.

Been a while since I did statistics, but I would guess that X~N(mu,sigma) means something like "X is an experiment (in this case, an experiment correponds to running the random number generator once) from the normal distribution with mean mu, std.ev. sigma".
In response to Drumersl
Drumersl wrote:
I notice that returns resuluts with an average range of about 6. (from -3 to 3, but of course it varies)

Yep, because Gaussian random numbers should form a normal curve with 1 as their standard deviation. Values outside ±3 are possible, but should be rare. About 75% of your values should fall within ±2.

Is there a way to change the range?

Say I wanted to have the majority of the numbers centered around 10.

Yep! Add 10.

I found this, but I do not quiet understand the answer the person provides on the site. (Specifically the use of the "~" ) I know mu is the mean and sigma is the standard deviation.

He's using ~= as a shorthand for ≅ which means approximately equal.

Basically, figure out the range of numbers you want to get almost all of the time. Divide that entire range by 6; you'll get the standard deviation. Now multiply the standard deviation by GaussRand(), and add the center of your desired range.

Lummox JR
In response to Lummox JR
Thanks for all your help.