stevesherrin
New Member
- Joined
- Oct 31, 2024
- Messages
- 4
- Office Version
- 365
- Platform
- Windows
I work for a playing card company and we often get calls for randomized expansion packs for games created from a pool of all the cards in the game. Some cards are more rare than others so should show up less times As an example, one game has a pool of 40 cards and I need to create 500 random 9 card sets but some cards are twice as likely to be drawn as others. I currently create a list of multiple copies of the filenames of each card, so each rare card appears once in my filename pool. The formula I use is :
=INDEX(filenames,(INDEX(UNIQUE(RANDARRAY(10^4, 1, 1, 217, TRUE)), SEQUENCE(9))))
This works well but there are 2 issues with it:
1) In some cases there are 4-5 rarity levels, some cards needing to appear 220 times in the filename list. The list is over 3000 filenames long. It is very time-consuming (and tedious) t put this list together.
2) While it minimizes duplicates within a single set, it doesn't completely get rid of them, especially with larger sets (36-54 random cards per set).
I have been trying to use a true weighted formula for this but the formulas I have found for weighted pulls from a list do not generate sequences (ie- a list of 9 cards)... They only produce one. The option that has been offered is putting the formula in one cell and dragging the handle down to duplicate the formula the 8 cells beneath it. While this works, there's no way to make the separate cards unique since they are drawn separately (since they are not a sequence created by a single formula in one cell that auto generates 9 entries in the column.
This new formula is:
=INDEX(filenames,MATCH(RAND(),cumulative))
filenames is a named range in the excel sheet (B3:B8) and cumulative is a named range (D3:D8)
Is there a way to modify this to create a sequence of random items from the list in a column and to prevent duplicates? Or maybe a VB script? Unfortunately I am a noob to excel and have no VB experience at all.
Thanks in advance for any suggestions you may have.
=INDEX(filenames,(INDEX(UNIQUE(RANDARRAY(10^4, 1, 1, 217, TRUE)), SEQUENCE(9))))
This works well but there are 2 issues with it:
1) In some cases there are 4-5 rarity levels, some cards needing to appear 220 times in the filename list. The list is over 3000 filenames long. It is very time-consuming (and tedious) t put this list together.
2) While it minimizes duplicates within a single set, it doesn't completely get rid of them, especially with larger sets (36-54 random cards per set).
I have been trying to use a true weighted formula for this but the formulas I have found for weighted pulls from a list do not generate sequences (ie- a list of 9 cards)... They only produce one. The option that has been offered is putting the formula in one cell and dragging the handle down to duplicate the formula the 8 cells beneath it. While this works, there's no way to make the separate cards unique since they are drawn separately (since they are not a sequence created by a single formula in one cell that auto generates 9 entries in the column.
This new formula is:
=INDEX(filenames,MATCH(RAND(),cumulative))
filenames is a named range in the excel sheet (B3:B8) and cumulative is a named range (D3:D8)
weighted random.xlsx | ||||||||
---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | |||
1 | value | probability | cumulative | weighted random | ||||
2 | ||||||||
3 | ape.jpg | 5% | 0.00 | frog.jpg | ||||
4 | cat.jpg | 10% | 0.05 | |||||
5 | dog.jpg | 10% | 0.15 | |||||
6 | bear.jpg | 20% | 0.25 | |||||
7 | dolphin.jpg | 25% | 0.45 | |||||
8 | frog.jpg | 30% | 0.70 | |||||
Sheet1 |
Cell Formulas | ||
---|---|---|
Range | Formula | |
F3 | F3 | =INDEX(filenames,MATCH(RAND(),cumulative)) |
D3:D8 | D3 | =SUM(D2,C2) |
Named Ranges | ||
---|---|---|
Name | Refers To | Cells |
cumulative | =Sheet1!$D$3:$D$8 | F3, D4 |
filenames | =Sheet1!$B$3:$B$8 | F3 |
Is there a way to modify this to create a sequence of random items from the list in a column and to prevent duplicates? Or maybe a VB script? Unfortunately I am a noob to excel and have no VB experience at all.
Thanks in advance for any suggestions you may have.