by Doc_Brown on Mon Feb 01, 2010 3:41 pm
I've thought about this off and on for a while, and I think I have an idea on how you could code this to keep the randomness present and give some chance for you to get the same card in short succession, but to reduce the likelihood based on when the card was cashed. Here's the basic idea: Start with the set of all possible cards (3 times the number of territories - each territory card in each color). The cards should be initially randomly distributed in a queue, so that when a card is drawn it is removed from the queue and placed in a second one. When a card is played, it is placed at the back of the first queue. Here's where the additional randomness comes into play: Instead of using a uniform probability distribution to draw the cards from the queue, use a binomial or Poisson distribution with the peak towards the front. If the first queue is empty, apply the picking algorithm to the second queue (only draw cards that are already in hand if the deck is completely empty, and prefer to draw cards that have been held the longest).
The one problem I see is that the cards could end up coming up in a fairly similar order after a few rounds. This would be a certainty if the picking algorithm always grabbed the first card, and the frequency with which it did so would set the degree to which the pattern of the cards being drawn is consistent from one loop through the deck to the next. However, we can fix that as well. We could apply a shuffling algorithm to the first queue every so often, but then we have to worry about whether or not there are enough cards left in the deck to provide a reasonable shuffle. A better idea is to randomly select the position in the deck to which a card is inserted. We could use another binomial-type distribution, except that it would peak towards the back of the queue. Thus, but setting the strengths of the two binomial peaks you can affect how likely a card is to come up again immediately after it has been played. If the second distribution has a sufficiently large standard deviation but still peaks at the back of the deck, it should be suitable to eliminate the sense of an order in which the cards are drawn while still ensuring that the most recently played cards would be among the least likely to be drawn.