Thursday, October 23, 2014

Of Math and Magic / Limiting Chance

Chris Mascioli has a nice article in his series Of Math and Magic where he shows how to calculate multivariate hypergeometric probability mass function using a spreadsheet.  He calculates the odds of drawing a pair of the same spell, something not easily done in Deck-u-lator.

He wrote this series as a response to Dan Nelson's series Limiting Chance.  Dan focuses his attention on the 40 card Limited format and addressed topics including play or draw, mulligans, cantrips, and the mana curve.

I appreciate what both these authors have done in helping to educate gamers about how to use math to improve their play.  Dan's approach is a bit more "scruffy", but he does carefully explain his methods.  Chris provides the "neat" contrast by rigorously explaining results using probability theory

Monday, April 23, 2012

Infrastructure Upgrades

The technology underlying the Deck-u-lator has been upgraded to the latest versions. This application now takes advantage of the High Replication Datastore and takes advantage of multithreading. There are also performance improvements due to faster page generation using a new template engine, using native Python language features for calculations and JSON processing.

Any change like this introduces the risk of changed functionality. If you see any problems, please contact me.

Monday, December 20, 2010

Visualizing hypergeometric distribution

What are the chances to draw exactly one card of four in a sixty card deck? This is exactly the question the hypergeometric distribution answers. Here are two graphs showing this distribution. First, the height of the bars shows the percentage of hands that have exactly the specified number of cards. The red bars show chances for drawing exactly one card of four. As you can see the maximum value is about 44% when 15 cards are drawn. This also happens to be when the average or mean value is exactly one.

Here is the same data with the bars stacked to show that the percentages always add to 100. This view clearly shows that your chance to draw at least one of the four cards after drawing fifteen is about 69%.

Saturday, December 11, 2010

How to calculate whether you have enough mana, continued

What are the chances that you will have one land to play for each of the first four turns? Using Deck-u-lator to answer that question was the topic of an earlier article.  Here is a graph showing the chance of having one land on turn one, two land on turn two, and so on for different 60 card decks.

With 20 land, there is a 54% chance to have 4 land on turn 4
With 24 land, there is a 57% chance to have 5 land on turn 5
With 28 land, there is a 51% chance to have 7 land on turn 7

Tuesday, December 7, 2010

Deck-u-lator JSON API

If you are interested in using Deck-u-lator from other applications, there is a simple interface. You can call the calculator directly from a URL.
arg0 is a JSON expression describing the problem to be calculated. The entire problem is a comma delimited list surrounded by square brackets. Each card type is represented by a two-element list. The first element is the number of cards in your deck. The second element is the number of cards in your combination.
arg1 is the number of cards you draw

The following example requests calculation of drawing 8 cards from a 12 card deck. The deck has three card types. The combination includes one card from the second and third types. The result is returned.[[4,0],[4,1],[4,1]]&arg1=8

Sunday, December 5, 2010

Visualizing probabilities

I have been experimenting with Google Charts for displaying Deck-u-lator results. Here are the chances for drawing combinations with two, three, and four cards. These assume you have four of each card in your deck and are playing with a 60 card deck.
You can see similar charts when you calculate results from any of the example problems posted here.

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 (!).

D choose H = D! / (H! (D - H)!)

The number of different hands of size H drawn from a deck of D cards is "D choose H". A similar formula is used to calculate the number of ways to satisfy each part of your combination. If your deck has DX cards of type X and you need HX for your combination, then there are "DX choose HX" 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.