Skill Distributions

Skill Distributions

Return to topic list

Tue Dec 20 03:53:33 2016   by   JJ
I believe your program should be able to handle this; but have been unable to get the syntax and steps correct. If I have 20 skills and 15 points to spread among them; thats a pretty simple formula. But I have 2 additional wrinkles that are making things harder. 1) you can only raise any particular skill to level 4; AND it cost 1 point get the skill at level 1; and additional point to bring it to level 2; 2 additional points to bring it to level 3 and a final 2 additional points to bring it to level 4. Meaning that the each of the 20 skills will end up with a value of [0,1,2,3,4] for [0,1,2,4,6] points respectively. Is it possible to translate that into something Troll can handle?

Any help would be VERY much appreciated (I've tried multiple times and multiple methods). And if you have any questions or I missed something let me know. Thanks again for the help and awesome program/tool.
Tue Dec 20 10:35:38 2016   by   Torben
I'm not sure what you want.  Do you want to roll random characters where the 15 points are distributed among the 20 skills?  If so, what kind of distribution do you want?  Do you want to randomly pick any of the 20 skills and then add one level if there are enough points left, continuing until the points are spent?  Or do you want to add a random number of levels to the selected skill (up to what you can afford with the remaining points)?

And do you just want to generate random skills, or do you want to calculate probabilities of every possible point allocation?  The latter has an immense number of possible outcomes, so I can't see this being useful (nor realistic to calculate).
Wed Dec 21 02:36:36 2016   by   JJ
I wanted to pick one of the 20 skills, and then pick level 1,2,3,4 for it [costing 1,2,4,6 points respectively] with no skill being re-picked and picking stopping when all 15 skill points are spent. I hope that helps clarify. Thank you.
Wed Dec 21 10:13:53 2016   by   Torben
It does clarify it somewhat.  I don't know if you want level 1--4 with equal probability when you pick,though.  I will assume that you do, below.

Essentially, you want to generate a set of pairs (skill, level), with no skill repeating, and such that the cost equals 15.  Troll can not handle sets of pairs (it can handle pairs of sets, though), so we encode the pair as 10×skill + level, which works because level<10.

The easiest way to do this is by defining a recursive function which takes two arguments: The number of available points and the skills not already picked, and returns the final picks (including levels).  We initially call this with 15 points and the of unpicked skills being {1..20}.

The function stops if there are no points left.  Otherwise, it chooses one of the remaining skills and a random level between 1 and 4.  If there are sufficiently many points for the level, it chooses the skill at this level.  Otherwise, it tries again.  Theoretically, it could keep retrying, but in practice it only takes a few tries before it picks level 1, which will work.  The cost is calculated by picking the nth smallest in the set {1,2,4,6}, where n is the level.  The complete code looks like this:

call allocate(15,{1..20})

function allocate(points, skills) =
  if points = 0 then {} else
    skill := choose skills;
    newskills := skills drop skill;
    level := d4;
    cost := max (least level {1, 2, 4, 6});
    if points >= cost
    then (10*skill + level) U call allocate(points-cost, newskills)
    else call allocate(points, skills) \ try again

It is fairly easy to modify the level costs and the number of available points.  But do not try to calculate probabilities!  There are simply far too many different outcomes.
Thu Dec 22 20:27:12 2016   by   JJ
Thank you VERY much for being able to parse my intent and come back with a very small and elegant solution. My efforts were both MUCH more messy (along with being unsuccessful)

To respond to your question regarding the level choice/probability; there were 2 things I committed from my original post in effort to keep it simplified.

A) I was rolling a D100 for the skill choice and and then mapping the 100 results to the 20 skills; this allowed me to weight the list of skills to prefer certain ones. I'm sure Troll could/would handle that; but it would at the very least require the list of weighted values to be input upfront, and I was just trying to get it working to start.

B) the level choice was also weighted but much more simply. Instead of 4 equal choices on a D4, I was using a D10 with {1,1,1,1 2,2,2, 3,3, 4}.

I can swap in the weight skill level picking and run with that. I HAD originally wanted to figure out all of the possibilities and permutations (or at least groupings of them); but I was/am trying to do that strictly with combinatorics and math. I did not expect Troll to be able to tell me that; although it would be super-awesome if it could.
Thanks again for your help; I cant believe you did in so few lines what I spent days trying to get done [and am still stuck on the math of some aspects of]

Return to topic list

New message:
Posted by:

Type the values of the dice shown below:

Return to topic list