I needed some practice with object-oriented aspects of python, so I set myself the task of writing that Klondike solitaire player I threatened. Some of what I found is about what you'd expect to see. I don't claim my algorithm is the best; one could be more strategic, especially as you learn what's in the deck. But it's an OK first approximation.
Yes, of course I wrote it so you can vary the number of ranks, number of piles, number of suits, and so on. Why bother otherwise?
I ran 10000 games with the different parameters. I kept 4 suits and 2 colors, but had 13 ranks and 7 piles (standard) and also 13 ranks with 6 piles, and 3 variants of 14 ranks (Tarot deck): 6, 7 and 8 piles. You expect that the more piles there are, the more cards are buried and the more will be left unplayed at the end of the game. And so it was.
With the usual game it looks like you win about 1 time in 20. (BTW, these are from random number generators, and are not exact.)
Type | Times you win | Time < 5 cards |
Standard | 485/10000 | 1681/10000 |
13ranks+6piles | 792/10000 | 3210/10000 |
Tarot+6 | 516/10000 | 2702/10000 |
Tarot+7 | 247/10000 | 1319/10000 |
Tarot+8 | 136/10000 | 452/10000 |
That's the easy part. What's a bit harder is quantifying the "frustration factor": how close you feel you got to winning. I figure the oftener you feel like you almost won, the more likely you are to start a new game--provided you actually do win from time to time. And the game can't be too easy. I'm not sure how to quantify that either. But from the fact that the standard game uses 7 piles instead of 6, I suspect that 6 makes the game feel too easy.
Notice the spike near 0 for the standard game. Most of the time you lose by a significant amount, but you come close oftener. I list the numbers in the table above, but I show the plots below.
For what it's worth, even a game with 2 suits and 3 ranks (and 2 piles) doesn't always wind up with every card face up. And the game above goes through the deck repeatedly.
No comments:
Post a Comment