Remember...
Posted: 04 May 2010, 01:43
Remember me? I've been inactive here for quite a while now due to other activities; I'm trying to remedy that. The reason for this post? Simple: my own MtG-rules-enforcing project has had a recent design breakthrough. While the actual code is still small (less than a thousand lines), this newest idea has been nominally tested in a vestigial project with promising results.
To be more specific, I propose using a threat analysis system for the AI to allow for "smarter" decisions - for example, more threatening creatures will be blocked before less threatening ones.
EXAMPLE: Llanowar Elves and Runeclaw Bear are attacking on T3; you have a Hada Freeblade. Clearly, the AI blocks the Elf rather the bears, not only because the Ally survives, but because the Elf mana ramps. It would do this because mana abilities are ranked higher than a vanilla creature, albeit with higher P/T.
This has many underlying assumptions and complications, which I have attempted to solve for my engine.
::Basic Rules of the Methodology::
1. Each permanent will have a threat level based on its statistics (P/T, Loyalty, etc) and its abilities (Runeclaw Bears v. Beastbreaker of Bala Ged).
2. The threat level of a card increases when it is directly impacting the game state.
-> For creatures, this means that attacking makes its power more important to the threat level and that blocking makes its toughness more important to threat level. Also, activated and triggered abilities would make it more threatening.
-> For PWs, this means that activating an ability would make it more threatening. Gideon Jura also needs to be accounted for.
-> For noncreature artifacts and enchantments, their abilities would be the whole of their threat level. Totem armor and Rancor-like abilities would clearly add to the threat level.
-> Lands would be evaluated on fixing and abilities, if relevant. (ex: Gargoyle Castle with 2 mana).
3. This can be used to make instants playable as combat tricks
-> Kill spells and pump spells are the best examples of this. If a creature passes a certain threat threshold or would kill you, you kill it. The natural mechanic would be for it to be most dangerous during combat or when its abilities activate/trigger.
-> It is important to note that the AI should never play spells that do not affect the battlefield significantly or negatively for them. (Shatterstorm with a Loxodon Warhammer under their control and Leonin Scimitar under their opponent's).
4. The AI must prioritize hurting the opponent over helping itself, with the exception of survival. Clearly, the goal is to have a more threatening position than the opponents. In multiplayer games, the AI can evaluate attacking the most threatening player first, and then down the hierarchy of player threat levels.
5. These rules lead cleanly to an AI choice between spells and combat decisions.
-> An AI has Lightning Bolt and Doom Blade in hand, against a Canopy Spider. What should it use? Depends on the life total of the opponent; if it is high, Bolt the spider. Otherwise, Doom Blade it.
-> More threatening creatures will be blocked before less threatening ones. However, low-power creatures with powerful non-combat abilities will not attack unless it is for the win.
::Evaluating Threats::
The AI evaluates threats differently for each type of permanent and for players.
CREATURES
P/T are significant, as are abilities. Evergreen abilities can be a standard additive or multiplier to those base stats (Deathtouch would add, but Lifelink would multiply stats). CMC may also matter with cards such as Smother and Consume the Meek.
(NONCREATURE) ARTIFACTS and ENCHANTMENTS
Abilities are king; equipments and auras will be also rated according to the creature they are attached to (the less powerful the creature, the lesser its rating, and vice versa).
PLANESWALKERS
The more potent its (relevant) abilities, the more dangerous it is. A Nicol Bolas ready to ultimate is more threatening than a near-dead planeswalker.
LANDS
The more colors it fixes, and the more mana it adds, the better it is. Quantity of mana will be ranked more highly than color of mana. Any abilities will most likely be secondary, with the exception of cards like Quicksand and Tectonic Edge, who will need custom evaluation functions.
INSTANTS and SORCERIES
These are clearly more threatening while on the stack; spells that hurt the AI (directly with Lightning Bolt or indirectly with Giant Growth during combat) will be considered more threatening than spells that aid the caster. The target of a spell also affects its threat level; Lightning Bolt on a Nessian Courser is less threatening than on a Halo Hunter. This will be evaluated by adding the target(s) threat levels, but first multiplying those numbers by a certain amount less than 1 (current thoughts: .5). As far as targets go, here is a rough breakdown of threat level by card type: PW, Land, Creature, Artifact/Enchantment, Instant/Sorcery/Abilities (on the stack), Cards in Hand, Cards in Graveyard, Cards in Deck. Obviously, the specific card will skew the ratings.
CARDS in HAND
Each card in hand will have its threat level multiplied by .75, and then by the chance of casting it. To clarify, with 2 Mountains and a Forest on the field, Keldon Marauders will have its threat level multiplied by 1, while Kozilek's Predator will have its threat level multiplied by .75 (3 mana possible/4 needed), and Oona's Gatewarden will be a 0 (since there is no chance of casting it without an Island or Swamp). Clearly, the situation would change drastically with a Birds of Paradise on the battlefield.
CARDS in GRAVEYARD
Each card in graveyard with a game-affecting mechanic (Bloodghast, Firebolt, etc) will be multiplied by a relevant multiplier depending on the mechanic in question. Otherwise, they will be multiplied by a chosen number (current thoughts: .33).
CARDS in DECK
Each card in graveyard with a game-affecting mechanic (Panglacial Wurm) will be multiplied by a relevant multiplier depending on the mechanic in question. Otherwise, they will be multiplied by a chosen number (current thoughts: .1).
These are my current thoughts; they are derived from similar mechanics used in RTS and FPS games but adapted and evolved to MtG. Comments? Feedback? Critique?
To be more specific, I propose using a threat analysis system for the AI to allow for "smarter" decisions - for example, more threatening creatures will be blocked before less threatening ones.
EXAMPLE: Llanowar Elves and Runeclaw Bear are attacking on T3; you have a Hada Freeblade. Clearly, the AI blocks the Elf rather the bears, not only because the Ally survives, but because the Elf mana ramps. It would do this because mana abilities are ranked higher than a vanilla creature, albeit with higher P/T.
This has many underlying assumptions and complications, which I have attempted to solve for my engine.
::Basic Rules of the Methodology::
1. Each permanent will have a threat level based on its statistics (P/T, Loyalty, etc) and its abilities (Runeclaw Bears v. Beastbreaker of Bala Ged).
2. The threat level of a card increases when it is directly impacting the game state.
-> For creatures, this means that attacking makes its power more important to the threat level and that blocking makes its toughness more important to threat level. Also, activated and triggered abilities would make it more threatening.
-> For PWs, this means that activating an ability would make it more threatening. Gideon Jura also needs to be accounted for.
-> For noncreature artifacts and enchantments, their abilities would be the whole of their threat level. Totem armor and Rancor-like abilities would clearly add to the threat level.
-> Lands would be evaluated on fixing and abilities, if relevant. (ex: Gargoyle Castle with 2 mana).
3. This can be used to make instants playable as combat tricks
-> Kill spells and pump spells are the best examples of this. If a creature passes a certain threat threshold or would kill you, you kill it. The natural mechanic would be for it to be most dangerous during combat or when its abilities activate/trigger.
-> It is important to note that the AI should never play spells that do not affect the battlefield significantly or negatively for them. (Shatterstorm with a Loxodon Warhammer under their control and Leonin Scimitar under their opponent's).
4. The AI must prioritize hurting the opponent over helping itself, with the exception of survival. Clearly, the goal is to have a more threatening position than the opponents. In multiplayer games, the AI can evaluate attacking the most threatening player first, and then down the hierarchy of player threat levels.
5. These rules lead cleanly to an AI choice between spells and combat decisions.
-> An AI has Lightning Bolt and Doom Blade in hand, against a Canopy Spider. What should it use? Depends on the life total of the opponent; if it is high, Bolt the spider. Otherwise, Doom Blade it.
-> More threatening creatures will be blocked before less threatening ones. However, low-power creatures with powerful non-combat abilities will not attack unless it is for the win.
::Evaluating Threats::
The AI evaluates threats differently for each type of permanent and for players.
CREATURES
P/T are significant, as are abilities. Evergreen abilities can be a standard additive or multiplier to those base stats (Deathtouch would add, but Lifelink would multiply stats). CMC may also matter with cards such as Smother and Consume the Meek.
(NONCREATURE) ARTIFACTS and ENCHANTMENTS
Abilities are king; equipments and auras will be also rated according to the creature they are attached to (the less powerful the creature, the lesser its rating, and vice versa).
PLANESWALKERS
The more potent its (relevant) abilities, the more dangerous it is. A Nicol Bolas ready to ultimate is more threatening than a near-dead planeswalker.
LANDS
The more colors it fixes, and the more mana it adds, the better it is. Quantity of mana will be ranked more highly than color of mana. Any abilities will most likely be secondary, with the exception of cards like Quicksand and Tectonic Edge, who will need custom evaluation functions.
INSTANTS and SORCERIES
These are clearly more threatening while on the stack; spells that hurt the AI (directly with Lightning Bolt or indirectly with Giant Growth during combat) will be considered more threatening than spells that aid the caster. The target of a spell also affects its threat level; Lightning Bolt on a Nessian Courser is less threatening than on a Halo Hunter. This will be evaluated by adding the target(s) threat levels, but first multiplying those numbers by a certain amount less than 1 (current thoughts: .5). As far as targets go, here is a rough breakdown of threat level by card type: PW, Land, Creature, Artifact/Enchantment, Instant/Sorcery/Abilities (on the stack), Cards in Hand, Cards in Graveyard, Cards in Deck. Obviously, the specific card will skew the ratings.
CARDS in HAND
Each card in hand will have its threat level multiplied by .75, and then by the chance of casting it. To clarify, with 2 Mountains and a Forest on the field, Keldon Marauders will have its threat level multiplied by 1, while Kozilek's Predator will have its threat level multiplied by .75 (3 mana possible/4 needed), and Oona's Gatewarden will be a 0 (since there is no chance of casting it without an Island or Swamp). Clearly, the situation would change drastically with a Birds of Paradise on the battlefield.
CARDS in GRAVEYARD
Each card in graveyard with a game-affecting mechanic (Bloodghast, Firebolt, etc) will be multiplied by a relevant multiplier depending on the mechanic in question. Otherwise, they will be multiplied by a chosen number (current thoughts: .33).
CARDS in DECK
Each card in graveyard with a game-affecting mechanic (Panglacial Wurm) will be multiplied by a relevant multiplier depending on the mechanic in question. Otherwise, they will be multiplied by a chosen number (current thoughts: .1).
These are my current thoughts; they are derived from similar mechanics used in RTS and FPS games but adapted and evolved to MtG. Comments? Feedback? Critique?