I want to predict the results of a simple card game, to judge on average, how long a game will last.
My 'simple' game is;
- Cards are dealt from a randomised
deck to n players (typically 2-4) - Each player gets five cards
- The top
card from the deck is turned over - Each player takes it in turns to
either place a card of the same face
value (i.e 1-10, J, Q, K, A), the
same suit (i.e Hearts, Diamonds,
Spades, Clubs) or any suit of magic
card (a jack) - If the player can place
a card they do, otherwise they must
take a card from the deck - Play
continues in turn until all but one
player has no cards left
I'm guessing that I could write code to play a mythical game and report the result, then run that code thousands of times.
Has anyone done this ? Can they suggest code that does a similar job (my favoured language is R, but anything would do) ? Is there a better way ?
Best Answer
The easiest way is just to simulate the game lots of times. The R code below simulates a single game.
Some comments