Unrepeated random numbers

Miscellaneous Forums/General Discussion/Unrepeated random numbers

The Forum Archive is locked. These are the original blitzbasic.com forums, kept so their posts can still be read and searched. No new topics, replies or edits can be made here. To join the conversation, head over to the Blitz3D+ forums.

Andy's solution sounds identical to mine in principle. I'm making an optimization: instead of two separate arrays, the last N elements of my array is the randomized deck. Essentially - select a random card from the first 52 cards and move it to the end of the deck, select a random card from the first 51 cards and move it to the end of the deck, etc. Of course, I'm also using my vector container library (which uses banks) instead of straight arrays to simplify things (for me, anyway.)

Using linked-list(s) means you'll have to walk the source list every time you want to find the Nth random element. Using array(s) means you'll have to move elements back to fill in your hole when you need to delete one. Both approaches have disadvantages for this application.