Saturday, December 4, 2010

How does it work?

Deck-u-lator computes the ratio between the number of different hands that include specific cards and the number of possible hands that can be drawn from the deck you describe. If half these possible hands have the card combination you want, there should be a 50% or 0.5 chance of drawing your combination.

Calculating this chance uses a branch of mathematics called combinatorics. The number of different ways to choose \(H\) elements from a set of \(D\) elements is called the binomial coefficient is calculated using factorials (!).

$$ \binom{D}{H} = \frac{D!}{H!\,(D-H)!} $$

The number of different hands of size \(H\) drawn from a deck of \(D\) cards is \(\binom{D}{H}\). A similar formula is used to calculate the number of ways to satisfy each part of your combination. If your deck has \(D_X\) cards of type \(X\) and you need \(H_X\) for your combination, then there are \(\binom{D_X}{H_X}\)  different ways to choose the type \(X\) cards you need. The number of hands with the cards you need is the product of all the different ways to choose each card. This is called a multivariate hypergeometric distribution (without replacement).

The Mathematics of Magic The Gathering: Probability, Statistics, Game Theory, and Strategy by Jon Prywes has an excellent discussion of mathematics for games if you are looking for even more information.


1 comment:

  1. Hi, do you programm this in php ?
    Could you share the code please ?
    There s an hypergeometric function in php but not a multivariate one.
    Thanks a lot !

    ReplyDelete