Let me briefly describe two different ways to program a Magic AI.
One, the programmer specifies all of the scenarios in which the computer would play Giant Growth. Two, the programmer lets the computer evaluate the outcome of using various cards, this is very flexible when compared to option one. Option one is hard to implement because each scenario has to be specified while option two requires more planning and coding. (Option two would use an algorithm like min-max or alpha-beta.)
MTG Forge uses option one and Wizard’s new Xbox game uses option two. In MTG Forge each card has around 4-10 lines of code that tells the computer if the card should be played. Below is an example of the code from Shatter. The computer will only play it if you, the opponent, have an artifact and it is turn 5 or latter. The idea behind playing Shatter after turn 5 is that hopefully it will destroy something really good instead of a cheap artifact.
public boolean canPlayAI()
return (getArtifact().size() != 0) && (AllZone.Phase.getTurn() > 4);
The code for Dark Banishing just verifies that you have a non-black creature in play. The method getNonBlackCreature() returns the biggest non-black creature.
public boolean canPlayAI()So you see that in MTG Forge each card has a little bit of AI logic programmed into every card. The AI can't use card combinations effectively because each card is programmed separately. Likewise the computer doesn't know that it should use both of its Shocks to win the game if you at are 4 life, because each the AI isn't that smart.
check = getNonBlackCreature();
return check != null;
And while MTG Forge's AI is very basic, I still attest to the fact that it is very fun.
The lines between the two types of AI's can be blurred. I can envision an AI that could be optimized for a specific deck such as white weenie. The AI would be hardcoded to play cards in a certain order but would also be able to "look ahead". The evaluation function for the look ahead code could be optimized especially for white weenie. This same idea could also be applied to combo decks.