Original Post
I'm trying to write a stat rolling system in C++ that allows the user to choose to re-roll their stats continuously, but I can not find an algorithm for this. I planned for the limitations on the stats to be: -4 different types -the total of all 4 must equal 30 -4 points is the minimum allowed for a stat -10 points is the maximum allowed For Example: Total points available: 30 Random Roll 1: Stat1 - 10 Stat2 - 7 Stat3 - 9 Stat4 - 4 The overly simplistic code I had originally thought would just roll a random 4-10 for the first 3 stats, then make the remaining points go into stat4. The obvious problem is that you could have a combination that could end up in: Stat1 - 10 Stat1 - 4 Stat2 - 10 Stat2 - 4 Stat3 - 10 Stat3 - 4 Stat4 - 0 Stat4 - 18 Or something similar where the last stat would be higher than 10 or lower than 4. Does anyone have a reference or any comments on how to implement this algorithm?