Tag Archives: mathematics

Deck Thinning In Depth

magic cardA common strategy in Magic the Gathering and other trading card games is deck thinning, moving lands from the deck onto the battlefield early in the game. In some ways, deck thinning is troll math. In others, it’s an optimal strategy.

Example: A player taps Bloodstained Mire to use its ability Sacrifice Bloodstained Mire: Pay 1 life, discard Bloodstained Mire into the graveyard, and search the deck for either a Swamp or Mountain, put the land into play, and shuffle the deck. This card lends itself to Red-Black decks as it gives players the option of searching for Swamps or Mountains.

bloodstained mirePlayers maintain that Bloodstained Mire and other deck thinning cards in dramatically alters the probability of drawing certain cards. Lands are removed from the deck and played early in the game, and non-lands are abundant later in the game. A 1/15 chance of drawing a desired card increases to 1/14.

However, 1/15 is only for a hypothetical deck in which every card exists as four multiples. 1/14 is only if you a lucky enough to remove four of the same exact card (unlikely), and that won’t happen with a single deck thinning card.

The probabilistic benefits of deck thinning are next to nil, but spending a few mana now to deploy lands needed later is worthwhile. However, deck thinning cards are only useful if a player can play them; while in the deck, or in the hand but without sufficient mana, they merely take the place of an otherwise useful card.

Deck thinning cards are just as likely to be drawn early in the game as they are to be drawn late in the game. If a deck thinning card is drawn early in the game, a land would have been as profitable as the thinning card (or more profitable considering the price of activating Bloodstained Mire). If a deck thinning card is drawn late in the game, it’s a complete waste; sorceries, instants, and creatures would be better.

Deck thinning can be a false economy. A 1/14 chance of drawing a certain card is hardly an improvement over 1/15. Bloodstained Mire is particularly undesirable, as it requires draining a life point and sacrificing itself. It also must be tapped to be activated, and thus is affected by land tapping spells such as Manabarbs.

badlandsA good way to change the odds of drawing certain cards is to have more or less of them in the deck. Instead of Bloodstained Mire, use Badlands. Badlands directly serves as a swamp or mountain land as the player wishes, does not drain health, does not have to be discarded after use, and does not shuffle the deck.

Scrying, fetching, and other draw cards are highly useful in their own right, just not for deck thinning / probabilistic reasons. A card that removes some from the deck and places them on the board, a card that puts two or more cards in the hand, a card that lets players search for any card in the deck, and even a card that puts cards in the graveyard is useful, recursion permitting.

Update: This post was originally titled “Deck Thinning: A False Economy”. It has been revised to acknowledge the direct benefits of fetch cards while still refuting the main of deck thinning theory: that probabilities are drastically altered, and that this is the primary benefit of deck thinning.

Update: Garett Johnson confirms by Monte Carlo simulation that deck thinning is next to worthless.

MATLAB is horrid

matlab logoI wouldn’t even steal MATLAB, it’s that awful. The syntax is inconsistent, the GUI cumbersome, and the documentation next to useless. Hardly any of the examples are self-sufficient:

fnint

Examples

The statement diff(fnval(fnint(f),[a b])) provides the definite integral over the interval [a .. b] of the function described by f.

That’s not an example! Specify f, a, and b so that readers can understand how to call fnint. MATLAB’s documentation sucks!

In contrast, the newLISP manual is excellent. Here’s the documentation for the abs function.

abs

syntax: (abs num)

Returns the absolute value of the number in num.

(abs -3.5) → 3.5

Oh my God, it tells you how to call abs, it tells you what abs does, and it gives an explicit yet concise example of how to use it in real life. newLISP is free and its documentation is light years ahead of MATLAB’s. I blame it on corporate-style thinking; IBM’s articles are similarly dense/yet void of content.

I played with many different possible syntaxes for fnint and never found the right one. I tried defining a function fun in fun.m and calling integrate(fun, [0 2]). I tried using an anonymous function integrate(@(x) x + 1, [0 2]). I tried using a symbolic function integrate(‘x+1′, [0 2]). None of these worked. I tried using combinations of the above with the MATLAB fnint function. Still didn’t work. If you, dear reader, can elucidate the secret syntax for integrate and fnint, please comment.

Finally, my girlfriend and I came up with an integration function that not only works, it has decent syntax.

function y = riemann(f, xmin, xmax)
	delta = 0.0001;

	y = 0;

	for t=xmin:delta:xmax
		y = y + delta * f(t);
	end
end

fun = @(x) 5 * exp(1) ^ (-(x-3)^2);
riemann(fun, [0 2])

ans =
	0.6970

You still need to declare riemann in a file called riemann.m., and either evaluate the last two expressions fun … and riemann(fun… in the MATLAB interpreter or declare them before the riemann function in riemann.m.

And that’s a hassle. I’ll admit, even Erlang doesn’t let you declare functions in the interpreter, so I don’t expect MATLAB to let you. But it would be nice if the MATLAB interpreter language were a subset of the MATLAB script language and not a derivative.

The GUI

There’s no good reason to use a GUI interpreter. It just gets in the way. Except in the case of Windows, where the Command Prompt has pre-2000 conventions for copy and paste. I still would rather use the terminal.

matlab -nodesktop

You shouldn’t have to add a flag (a long one at that) just to keep the GUI from loading. And guess what? On Windows, the flag doesn’t do jack.

MATLAB exists to do integration of arbitrary functions, and it’s awful at it. There’s no reason to use this proprietary, non-free, dysfunctional language when perfectly decent alternatives exist.