Results 1 to 1 of 1

Thread: Rolling for starting stats the hard way.

  1. #1

    Thread Starter
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819

    Rolling for starting stats the hard way.

    My brain is mush. This is a simple problem and my concentration just isn't there at the moment.

    Anyway...

    I'm doing it the dumbest, most freshman way imaginable.

    First some numbers.

    Each stat has a minimum allowed starting value and maximum value.

    That's per stat so different stats can have different starting rules.

    Let's say they're all the same for simplicity.

    CAP = 100

    Min = .15 * CAP (minimum of 15 points to start)
    Max = .80 * CAP

    Then there's a total number of points that can be allocated.

    Let's say it's 40% and there are 5 stats

    40% * CAP * 5 = Total points available.

    They can distributed any way the player likes as long as they are at or above min and at or below max.

    Standard stuff.

    The way I'm doing it is stupid and works very poorly. It does work though.

    So I'm rolling each stat in turn until the number is valid and then adding them up and if they aren't the correct number just doing that over and over again.

    What I want to do and where I'm confusing myself.

    Step 1: I want to pre-load each stat with the minimum and subtract that from the total available.

    Step 2: Send each stat in turn to a sub with the remaining amount of points. Figure out which is the greater but less than or equal to Max - Min: Max - Min or Available points.

    Then roll for that, add it to the min that's already there and return the amount of available points remaining. Also subtract 1 from the die roll because rolling always returns at least one which would always make the stat at least one more than the min.

    nPointsAdded = RollDie (Max - Min + 1) - 1

    or

    nPointsAdded = RollDie(AvailablePoints +1) -1

    Now I don't want to do that in order and I'm not sure if my logic is correct here but I think if I send them in order then the points for the last stats will tend to be lower than the stats for the first one because the pool gets smaller.

    So I need to create an array that holds the indexes of the stats, shuffle it, then send the stats in that order to the sub.

    It's the array and shuffling part that's shutting my brain down even though I'd done that exact same thing many times. I should just think of some code of mine it's in and go find it.

    Also too, the array doesn't even have to be shuffled. Instead, the Indexes of the Stats could be inserted randomly while checking that each stat is in the array only one time.
    Last edited by cafeenman; Jun 18th, 2024 at 02:56 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width