aquiline ascension

published: 2010-10-16
author: Hans Nowak

My Magic projects (part 1)

First, a bit of background info...

I have been playing Magic the Gathering since about 1997. Ever since that time I have been wanting a card database, especially one that could be searched using powerful queries. Tom Christiansen's Mox Perl was the first one that I know of. 1  I didn't actually use it much, but it did inspire me to write a similar database of my own, using Python.

Back in the day card data wasn't all that easy to get. There were text-based spoilers, which could be parsed to extract card info; however, the info wasn't always correct, and the format often differed between files. Much time was spent getting the actual parsing right.

I wrote several searchable card databases like this. Mostly with command line interfaces, and once with a wxPython GUI. I wrote a version in Ruby a few years ago (called MoxRuby, the remnants of which can probably still be found online somewhere), and one in Scheme for Pokemon cards. Last year I wrote one for Magi-Nation, using Python and Google App Engine; Magi-Nation Search is available online and has its own project page.

All of these operate on the same premise: there's a card database, stored as a list of card objects or similar, and you can enter an expression in Python (or whichever language was used) to search for cards. Basically, the expression is applied to each card, matching cards are collected, and then displayed.

So, as a simple example, in order to find all red creatures in Magic, I could type and card.creature

and it would evaluate that expression for each card. This mechanism goes back all the way to Mox Perl (which, of course, used Perl expressions instead).

A few years ago, Wizards of the Coast put their own Magic database online, called Gatherer. Unfortunately, compared to the expressive power of the aforementioned programs, it was pathetically weak. It could be used, however, to fetch card data in an organized and methodical manner, as opposed to the old way of parsing text spoilers. 2  I wrote a program called Magicripper that did exactly that.

(You might wonder why Gatherer wasn't good enough. It had a GUI/web-based interface, and its selection mechanism was very limited. Being a programmer, when presented with a set of data, I am used to being able to do whatever I want with/to that data, rather than being restricted by a limited interface. To put it another way, the expression-based card databases could do many kinds of queries that were simply not possible in Gatherer.)

An improved version of Gatherer was rolled out eventually (I think it was last year), which introduced a different HTML format, which broke the first version of Magicripper. I lost interest until fairly recently, when I decided to try my hand at writing a new version. The result is the new and improved Magicripper2.

Magicripper2 is the basis for a set of 3 Magic-related projects (soon to be 4), which I will talk about in part 2.


1  I think there is no longer a working online version. I'm not sure if the code is even available.

2  Although I suspect that some of the data for the older sets are taken from the very same text spoilers! Complete with odd mana symbols and all.

blog comments powered by Disqus