Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Gaussian distribution RNGs for RLs?

16 views
Skip to first unread message

copx

unread,
Jan 6, 2009, 6:02:11 PM1/6/09
to
What do you think of the idea of using RNG functions
whose output shows Gaussian distribution instead of the
standard uniform distribution for things like damage?

Gaussian distribution means that the results in the
middle of the range will be most common with extremes
being rare (i.e. the infamous bell curve).

I never thought about this before but it seems to
me this makes more sense than uniform distribution
for most game mechanics. I mean very good hits and
very bad hits should be rarer than average hits, right?


Sir_Lewk

unread,
Jan 6, 2009, 6:09:57 PM1/6/09
to

I never really thought of that but I guess that does make sense. I'd
just be wary of making combat too consitent and boring.

regrads.

Nate879

unread,
Jan 6, 2009, 6:22:10 PM1/6/09
to
D Notation (http://nethack.wikia.com/wiki/D_notation) approximates a
Gaussian Distribution. It's common for Roguelikes to use it. Nethack
uses it extensively.

copx

unread,
Jan 6, 2009, 6:22:56 PM1/6/09
to

Well, its a matter of perspective you could either
call it "consistent and boring" or "realistic" :P

copx

unread,
Jan 6, 2009, 6:47:50 PM1/6/09
to

Depends on how you implement your dice roller..
In Warp Rogue I implemented it so that something
like dice(2,6) translated to random_int(2, 12)
because its faster, and I wasn't even aware
of the distribution issue back then.

But yeah, if you actually let your dice roller
roll separate dice than the result gets closer
and closer to gaussian distribution as the
number of dice increases.

Something to be aware of at least.

msa...@gmail.com

unread,
Jan 6, 2009, 7:19:34 PM1/6/09
to
On Jan 6, 6:09 pm, Sir_Lewk <SirL...@gmail.com> wrote:
>
> I never really thought of that but I guess that does make sense.  I'd
> just be wary of making combat too consitent and boring.

This isn't actually a problem if you make your standard deviations
large enough. As long as you can produce a wide range of values for
each roll you can still make tests against a target number that is
significantly higher than your average. For instance, if you
distribution is mean 20 and standard deviation 10 you will still hit
30 target numbers 15% of the time.

Using a gaussian is not much different from games where you use a sum
of multiple dice for each test. Gurps, which is very similar to D&D/
d20 except that you roll 3d6 instead of 1d20, comes immediately to
mind. In these systems the average is far more likely than the
outliers (a classic example is how much more common it is to roll a 7
on 2d6 than a 2 or 12).

You will have to balance your game a bit around it. Games with uniform
number generators have a property that weak enemies in mobs can pose a
threat because they can gamble on getting a few lucky hits (think of
10 goblins with no to-hit bonus swinging at a player with an AC of
18.... on average one will still hit every turn). Its not bad to lose
this, but you do have to be considerate of it when you design the game.

Lorenzo Gatti

unread,
Jan 7, 2009, 9:20:31 AM1/7/09
to
On Jan 7, 1:19 am, msal...@gmail.com wrote:
> Using a gaussian is not much different from games where you use a sum
> of multiple dice for each test.

There is a substantial difference even if the pdf is close: sums of
"dice" fall within a predetermined and controllable interval, while a
gaussian distribution isn't bounded.
Any value can be produced with a very low probability; in particular,
negative values are possible. This is the sort of unlikely special
case that can cause complications.

Regards,

Lorenzo Gatti


msa...@gmail.com

unread,
Jan 7, 2009, 10:01:10 AM1/7/09
to
On Jan 7, 9:20 am, Lorenzo Gatti <ga...@dsdata.it> wrote:
>
> There is a substantial difference even if the pdf is close.

Well, statistically, yes, but practically, no. I don't think that the
fact that gaussian is continuous (as opposed to discrete) and can
produce very high or low values (relative to the standard
distribution) has much practical impact on game design.

Perdurabo

unread,
Jan 7, 2009, 10:09:49 AM1/7/09
to

I'd be very careful before summoning the ghost of 'realism' and
inviting it over the threshold of the Roguelike House. That way lies
madness and flame-wars.

Implementing a Gaussian distribution would blunt the fangs of the RNG
to an extent, which may or may not be such a good thing.

Best,
P.

Gerry Quinn

unread,
Jan 7, 2009, 11:24:45 AM1/7/09
to
In article <gk0nto$a6o$1...@inews.gazeta.pl>, co...@gazeta.pl says...

Gameplay is more important than realism. That is the most important
thing to remember. If Gaussians give better gameplay, use Gaussians.
If lat distributions work better, use them.

It's also not true that everything tends towards a Gaussian
distribution. The sum of multiple random variables does, but their
product, for example, does not.

And I wouldn't expect the damage done by a sword in practice to be
either a Gaussian or any of the distributions used in roguelikes. in
practice it would do massive damage occasionally (i.e. when blocking
failed). This would be bad for roguelike gameplay, so it doesn't
happen.

- Gerry Quinn
--
Lair of the Demon Ape (a coffee-break roguelike)
<http://indigo.ie/~gerryq/lair/lair.htm>

Risto Saarelma

unread,
Jan 7, 2009, 11:35:06 AM1/7/09
to
On 2009-01-06, copx <co...@gazeta.pl> wrote:
> I never thought about this before but it seems to
> me this makes more sense than uniform distribution
> for most game mechanics. I mean very good hits and
> very bad hits should be rarer than average hits, right?

Is there any way to test or quantify whether the effect is actually
perceptible to the player and if it is, how does it make the actual
gameplay feel different?

For what it's worth, out of the well-known pen & paper RPG systems, D20
uses an uniform distribution and Gurps approximates a Gaussian
distribution with 3d6. Here are some notes on converting D20 to use 3d6
for resolution:
http://www.d20srd.org/srd/variant/adventuring/bellCurveRolls.htm

I'm not sure that a Gaussian distributions would necessarily be a good
thing from a gameplay viewpoint. A distribution clustered around the
center (boring) with the odd outlier (oneshotted by a kobold) doesn't
initially seem as fun as a building things around an uniform
distribution where the unusual things happen more often. Then again, it
might make the outlier events more memorable and interesting.

Ray Dillinger

unread,
Jan 7, 2009, 1:29:17 PM1/7/09
to
copx wrote:

> What do you think of the idea of using RNG functions
> whose output shows Gaussian distribution instead of the
> standard uniform distribution for things like damage?

For damage, most roguelikes already use near-gaussian
distributions in the forms of sums of die rolls. But
most use a linear distribution when determining hits.

Anyway, you'll need to chop off the "long tail" of the
Gaussian distribution to avoid generating negative
damage numbers, or else fix your combat routines to
ignore or use them. If you want to use Gaussian
distributions for hit rolls, maybe negative numbers
correspond to fumbles? It's up to you.

> Gaussian distribution means that the results in the
> middle of the range will be most common with extremes
> being rare (i.e. the infamous bell curve).

> I never thought about this before but it seems to
> me this makes more sense than uniform distribution
> for most game mechanics. I mean very good hits and
> very bad hits should be rarer than average hits, right?

I dunno. If your priority is realism about battle
wounds, talk to an army doctor about what the range of
"typical" combat trauma is like. It may look nothing
like gaussian distributions. But if your priority
is making a good game, your time may be better spent
talking to players about what they liked and disliked
and observing what keeps them engaged in the game.

Bear

Xecutor

unread,
Jan 8, 2009, 2:37:14 AM1/8/09
to
On 7 янв, 05:02, copx <c...@gazeta.pl> wrote:

Speaking of RNG.
Here is transformation of uniform RNG, that
have distribution like this:
|\
| \
| \
| \
| \
| \
| \
| \
----------
0 1

Probability of value in range (0..0.1] is approximately 10x higher
than in range [0.9..1.0].

double x=rnd.getDouble();
static const double c1=sqrt(1.0/1.02+0.006);
static const double c2=c1-sqrt(0.006);
x=(c1-sqrt(x/1.02+0.006))/c2;

However after transformation range is (0,1] instead of [0,1)

I use this transformed RNG to roll quality of items depending on depth
of dungeon.

Message has been deleted

David Damerell

unread,
Jan 8, 2009, 11:51:17 AM1/8/09
to
Quoting copx <co...@gazeta.pl>:

>Sir_Lewk wrote:
>>I never really thought of that but I guess that does make sense. I'd
>>just be wary of making combat too consitent and boring.
>Well, its a matter of perspective you could either
>call it "consistent and boring" or "realistic" :P

Since when was realism a good thing, and since when was average damage
realistic? If you want realism, most wounds in single combat should be
either trivial or fatal (inasmuch as any serious injury will cause your
opponent to finish you off if there's no-one around to help you).
--
David Damerell <dame...@chiark.greenend.org.uk> flcl?
Today is First Olethros, January - a weekend.

Jotaf

unread,
Jan 8, 2009, 12:45:33 PM1/8/09
to
IIRC, 97.5% of the values that occur are within the range
[-3*deviation, +3*deviation]. So you can easily make an attack that
most of the time deals values between 10 and 20 hp, with the odd
critial hit/critical failure. Also I like the idea of negative values
representing bad failures! But maybe it would be too harsh on new
characters.

Jotaf

Bongo Bill

unread,
Jan 10, 2009, 12:30:44 AM1/10/09
to
On the subject of alternate distributions for random number
generation, I've seen a system used that isn't quite Gaussian but is
food for thought. The game makes the player aware of a probability to
hit between 0% and 100%, but in reality, it generates two random
numbers between 0% and 100% and compares their mean against the target
value, making unlikely outcomes less likely and likely outcomes more
likely.

Raymond Martineau

unread,
Jan 10, 2009, 10:30:21 AM1/10/09
to
On Wed, 7 Jan 2009 06:20:31 -0800 (PST), Lorenzo Gatti
<ga...@dsdata.it> wrote:

>On Jan 7, 1:19 am, msal...@gmail.com wrote:
>> Using a gaussian is not much different from games where you use a sum
>> of multiple dice for each test.
>
>There is a substantial difference even if the pdf is close: sums of
>"dice" fall within a predetermined and controllable interval, while a
>gaussian distribution isn't bounded.

True, although you can easily create a wrapper function that ensures
that no value is beyond ~3-4 standard deviations if you sense a small
stick could take out a DeathStar in one hit.

This is "safe" since anything past 4 standard deviations is too rare
to consider, and probably could result in a form of scumming.

Gerry Quinn

unread,
Jan 10, 2009, 11:22:35 AM1/10/09
to
In article <cb39987b-f70c-4619-b172-
a1144f...@s9g2000prm.googlegroups.com>, Bong...@gmail.com says...

That's the same as using two dice - it gives a triangular distribution.
It's a step in the series leading towards a Gaussian distribution -

1 die gives a flat distribution
2 dice give a triangular distribution with a peak in the middle
3 dice give a distribution that already looks a bit bell-shaped

Indeed, the triangle is probably quite adequate for most games in which
the uniform distribution is too flat.

There are other systems. In my game weapons do a flat 50% of damage
plus a uniformly distributed fraction of the remaining 50%. My logic
was that in a game with no free health regeneration, it was good to
allow the player situations in which he can be certain of a kill.

Jotaf

unread,
Jan 13, 2009, 3:04:25 PM1/13/09
to
On 10 Jan, 16:22, Gerry Quinn <ger...@indigo.ie> wrote:
> That's the same as using two dice - it gives a triangular distribution.  
> It's a step in the series leading towards a Gaussian distribution -
>
> 1 die gives a flat distribution
> 2 dice give a triangular distribution with a peak in the middle
> 3 dice give a distribution that already looks a bit bell-shaped
>
> Indeed, the triangle is probably quite adequate for most games in which
> the uniform distribution is too flat.

That makes sense. Actually now I'm convinced that a "triangle-shaped
distribution" is even better than white noise or gaussian noise.

> There are other systems.  In my game weapons do a flat 50% of damage
> plus a uniformly distributed fraction of the remaining 50%.  My logic
> was that in a game with no free health regeneration, it was good to
> allow the player situations in which he can be certain of a kill.

This is the same as shifting your distribution to the right.

I think that the most intuitive way to go about it is to define a mean
value (average) and a max variation value. With a system like "50%
fixed damage, 50% roll" you still have to run some calculations off
the top of your head, but with mean+variation you know you can score
40dmg (mean) most of the time, plus or minus 10dmg depending on your
luck.

---

A related topic is how should the distribution vary with the gameplay?
Should we always use the same distribution for every calculation?

Maybe regular weapons could use triangle or gaussian (reflecting
natural distributions), and magic tend more towards extreme values,
using plain random values within wide ranges (feeling a bit more
unpredictable). I didn't give much thought to other actions like lock-
picking, or ranged combat vs. melee. Anyway, players are good at
estimating the variance of an effect given a few samples, and magic
would feel much more unpredictable than standard weapons.

Another thing is how damage evolves with the player's level. Advancing
in level could not only increase the average damage dealt, but also
reduce the variation. Skilled fighters can deal the same damage
repeatedly with small chance of mistake, while inexperienced fighters
will have either lucky breaks or complete failures.

Jotaf

rdc

unread,
Jan 13, 2009, 6:19:13 PM1/13/09
to

"Jotaf" <jot...@hotmail.com> wrote:
> A related topic is how should the distribution vary with the gameplay?
> Should we always use the same distribution for every calculation?

One thing that comes to mind is changing the distribution based on the skill
of the player. If a player is unskilled with a weapon or magic or whatever,
use a linear distribution to reflect the wild variance you have with a
rookie. As the player advances in skill switch over to triangular and
finally Gaussian to reflect the the mastery the player has with the weapon
or spell.

You could actually mix and match this with the same character. If he is
proficient with a sword, you use Gaussian. However, he isn't that good with
a Halberd so you use triangular. He's terrible with a flail so you use
linear.

rdc

r.sh...@gmail.com

unread,
Jan 13, 2009, 6:36:58 PM1/13/09
to
If you really want pseudorandom Gaussian numbers, the Box-Muller
transformation takes two independent values x1, x2 from a uniform
(0,1) distribution, and returns two independent values from a normal
(0,1) distribution

y1 = sqrt( - 2 ln(x1) ) cos( 2 pi x2 )
y2 = sqrt( - 2 ln(x1) ) sin( 2 pi x2 )

But as others have indicated, the extreme outliers in the Gaussian
might be difficult to balance. If you want to directly specify a mean
and a maximum range of scatter, something like mean + 1d(scatter) - 1d
(scatter) works.

msa...@gmail.com

unread,
Jan 13, 2009, 10:10:43 PM1/13/09
to
On Jan 13, 6:19 pm, "rdc" <rickclar...@gmail.com> wrote:
>
> If a player is unskilled with a weapon or magic or whatever,
> use a linear distribution to reflect the wild variance you have with a
> rookie. As the player advances in skill switch over to triangular and
> finally Gaussian to reflect the the mastery the player has with the weapon
> or spell.

You don't want to do it this way, but it is a neat idea. What I don't
recommend is using different distributions like this. The problem is,
when you use linear for 'bad' and normal for 'good', then a player
that is bad has a better chance of getting very good rolls (if you are
not careful). But if you are using a distribution like a normal, you
can instead increase the mean and reduce the variance of your roll as
you become more skilled.

I play with a similar system when I write my roguelike vaporware.
Basically, each skill point increases the average of your skill rolls
by 1, but also decreases the variance. I use something like the
following formula:

0: 2d10 (mean 11 max 20)
1: 2 + 2d9 (mean 12 max 20)
2: 4 + 2d8 (mean 13 max 20)
3: 6 + 2d7 (mean 14 max 20)

It would be easy to do something similar with normals if you wanted to
(I initially was going to but went with this for ease of explanation).

Gerry Quinn

unread,
Jan 13, 2009, 10:58:35 PM1/13/09
to
In article <a14d68e0-541e-406d-8746-
fa4d80...@p2g2000prn.googlegroups.com>, jot...@hotmail.com says...

> On 10 Jan, 16:22, Gerry Quinn <ger...@indigo.ie> wrote:

> > There are other systems.  In my game weapons do a flat 50% of damage
> > plus a uniformly distributed fraction of the remaining 50%.  My logic
> > was that in a game with no free health regeneration, it was good to
> > allow the player situations in which he can be certain of a kill.
>
> This is the same as shifting your distribution to the right.
>
> I think that the most intuitive way to go about it is to define a mean
> value (average) and a max variation value. With a system like "50%
> fixed damage, 50% roll" you still have to run some calculations off
> the top of your head, but with mean+variation you know you can score
> 40dmg (mean) most of the time, plus or minus 10dmg depending on your
> luck.

Yes, but in Lair every class has a weapon type they never miss with, and
if they have such a weapon that does 10 damage, and there is a nearby
mob with 5 health, they know for sure it will die from one blow and not
be able to hit back. That can matter a lot if you are down to the wire
and have no healing potions or abilities. It matters most to warriors
and archers, obviously.

Not knocking your system, just telling you the way mine works.

rdc

unread,
Jan 14, 2009, 6:45:13 AM1/14/09
to
<msa...@gmail.com> wrote:
> You don't want to do it this way, but it is a neat idea. What I don't
> recommend is using different distributions like this. The problem is,
> when you use linear for 'bad' and normal for 'good', then a player
> that is bad has a better chance of getting very good rolls (if you are
> not careful). But if you are using a distribution like a normal, you
> can instead increase the mean and reduce the variance of your roll as
> you become more skilled.

Very good point. I hadn't thought of that. Your method sounds much more
consistent.

rdc

Gerry Quinn

unread,
Jan 14, 2009, 11:38:40 AM1/14/09
to
In article <a14d68e0-541e-406d-8746-
fa4d80...@p2g2000prn.googlegroups.com>, jot...@hotmail.com says...

> Maybe regular weapons could use triangle or gaussian (reflecting


> natural distributions), and magic tend more towards extreme values,
> using plain random values within wide ranges (feeling a bit more
> unpredictable).

Or vice versa... in my game wands always do exactly X damage, unlike
weapons which have a random element.

It's actually an interesting facet of game design when you think about
it - if your character is going to be on the edge of survival,
deterministic behaviour is a big factor in the value of an item / spell
etc. If instead he can take a few hits before dying, it is much less
important.

My game leans towards determinism, but this is not intrinsically better
or worse than leaning towards randomness, just something that should
match the game style.

Gerry Quinn

unread,
Jan 14, 2009, 11:43:40 AM1/14/09
to
In article <8e6cb251-4f52-4e3c-acbc-4c80f22b17d1
@v15g2000yqn.googlegroups.com>, msa...@gmail.com says...

> I play with a similar system when I write my roguelike vaporware.
> Basically, each skill point increases the average of your skill rolls
> by 1, but also decreases the variance. I use something like the
> following formula:
>
> 0: 2d10 (mean 11 max 20)
> 1: 2 + 2d9 (mean 12 max 20)
> 2: 4 + 2d8 (mean 13 max 20)
> 3: 6 + 2d7 (mean 14 max 20)

That looks pretty good. And of course if you wanted you could ramp up
the effect of skill by increasing the constant by 3 per level (for
example):

0: 2d10 (mean 11 max 20)

1: 3 + 2d9 (mean 13 max 21)
2: 6 + 2d8 (mean 15 max 22)
3: 9 + 2d7 (mean 17 max 23)

msa...@gmail.com

unread,
Jan 14, 2009, 12:51:35 PM1/14/09
to
Gerry Quinn wrote:
> That looks pretty good. And of course if you wanted you could ramp up
> the effect of skill by increasing the constant by 3 per level (for
> example):
>
> 0: 2d10 (mean 11 max 20)
> 1: 3 + 2d9 (mean 13 max 21)
> 2: 6 + 2d8 (mean 15 max 22)
> 3: 9 + 2d7 (mean 17 max 23)

Yeah, to some extent thats exactly what I do. I basically divide each
skill into a 'training' and a 'bonus'. Increasing either by 1 will
increase your average skill roll result by 1. Increasing training
(which was the chart I wrote) also decreases the variance, so that the
more trained you are, the more reliable you are. Increasing the bonus
also increases the maximum by 1, so that the better your bonus is the
more exceptional your results could be.

I can't say its a great idea... naturally having never produced
anything playable enough to release it hasn't had much playtesting.
Certainly, points in your bonus are often worth more than your skill,
in particularly at the high levels. But I think its cute.

Gerry Quinn

unread,
Jan 14, 2009, 1:12:31 PM1/14/09
to
In article <ab75bbbd-ee5f-4910-9492-
b55a0a...@v42g2000yqv.googlegroups.com>, msa...@gmail.com says...

Well, I think it would work... you'd ideally want to be skilled AND
wielding a great weapon.

- Gerry Quinn

0 new messages