top of page
Making random distribution controlled

This was a mini project designed to make random distribution easier to control in generated content.  When using the Unity Game Engine, the random number generator has a general tendency to evenly distribute values across any given spectrum.  Since even distribution isn't always a feature desired in playable content, a shift in distribution is necessary to better emulate value for players.  To achieve this goal, I opted to write a small algorithm to "shift" the distribution to desired points in the spectrum based off of the lowest point in the spectrum. 

To achieve this outcome I've opted to take a given value needing a distribution shift, and check against a threshold.  If the threshold is met, then I obtain another random value between 0 and 1 and check if it sets off a trigger value between that range.  If the trigger value is met, I then create a new random number with a distribution range centered around a users inputted distribution center point.  From there I was able to focus the random distribution with an absolute value function removing any unwanted negative values.

The net outcome was a relatively compact method which allows for fast redistribution of probability for a given roll.

bottom of page