On Thu, 2 Jul 1998, John Woods wrote: > I was using a relatively simple system...first rolled each stat between 50 and > 100. Then I was adding them up. As long as they were not all adding up to 825, > the game was supposed to roll a number between 1 and 11, and reroll the [snip] > > So finally I ask my question: does anyone have a snippet for allocating so > many stat points /unevenly/ between 11 different stats, so that they add up to > whatever amount you specify? #define MAX_SUM 825 int scores[11]; // for (int i=0;i<11;i++) { scores[i]=50; // min score of fifty for all } int pts_remaining = MAX_SUM - 550; while (pts_remaining-- > 0) scores[number(0,10)]++; // assign scores[] to ch->abilities... That's a general idea. Not exactly speedy, but not too bad either. You can speed it up by doing a bit more sophisticated job of distributing the points (by more than 1 in other words) but it'll work. I'm away from my code, and I haven't coded in C for about four months, so I'm a bit rusty. :) You should get the general idea, though. Good Luck, Ray +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/15/00 PST