The AI (artificial intelligence) is the most important aspect of MTG Forge. Yes, Magic is a fun game, but you need to have a challenging opponent.
I’ll let you in on a little secret. I don’t have the Internet at home. Are some of you shocked? I don’t have cable either, ha. Double shock!! But don’t worry I have used Magic Online and at first I was very impressed with everything. The games played very smoothly and I understood the phase stops and everything. Unfortunately after awhile I got irritated waiting on my opponents and “random” disconnects when I was winning. The high card prices also frustrated me, so MTG Forge was born. My goal was to provide fast, fun games of Magic. I am very happy that MTG Forge is able to simulate drafting and sealed games. Currently sealed is my favorite and I often make 2-3 decks with the same pool of cards in order to see which configuration works the best. Sometimes I play “speed Magic” and see how fast I can click and still win.
OK, back to the nitty-gritty of the AI. The AI of course has many different parts. The main skeleton is named ComputerAI_General and it calls the other parts of the AI depending on the phase. This part of the AI has code which handles playing a land, paying for a card, attacking, and blocking. Each of these separate parts has its own code, for instance ComputerUtil_Attack2 decides which creatures the computer will attack with.
The AI is roughly divided up into 2 parts. Code that is built into each specific card and code that attacks, blocks, plays a land, and pays for cards. Some AI is built into each card. For instance, the computer will target creatures with a defense of 2 or less when choosing targets for Shock. The AI code in Shock chooses the targets and decides when the computer should play it. All of the cards and their AI is crammed in CardFactory, which is roughly 10,000 lines long. Yes it is really, really long.
The AI is sub-optimal sometimes when playing cards like Wrath of God and Giant Growth. When playing Giant Growth, the computer will target a creature that will attack but won’t target a 2/2 if you have a 2/3 blocker. The computer will also not use regeneration effects or counter spells unlike the old Magic game Duels of the Planeswalkers, also known as Shandalar. I find it impressive that Shandalar did do some things right and occasionally even pulls off some pretty good 2-card combos. I am very pleased how MTG Forge’s AI worked out. It is smart enough to provide a good game which was my goal. I have played MTG Forge more than probably anyone else, I’m guessing 100+ hours, but I still love it. Maybe next version I’ll add something that shows the “total time played” so you could see how much you really love Magic and of course for bragging rights. :)
p.s. Sid Meier is credited as both a game designer and programmer in Shandalar.