# Magic: The Gathering – Duels of the Planeswalkers

Magic: The Gathering – Duels of the Planeswalkers is a video game based on the popular collectible card game of the same name, published by Wizards of the Coast. It was released on June 17, 2009.

## Gameplay

The core game follows the standard rules of the collectible card game Magic: The Gathering; each player has a deck of cards consisting of lands and spells. Lands are used to generate "mana," the resource needed to cast spells. Mana comes in five colors, and cards may require colored or generic (mana of any color) to be cast. Spells come in many varieties, from sorceries which have a one-time effect, to summoned creatures which can attack and defend from opponents. Players alternate turns playing land cards, casting spells, and attacking opponents until all but one player's life total is reduced to 0. Unlike the paper cardgame, you cannot make your deck of cards in the videogame.
The game is, as described by its developers, an "arcade" game and simplifies much of gameplay to be more accessible to newer players. There is no deck construction, and players only have access to a limited number of preconstructed decks; however, as they play and win against computer opponents, they unlock new pre-constructed decks and specific cards that can be inserted into each deck to make the deck more powerful. Tapping of lands for mana is done automatically, with the engine selecting lands in multi-colored decks based on the remaining cards in a player's hand. Whenever an action is taken that other players may respond to, a brief timer is present to allow for any player action; players may pause this timer to give them more time to respond if needed. As such, play priority goes to the person who responds first, with all further actions resolved via Magic's stack rules. Regardless of the game type, players get one free mulligan at the start of a match; any further requests to redraw their hand will impose Magic's standard rule of diminishing the number of cards drawn.
To help newer players, an option exists to bias the shuffle for computer opponents to keep game-unbalancing cards at the bottom of their deck so that they will never likely see play. As the player conquers the computer opponents, this bias is enforced less and less, allowing the player to gradually become aware of these cards. The game does not include cards that the developers thought were too complex and not conducive to the "arcade" feel.
The game includes a Campaign mode to duel several computer opponents for new decks and cards, a Challenge mode where the player must find the right combination of plays on a single turn to defeat the opponent, and both single and co-operative play against the computer (including "Two-headed Giant", a variant format where the two players share their life total). Players can play in both casual and ranked competitive games over Xbox Live against up to three opponents. In the PC version, players can compete against each other, but the second player is required to use a gamepad instead of the keyboard or mouse.

## Development

Due to the nature of Magic's gameplay, in which any card can override the game's core rules, Duels was developed using a combination of C++ for the core engine and the Lua scripting language, wrapped in XML, to provide logic for specific cards. The engine was developed in this fashion to allow for future expansions on the game, including adding new cards and complexities to it. The game is able to handle cards with more complex rules, though these may require additional programming.
The game's interface was kept separate from the development of the engine, and instead structured in a client–server fashion, with the interface as the client. This was performed in this manner to avoid the complexities of having the user interface to be aware of the complexities of each card, as well as to provide potential reuse of the interface engine. The interface is a "dumb client" that only observes the state of the engine, and is only aware of where cards are on the table and their state, but is not aware of how the cards arrived in their current position. According to the developers, this allows the interface to be "robust and future-proof" for potential expansions.
The game's artificial intelligence (AI) is based on creating a multistep "lookahead" decision tree from the current state of the board, evaluating possible known moves by its opponents, scoring the current and resulting situations both positively and negatively, and then selecting the option with the highest score. The artificial intelligence utilizes threading to run the main intelligence algorithm alongside three "sub-contractors" that evaluate the possible future states and report back to the main algorithm. Each of these instances of the AI uses a special engine that both implements the rules of Magic, while also providing "undo" actions so that they may explore up and down the decision tree. The game's intelligence algorithm runs on a separate CPU core than the main game to avoid creating framerate issues with its display while the player is considering their actions. When the player makes an action, the AI threads are interrupted and brought to the same state as the game, then continue processing, in some cases, reusing existing branches on the decision tree that match with the player's selection. The AI itself does not employ any strategy in terms of strong card combinations, but instead, when such combinations improve the computer's situation, the chances of playing these combinations will "ripple" back through the decision tree. In this manner, the computer AI will play one card of such a combination should it be the best choice at that time, and follow up with the second card of the combination should that option still remain the best after any other player actions.
In order to simplify the task of forward evaluation, the lookahead algorithm was optimized in several ways, considering "the idea that the AI needs to be excellent 99% of the time, even if it's at the cost of being sub-optimal that other 1%". The computer will not consider actions that are considered "pointless", such as healing an opponent, though as noted, there are combination of cards where such actions are useful in the normal card game; as this was found to be a useful feature, the game also implements a similar check on player actions, though the player may disable this feature. The computer also skips any further calculations while it has control of the top action on the stack. The algorithm only looks about three moves (or six total actions) ahead to avoid considering too many deep options. In order to respond quickly, certain actions, such as attack and blocking resolution, are permuted and evaluated (a considerably fast process), and then are sorted in order; the computer then proceeds the lookahead from each option, in order, with the likelihood that if the computer should run out of time, one of the high scoring options will produce the best possible result.
As a result of these means of programming the AI, it was noted that the computer opponents may exhibit behavior not found by typical Magic players, such as not holding back attackers to act as blockers for the opponent's turn, though as noted by the developers, such aggressive play is generally a winning strategy for the computer. The AI also does not have any special knowledge of the constructed decks itself or what cards an opponent might have given the visible cards in play; again, the developers noted that approach can sometimes work better instead of contemplating "big and clever" plans. The developers noted that they observed unusual but effective strategies from working with the AI that they were not aware of before, primarily based on the timing of playing certain cards and effects.

### Downloadable content

The game's first expansion, titled "Duel the Dragon", was announced at the 2009 PAX conference, and was released on October 21, 2009. In addition to a title patch, the expansion adds in three new decks, six more campaign ladder matches including a new boss character, and several new challenges including those that operate over multiple turns. The new expansion also included three new challenges to test the player's ability to think differently.
The game's second expansion was released on May 13, 2010 (September 1 for PC). The expansion features three new cards for each of the game's existing decks as well as including entirely new decks and the ability to use Nicol Bolas' "Eons of Evil" deck in play. In addition, an updated version of the game was made available which fixed a variety of glitches and streamlined much of the gameplay. This update is available whether the user purchases the new expansion or not.
On November 3, 2010, the game's third expansion was released for PC. This expansion features three more cards for each existing deck, including all of the decks from the last two expansions, as well as new challenges, achievements and Two-Headed Giant levels. Finally, the expansion introduces three new playable decks, including the "Master of Shadows" boss deck used by Sorin Markov in the last expansion's campaign, and "Root of the Firemind," the game's first red/blue deck. The PS3 version of the game was released on November 23, 2010. The release date for the Xbox Live Arcade version was December 29, 2010.
New downloadable content beyond the third expansion has not been confirmed.

### Sequel

A sequel to Duels of the Planeswalkers, titled Magic: The Gathering – Duels of the Planeswalkers 2012, was released on June 15, 2011, for Microsoft Windows, Xbox 360, and PlayStation 3. The game includes new game modes, additional card decks, new computer opponents, and new puzzles. One of the additional modes is "Archenemy", a co-operative campaign mode for up to three people, where the players must defeat a range of boss characters with double the normal life points.

## Sales

Duels, in its first five weeks of release on the Xbox Live Marketplace, had been downloaded over 440,000 times and has had 170,000 full game purchases, a turnover percentage that is generally higher than most other digital downloads. The game also remains on the top ten played Xbox Live titles, with it being the top-ranked title for the first two weeks of release. By January 2011, more than 500,000 units of the game have been sold on the Xbox Live Marketplace.