[Tutor] AD&D Character generator problems

Blake Winton bwinton@tor.dhs.org
Wed, 5 Apr 2000 09:23:49 -0400


* Borgulya Gabor <borgulya@pons.sote.hu> [000405 07:39]:
> stats= {'str': 0, 'dex': 0, 'con': 0, 'int': 0, 'wis': 0, 'cha': 0}
> def MakeStats():
>     for stat in stata.keys():
                  ^^^^^
This should probably be "stats", not "stata".  (Typo)

>         stats[stat]= random.randint(3, 18)

And while I'm here, I might as well commment on this line.  In AD&D, to
get an stat for a character, you used to roll 3 6-sided dice.  While
it's true that would give you a number between 3 and 18, the
distribution of values would be very different than the distribution you
get from the above code.  (i.e. in the code above, you have a 1 in 15
chance of getting a 3, but with dice, you have a 1 in 216 chance.)

So for more accurate stats, you might want to change the line to
        stats[stat] = random.randint(1,6)
                      + random.randint(1,6)
                      + random.randint(1,6)

Or, move that into a function called, say, GenerateSingleStat, which
would return an integer.  That way, if you decide to switch the
algorithm later (to roll four dice, and take the best three, for
instance), you know where to find it.

Later,
Blake.
-- 
9:12am up 7 days, 9:46, 1 user, load average: 0.32, 0.07, 0.02