Mar 29 2008
I’ve just written and uploaded a very alpha version of a program that will calculate the odds of drawing a particular card (or its copy) in a deck of a given number of cards. In particular it’s designed for Magic the Gathering. I still have a number of things to do with it, including making it look decent and making the opening hand size variable.
Updated: I’ve fixed the code and it works nicely. You can use it and see the code both at: www.tollie.org/files/cardcount.php
In particular, and here’s where I’m asking for comments: my math is a little off in the way I’m accounting for things. Presently, the numbers are high for situations where the target card has copies (ie. cards > 1) due to double accounting for the multiple copies in the same deal. In other words, if you draw two of the target cards in the opening hand, it essentially treats that as two cases of "in opening hand = yes", but only one iteration. Likewise, the numbers are more skewed as the number of cards increases. This explains the > 100% figures.
There are ways to account for this, but I’d like suggestions on ways to do it cleverly without making the code much more complex. For now, the percentages are based on 30,000 "deals."
Thanks for your comments and suggestions. I hope this helps you construct your Magic the Gathering decks mathematically.
Find it (working) and the code here: www.tollie.org/files/cardcount.php


