Game Development Reference
In-Depth Information
Naturally, we can skew curves in the other direction as well. If we need to re-
create the example of household income mentioned earlier in this chapter, we
would create a distribution curve that is heavily skewed to the left. This would in-
dicate that the bulk of the households have a relatively low income but still allow for
the likes of Bill Gates and Warren Buffet on the extreme right end.
P UTTING I TIN C ODE
The code necessary to roll multiple dice and then remove one or more is slightly
more complicated. The reason for this is that we need to keep track of all the roll
results until the end. We can't simply add them together as we go. If we know that
we are only going to be removing one die result, we can keep track of the highest or
lowest roll (depending on which direction we are skewing the curve), add the rolls
as we go along, and then add or subtract the stored value from the total of the rolls.
While this will certainly work, we would be limiting ourselves to only skewing by
one factor. For example, we could perform “4d6, drop the lowest� but not “5d6,
drop the lowest two .�
By extending our multiple dice function above, we can make it account for sit-
uations where we want to skew the curve. It will handle skews of both directions (or
no skew at all) and an arbitrary number of dice.
typedef enum {
SKEW_NONE,
SKEW_RIGHT,
SKEW_LEFT
} SKEW_TYPE;
unsigned short CDie::MultipleDie(
unsigned short NumDie,
unsigned short NumSides,
bool ZeroBased /*= true */,
SKEW_TYPE SkewDirection /*= SKEW_NONE*/,
unsigned short SkewCount /*= 0*/ )
{
// Vector container to hold our die rolls
std::vector<unsigned short> vRolls;
Search WWH ::




Custom Search