You're wanting a more robust way of calculating random numbers, to ensure an even spread. This kind of logic is used in roguelike loot systems to ensure that sampling probability distribution over some short timeframe ends up closely matching the desired distribution.
There are a number of ways to achieve what you're wanting. One way is to generate all the numbers you know you'll use in advance, adding them to a queue, then popping them from the queue one by one.
When doing this, you can add a check that re-rolls the random number if it's already in the queue too frequently, adding it only if it passes the frequency test.
If you have different "tiers" of things selected by the random number generator (eg, using the roguelike example, common items vs rare vs legendary), you can cater for an even spread of those in your queue by making A, B, and C number of them ready for the queue, then shuffling the queue.
↧