I'm currently writing a bot for a game, and I'm really struggling to figure out how to solve this mathematics problem.
Essentially, the problem is as such.
There are 20 levels that can be played, and every 3 days the bot is required to randomly pick 5 levels that are played for the following "rotation".
The only condition is that none of the five levels chosen can be from the previous rotation.
In other words, lets assume level names are "1", "2", ..., "20". If the first rotation contains levels 1, 2, 3, 4, 5, then the second rotation can only have levels 6..20.
However, in one season of play, there are only 9 rotations that are made, and as a result, after coding together a simulation, it appears that the chance that all levels get chosen is around 16%. There is a 36% chance that 1 level doesn't get played across the season, 30% chance that 2 levels don't get played, etc.
I would like to ensure that the probability that all levels getting played at least once is much closer to 100%.
The simple solution here would be to keep track of all the levels that haven't been played, and to ensure that they get selected in future rotations, but that essentially removes the randomness element from the selection process.
My thought is that when the selection process occurs, that the levels have some sort of weighted probability of being selected, with the levels that have been played more having a lesser chance of being selected, whilst the levels that haven't been played having a greater chance of being selected - but I'm not sure how to mathematically approach this problem (i.e., how should the probabilities be altered based on the amount of play).
I would really appreciate any pointers from anyone!
Here is a simple method which chooses all levels with a probability of about $94\%$. Imagine a deck of $60$ cards, each numbed $1$ to $20$, with three copies of each number. Repeat the following $9$ times:
Shuffle the deck.
Deal cards one at a time from the top of deck. Each card you deal will either go into the "chosen" pile, or the "discard" pile.
Keep dealing cards until there are five cards in the chosen pile.
Place the five chosen cards in the trash, then place the discard pile on top of the deck. The trash cards are never put back in the deck.
Note that using two copies of each card is insufficient, since you will need to choose $9\times 5=45$ cards total. Having three copies of each card is sufficient to ensure that the procedure never gets stuck, i.e. that you never exhaust the deck. You could do the same with say, an $80$ card deck with four copies of each card, but this decreases the probability of choosing all levels.