Friday, April 27, 2007

Play Magic against the Computer

I’m writing this article to promote a program I wrote called “MTG Forge” that lets you play Magic against a computer opponent using all the rules of a real game, and it’s really fun. (Self promotion is horrible I know. J) Currently there are 350 cards available and you can play in three modes: constructed (all the cards), sealed, or draft. Can you believe it, free drafting? Yes, the best things in life are sometimes free.

Side Note: If you want to play against another human player, you have to use this other free software project, called the Magic-Project. Like Apprentice, you have to know the other person’s Internet IP address in order to play them, but unlike Apprentice, the Magic-Project enforces all of the rules of a real game.


Good News:
The card set is the best of Magic, and includes such cards like Ancestral Recall, Juzam Djinn, Serendib Efreet, Flametongue Kavu, Man-o'-War, all the moxes, Kokusho, the Evening Star, Keiga, the Tide Star, as well as old favorites like Wrath of God, Psychic Blast, Serra Angel, and a few Planar Chaos cards like Pyrohemia, Serra Sphinx, Damnation.

More good news, you can automatically download all of the card pictures with just one click, which makes playing more fun.

This project is written in Java (so you have to have Java installed) and has been tested on Windows and Linux. It should work on Macintosh but I don’t know for sure. You have the option of downloading either a full-featured Window’s installation program, or a plain zip file. To install using the zip file, unzip all the files into a directory and double-click on the file “run-forge.jar”

Main Download Site:


Limited Good News:
You can play in sealed deck format or draft, cool I know. J The sealed deck format works like usual, you get 5 booster packs, 75 cards, and you have to put your deck together. To make a sealed deck, open the “Deck Editor” and from the menu select “New Deck – Sealed” and your card pool is generated for you. If you want a different card pool, just select “New Deck – Sealed” again.

In the sealed format you can optionally select “Generate Deck” for both you and the computer’s deck. This generates a 2 color deck with at least 15 creatures from a card pool of 5 booster packs like normal. The deck has 18 lands, a little high I know, with 9 lands of each basic type. I like this option because I don’t know what cards are in my deck and I definitely don’t know what cards the computer has. It is really surprising but fun. You can still win 95% of the time using the “Generate Deck” option.

Drafting is fun, but I’ve never drafted in real life and only once on Magic Online. It seems like a really enjoyable format, but a little too money intensive for me. Drafting works like normal, you open 1 pack, choose a card, and pass the rest to your neighbor. The computer selects cards for the other 7 players and actually constructs their decks using the chosen cards, something that took way too much programming. You can then play your draft deck against the other 7 players that drafted with you. After you have drafted all of your cards and saved them to a file, you have to open the Deck Editor, and then open the file that you just saved in order to actually make your deck.

Bonus Limited News:
You can edit which cards are classified as common, uncommon, and rare for sealed and draft!!!! If that news isn’t great, what is? Chocolate covered deck protectors? The file “common.txt” contains all of the card names that are considered common, so if you are tired of playing against Wellwisher, just delete it. If you want to play with Kiki-Jiki, Mirror Breaker more, make him uncommon by adding him to the file “uncommon.txt” The files “common.txt”, “uncommon.txt”, and “rare.txt” have no blank lines, lines starting with “//” are ignored, and the card names must be valid. I suggest cutting and pasting card names from the file “cards.txt”, which holds all of the programmed cards, in order to avoid any messy errors.

Bad News:
Since this is the work of one programmer and freely distributed at no cost, the user interface (how stuff looks on the screen) is simple, but very usable. You can see a screenshot here.

The computer intelligence (AI) is simple. The computer only plays cards during its turn, and will play Giant Growth before declaring attackers much like a beginner. Even though the AI is basic, the computer can top deck some great cards, so I think it feels realistic. Honestly, I forget I’m playing a simple computer opponent sometimes since I am so into the game, and focused on winning. Because people enjoy winning – yea!!! –
having a challenging yet beatable computer opponent works out really good.

With the limited card pool and basic computer intelligence you will not be able to test your deck for a tournament. I’m just saying this in case anyone has that idea. That was one of my ideas when starting with this project, but one man can only code so much. So features were cut, and although you can’t play your favorite deck, you can make new decks with all those banned cards like Ancestral Recall, Wheel of Time as well as other expensive rares like Adarkar Valkyrie and Visara the Dreadful. Here is a recipe for fun, mix in Ancestral Recall with a pinch of Eternal Witness for insane card drawing and make sure you don’t deck yourself. One of my favorites is Kiki-Jiki, Mirror Breaker, which is fun to play and really silly to pronounce. And who can tell me what Fire Imp does? Well, he is Flametongue Kavu’s little brother, costs 2R, creature, 2/1, that deals 2 damage to target creature when he comes into play. Fire Imp is a fun Portal card that no one has heard of, but it’s a great casual card. And who out there really has enough money to buy 20-30 copies of Relentless Rats, well put away that wallet, since you can play with them for free.

Extra Ramblings:
If you like Magic, and I bet you do, MTG Forge is really fun. Games are a quick 5-10 minutes and your opponent never gives up. Don’t you hate it when you are winning and your opponent has connection failure, curse you Magic Online. And you can play land destruction and other hate decks without annoying people.

I wrote MTG Forge because I wanted to play fast, quick games against the computer, using cool rare cards that I could never afford in this life time. I’m looking at you Ancestral Recall and Juzam Djinn. Even though the AI is basic, the computer plays a challenging game.

For more information consult the user manual that is included when you install MTG Forge.

Download Me:

E-mail me any comments good or bad; I want to make MTG Forge the best I can.

--Forge, mtgrares at yahoo com

Thursday, April 26, 2007

Introduction to Programming

There are two types of people in the world: those who program computers and those who use those programs. Programming is similar to writing music. A piece of sheet music does nothing until it is interpreted by a musician. The computer interprets what a computer programmer writes.

Programming is hard because you have to tell the computer what to do in every situation. For example, let’s say a piece of code takes a number and doubles it. So if you pass the code the number 2, it returns 4, sounds simple right? What if you pass the code a negative number? If you give it the number -2, do you want it to return -4? The answer is sometimes yes, sometimes no depending on what the code is used for. What happens in the code if it tries to double the number but it is too big? These types of situations can happen. Programming these edge cases, that rarely happen, takes probably 50% of the total programming time.

Error situations like this take a lot more programming versus the “normal” things the program is supposed to do. Probably half of Microsoft’s Word programming is concerned with errors like checking if the hard drive is full. Programming is also excruciating hard because every single CHARACTER matters, there is no such thing as an “extra” word or character when you program.

Introduction to Magic

Magic: The Gathering is a card game with creatures. Both you and your opponent start out with 20 life and you try to reduce your opponent’s life to 0.

Card types include creatures, which you use to attack, and spells which have some effect on the game like you gaining 5 life or causing your opponent damage. Games include a lot of strategy which makes the games exciting, and helps make Magic infinitely enjoyable. Magic has been called “cardboard cool-aid” and “cardboard crack” because it is so addictive.

The official Magic website is here and an overview of Magic is here. A good demo for PCs can be downloaded here (85 megabytes).


It’s hard to describe yourself, but I’ll try. I wrote a Java implementation of Magic: The Gathering that lets you play against the computer using all the rules of a real game, unlike Apprentice.

MTG Forge
-365 cards are available
-Constructed, Sealed, or Draft mode
-Automatically downloads card pictures

Magic is the oldest and mostpopular card game around that currently has around 8,000 cards. My program currently has 365 cards, which is pretty good. My initial goal was 150 cards, 30 of each color. It was a large project that was written by just me. I don’t eschew other programmers, and I’m sure I could work in a group, but I just programmed it for fun in my free time. Actually, I’m very happy with it. It works, so much software, especially free software, seems a little buggy, which I totally understand. Free software is written mostly by computer enthusiasts and bug stopping is usually no fun, personally I hate it. Free software also tends to have a basic user interface or none at all. My program has a simple user interface written all in Java, and it shows, but it is at least a visual interface. It automatically downloads all of the card pictures, which is a nice bonus to the user. I am really proud of the deck editor. It works nicely and is very easy to use.