I'm working on a personal project to develop a stat generator for Tabletop RPGs like D&D. I need the generated numbers to meet the following criteria:
- The numbers must be within 1 and d (the size of the die).
- The sum of n random numbers must always be (d+1)n\2.
As an example, if d = 20 and n = 6, the sum should be S = 63 and the random numbers should be between 1 and 20. This would mean an average output of something like [10, 11, 10, 11, 10, 11]
The issue of generating numbers with a constant sum is covered in this post, and I'm quite familiar with generating numbers within a certain range, but I wanted to know if there was a simple algorithm that ensured both of these criteria were met.