Friday, August 29, 2008

Random Rules Questions

Occasionally I have random questions about the rules. I could post my questions to a forum but I have you, my faithful legion of readers, to answer my questions. And by the way, I hate optional abilities that begin with “you may”, because it requires additional programming.

1. Reya Dawnbringer – has a triggered ability that says, “At the beginning of your upkeep you may return target creature card from your graveyard to play.” Since this ability is optional, when do you decide if you want to or not? Do you decide at the beginning of your upkeep whether or not to use Reya’s ability?

2. Angel's Feather says “Whenever a player plays a white spell, you may gain 1 life.” When do you decide if you want to use this ability or not? Do you have only one window of opportunity to use this ability once a spell is on the stack?

3. Ok this isn’t strictly a rules question, but what is Heart of Light (10th Edition) good for? Heart of Light is a creature enchantment that says, “Prevent all damage that would be dealt to and dealt by enchanted creature.” You can target one of your creatures to make him an all-star blocker and I guess you can target one your opponent’s creatures that you couldn’t handle. Is this card a variation of Pacifism? This card just confuses me.

4. What happens when Orcish Artillery’s ability goes on the stack and then your opponent steals Orcish Artillery. Do you or your opponent receive 3 damage? (In case you don’t know, Orcish Artillery’s ability says, “tap: Deal 2 damage to target creature or player and 3 damage to you.”)

Wednesday, August 27, 2008

Stack – Cards versus Spells

Sometimes thinking about a Magic card really confuses me. Generally a card is a spell right? And if that card is a creature, that spell generates a creature. The confusing part is that the card represents the spell for the creature and the creature itself. This isn’t confusing if you have physical card, but it does confuse me, a Magic programmer. And cards don’t go on the stack, only spells do.

The stack is the only zone that doesn’t hold cards. Technically the stack only holds spells and abilities. MTG Forge version 1 tries to stay true to the rules, no Card objects can be added to the stack, only SpellAbilities. (All spells and abilities are represented by a SpellAbility object. This object implements the functionality of the card. Using Wrath of God as an example, its SpellAbility would destroy all creatures.)

Since Magic is all about moving cards, it is difficult when you play a card to move it from your hand to the stack, since the stack doesn’t hold cards. I decided that I would let the stack hold cards and each Card object would hold a SpellAbility object. All I am really doing is swapping Card and SpellAbility. Currently only SpellAbility objects are added to the stack but and they hold a reference to the card that they represent.

Allowing the stack to hold cards makes moving cards much, much easier. The stack is a zone but you had to treat it as a special exception since it didn’t hold cards. Now I can write a simple moveCard() function that will work all the time.

moveCard(Card card, String zoneTo, String zoneFrom)

p.s.
Incantus, another Magic program, adheres strictly to the rules and each card has characterstistics. Below is taken from Magic’s comprehensive rules.

201.2. An object’s characteristics are name, mana cost, color, type, subtype, supertype, expansion symbol, rules text, abilities, power, and toughness.

Tuesday, August 26, 2008

Tortuga

I'm not sure where to post this image, so I'll just stick it here. Tortuga is a card that I made up and yes it is very unbalanced and too powerful.

Basically Tortuga is the Library of Alexandria (tap: draw a card. Play this ability only if you have 7 cards in your hand.) with another ability that says, "tap: Discard a card, then draw a card." I thought it was fun to discard and then draw. This ability lets you draw cards for free if you hand is empty.

Monday, August 25, 2008

Telengard

I wasn't sure how to get up with you, Telengard. I saw your post about programming the AI for Dreamblade. I played the computer demo for Dreamblade and it was very fun. Do you have a playable version yet? You can post a comment or e-mail me (mtgrares yahoo com).

Shared Zones and Incorrect Rules

The good news is that I’m making real progress on MTG Forge version 2. I was programming the code for the different zones and I came to the conclusion that Magic is all about moving cards. You draw a card. You play a card. You destroy a creature. Practically everything you do in Magic (and any card game) involves moving cards.

My other great realization was concerning zones. Some zones like “in play” are shared while others like your hand and graveyard are not shared. While I like to keep as close to the rules as I can, I decided to make all zones shared, including your hand and graveyard.

Cards in your hand will be cards that you control (because you can steal your opponent’s cards occasionally) while all cards in your graveyard will be cards that you own. I was very tired of writing code like “move card from Player’s Hand to Player’s Graveyard”. Now I can just write “move card from Hand to Graveyard.” While this seems like a minor issue, MTG Forge is full of statements that just move cards. If I can make those statements shorter, everyone is happier.

p.s.
I might really cheat and write “move card to Graveyard” and let the program find the zone that the card is currently in.

Wednesday, August 20, 2008

AI and Combat

As I work on MTG Forge version 2, I keep thinking about the artificial intelligence (AI). How can I, a guy who isn’t an expert in AI, write and program a better AI? The AI could attack or block better, but how?

One of the key phases in Magic is creature combat but making any combat choice is complicated. The cards you see in play only make up a small part of the puzzle. The AI can only see the creatures in play, so it has to make all of its decisions blindfolded. It doesn’t have years of experience or intuition to rely on. (Technically the AI can also see the cards in your hand and deck but trying to use that information is extremely complicated.)

So this leads me to the question, “How good can the AI be if it only considers the board?” The AI could comprehensively consider all the creatures in play and determine how to maximize the situation. Basically the AI would have function that evaluated the board and it would try to maximize it, but would this really help the AI play better?

The next level of AI would consider the board position and the cards in his hand, thus enabling him to effectively use Giant Growth and Terror. This type of AI would be a definite improvement over its primitive ancestor. The AI would seem more “alive” and would occasionally make a surprising play. (One of my goals is to have the AI surprise the player because it makes the game more interesting.)

Obviously there could be another level of AI that also considered the type of deck it was using and the type of deck it was playing against. I’m not sure if I’ll get to this level of sophistication, but I will keep it in mind.

Articles about the AI generate the most comments, so feel free to post your opinion. And if you are an expert in AI or write AI for videogames, please e-mail me.

--Forge (mtgrares yahoo com)

Tuesday, August 19, 2008

Beta Version

I posted a new beta version of MTG Forge here. Hopefully it doesn't have any major bugs, but if it does just leave a comment. Over 100 new cards were added pumping the total up to a total of 849 cards.

The "download card pictures" option should work and I love the new layout that Nantuko submitted, it makes MTG Forge look better. (Instead of showing colored boxes for the cards, the card images are scaled down and shown.) Also thanks to another reader that sent me the code to make rotating images faster. Thanks to Rob Cashwalker for submitting 50 or so cards also.