Originally Posted by

**brewbuck**
The sum of multiple dice rolls is equivalent (well, only roughly) to drawing values from a Gaussian distribution. So you can do it with a single call to rand(), but the expression is a bit more complex.

Yeah, one rand() call will give the wrong distribution - flat.

Try something like the above roll function, but I'd optimise all those +1's:

Code:

int roll(int sides, int num_dice)
{
int sum = num_dice;
for( int i = 0; i < num_dice; ++i)
sum += rand() % sides;
return sum;
}
/* ... */
int playerHealth = roll( 10, 5 );