Darkhax-Minecraft / Tips

Adds tips to loading screens of Minecraft.
GNU Lesser General Public License v2.1
50 stars 46 forks source link

[Suggestion] Random selection without replacement #99

Open AngleWyrm10 opened 2 years ago

AngleWyrm10 commented 2 years ago

It would be nice to see something that isn't just randomly selecting from the set of all tips, where the same tips can pop up during the same presentation of tips.

A way to do that would be instead of using a random roll against the set of all tips, create a temporary copy of the set of all tips as a bag of tips for the presentation session, and then draw one tip out of the bag each time a new tip is presented.

Random selection without replacement: random shuffle a list of tips once at the start, and then just pop one from the end every time another tip is needed.

If the list runs out of tips, refill the temporary list, re-shuffle, and carry on.

Darkhax commented 2 years ago

Thanks for the suggestion, I will look into adding this. Could just iterate the shuffled copy and wrap around rather than treating it like a stack.

AngleWyrm10 commented 1 year ago

Yeah that seems like it could be even more efficient :)