Arqade is a question and answer site for passionate videogamers on all platforms. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

A dispenser can eject one of nine different items at random, simulating a deck of up to nine cards (as of 1.6 it is no longer biased toward certain slots). How would you simulate a deck of cards with more?


  • A dice-type random generator isn't sufficient, since it doesn't simulate a card being removed from the deck on subsequent draws
  • It would be beneficial to simulate arbitrary decks, not just a standard deck of playing cards
share|improve this question
up vote 3 down vote accepted

To simulate a standard 52-card deck, you need to go through a number of steps:

  • Stage 1 - Suit selector
    A dispenser containing 4 stacks of 13, corresponding to each deck. The item dispensed tells you what deck to go to for the next stage.
  • Stage 2 - High/Low
    We can't proceed directly to choosing a card, since we don't have 13 slots in a dispenser, so insert a high/low selector here. This is another dispenser with 2 stacks, one of 6 and one of 7. 6 -> low, 7 -> high. You need one of each of these dispensers for each deck.
  • Stage 3 - Card selector
    Finally, you can set up your final array of dispensers, containing the cards, 6 for low, 7 for high, again two dispensers for each deck. These dispensers only contain 6/7 unique items that correspond to the cards.

To use the card selector, first use the deck selector. It will pop out an item corresponding to which deck you should use. Keep this item!. Next, use the high/low selector for the deck you have been assigned. Again, keep the item!. Finally, remove your 'card' from the deck at the last round.

This method will simulate removing cards from the deck, as long as you don't take a wrong path (i.e. you are assigned spades at stage 1 and then go on to use the diamonds stage 2).

It is not perfect, since the odds at stage 2 are weighted in favour of high cards. There's no way round this (using dispensers) since 13 is a prime number.

As you can see, this method can be adapted to model non-standard decks.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.