It is currently 16 Apr 2024, 22:13
   
Text Size

Remember...

General Discussion of the Intricacies

Moderator: CCGHQ Admins

Remember...

Postby lord of 13 » 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?
><><><><><><><
Currently developing Mindgames, for playing a rules-enforced game of MtG.
RECENT PROJECTS
->XMLScript
->Zwiel Platformer
User avatar
lord of 13
DEVELOPER
 
Posts: 79
Joined: 06 Jan 2010, 01:36
Has thanked: 0 time
Been thanked: 0 time

Re: Remember...

Postby MageKing17 » 04 May 2010, 05:16

A fascinating idea, however I'm not so sure about a threat level of 0 for uncastable cards in hand. After all, if an Elf deck has no green mana out, despite not being castable, if you Coercion your opponent, you'll want to nail, say, a Priest of Titania or a Wellwisher before it can hit the field, despite it "currently" being uncastable (assuming, of course, that a Priest of Titania or Wellwisher is the most threatening thing in their hand).
User avatar
MageKing17
Programmer
 
Posts: 473
Joined: 12 Jun 2008, 20:40
Has thanked: 5 times
Been thanked: 9 times

Re: Remember...

Postby Huggybaby » 04 May 2010, 05:22

Well, I remember you. :) Welcome back, and thanks for the fascinating post. This is the type of analysis I've been hoping for for some time. I see it as a natural evolution of what this forum is about. We have lots of playing apps here, so the next step is to make them smarter.

I'm sure you'll get lots of comments on this subject, but one thing stuck out to me right away. You said "Quantity of mana will be ranked more highly than color of mana." I can think of one possible exception. When someone is playing a multicolor deck, it's a powerful defense to eliminate any one color.

For example, opponent is playing red and green; If the guy has five green lands and only one red, destroy the one red. This prevents him from playing any of those red cards that will just continue to build up uselessly in his hand.
User avatar
Huggybaby
Administrator
 
Posts: 3205
Joined: 15 Jan 2006, 19:44
Location: Finally out of Atlanta
Has thanked: 696 times
Been thanked: 594 times

Re: Remember...

Postby juzamjedi » 04 May 2010, 19:09

"Threat level" as I think I understand it would be a fine way for a dumb AI to play. Please take this in the spirit it is meant. The problems will come up when the strategy of a deck means certain cards are more (or less) threatening than normal.

As a clear example: suppose I have Rhox War Monk and Kor Firewalker in my Bant deck. For a lot of opponents Rhox is above average and Kor Firewalker is below average. However, for an AI player using a Blightning / beatdown strategy both of these creatures are must-kill threats!

Another example: AI is playing a U/B Polymorph combo deck and turn 1 casts Duress. My hand has Lightning Bolt and Ajani Vengeant as legal targets with only 2 lands in my hand. I would guess that Ajani would have a higher "normal" threat level than Lightning Bolt. However, because the AI strategy requires polymorphing a plant token etc. the instant speed Lightning Bolt is usually the correct play. But also the AI has to value what are the odds that I draw 2 lands fast enough that I can play Ajani and keep Emrakul tapped? Does the best choice change if my Polymorph target is Sphinx of the Steel Wind instead of Emrakul?

Another example: I am playing Dredge and AI is playing Zoo. If Bridge from Below gets into my graveyard then it is often the correct play for the Zoo player to kill one of its own creatures. Seriously. Alternatively if I was dumb enough to cast Bridge from Below (and it is an enchantment on the battlefield) then the threat level from Bridge would be near zero. Of course Bridge is a very special case. ;)

As I finished typing this post I thought of a single card that is fantastic for you to consider: Cabal Therapy.

When the AI plays Cabal Therapy what does it name against me? The most threatening non-land card in all of Magic is probably Ancestral Recall. Clearly it is wrong for AI to name that card though if we're playing Legacy though since Ancestral Recall is not legal in Legacy. Should it name Force of Will? What if I played a basic mountain; should it name Blood Moon? Tarmogoyf? If AI is playing Dredge does it just name a random graveyard hoser like Ravenous Trap? Does the AI track the cards I play so that future use of Cabal Therapy has some information about which cards were in my hand previously and are still in my hand now?

So in short the main flaw I see here is that in certain strategies the importance of a specific card can move the threat level up or down a lot. This is especially true for combo decks.
juzamjedi
Tester
 
Posts: 575
Joined: 13 Nov 2008, 08:35
Has thanked: 6 times
Been thanked: 8 times

Re: Remember...

Postby juzamjedi » 04 May 2010, 19:15

Edit: a I just reread your note about cards in hand. Quantity of lands needed is only a good way to evaluate if the player already has the colored sources they need. A better method would have the AI "cheat" and look at deck contents of the human player and calculate the outs. In my example above if my 2 lands in hand were Forest + Mountain and AI wants to calculate threat level of Ajani in my hand it would need to know the odds of me drawing 1 white source + 1 other land in my next X draw steps.
juzamjedi
Tester
 
Posts: 575
Joined: 13 Nov 2008, 08:35
Has thanked: 6 times
Been thanked: 8 times

Re: Remember...

Postby lord of 13 » 04 May 2010, 22:42

Interesting points; maybe uncastable cards will .4 instead of .75, so that threatening cards that cannot currently be cast will be evaluated.

As for AI playing strategies, that is deeper than this system is intended to go; for that, I would use the Lua script to create the AI Logic.
><><><><><><><
Currently developing Mindgames, for playing a rules-enforced game of MtG.
RECENT PROJECTS
->XMLScript
->Zwiel Platformer
User avatar
lord of 13
DEVELOPER
 
Posts: 79
Joined: 06 Jan 2010, 01:36
Has thanked: 0 time
Been thanked: 0 time

Re: Remember...

Postby frwololo » 06 May 2010, 02:15

Wagic uses such a system (although only for creatures and based on damage so far)
The results are a bit awkward, it kind of works, the bad side effect is that you can see the AI "ganging up" on what it believes to be a huge threat from time to time.

It Works very good against "lords" for example, because one of the rules in my current implementation is that "every time a creature does some damage, if a lord is 'acting' on that creature, it gets a share of the creature's threat level"

Imagine you have a goblin king, and attack with 3 raging goblins.
each raging goblin will see its threat level increase by 2, and the goblin king will receive 3 * 2 * multiplying_factor, where multiplying_factor is, for example, 0.5.
So if they all started at 0, each raging goblin is now considered as a "level 2 threat", while the goblin king (even if it didn't attack) is considered as a "level 3 threat".
Next time you play with the same deck against Wagic's AI, it will focus some of its attention on the goblin king if it has the possibility to do so.

http://code.google.com/p/wagic/source/b ... IStats.cpp
frwololo
DEVELOPER
 
Posts: 265
Joined: 21 Jun 2008, 04:33
Has thanked: 0 time
Been thanked: 3 times

Re: Remember...

Postby Huggybaby » 06 May 2010, 03:37

Ahh, the King...one of my favorite cards. I love the hasty Goblins too.
User avatar
Huggybaby
Administrator
 
Posts: 3205
Joined: 15 Jan 2006, 19:44
Location: Finally out of Atlanta
Has thanked: 696 times
Been thanked: 594 times

Re: Remember...

Postby princealway » 11 Aug 2010, 18:23

I just read your note on the cards. Quantity of land required is only one way to evaluate if the player already has the color sources they need. A better approach would have the AI cheat and look inside the human player's deck and calculate the outputs.
Life is either a daring adventure or nothing.
princealway
 
Posts: 4
Joined: 11 Aug 2010, 18:13
Has thanked: 0 time
Been thanked: 0 time

Re: Remember...

Postby Yggdrasil » 12 Aug 2010, 12:10

Why not a "tag" associated to each deck, indicating the nature of the deck and how AI has to play it ?

examples of tags :
burn
fast aggro
mid-pace aggro
control
combo (the tag indicates also which cards are used in the combo)
prison (the tag indicates the type of ressources targeted)
...

The tag would be specified by the player in the deckbuilder.

For each type of tag, AI would have a specific way to play with the associated decks, and (why not) also a specific way to play AGAINST this type of deck.

For example, when playing a deck tagged 'combo', AI would try to reunite the cards of the combo (for example by using its tutors), play and protect them in priority.
When playing against a combo-tagged-deck, AI would try with high priority to counter or remove the combo cards specified in the tag.
Yggdrasil
 
Posts: 124
Joined: 16 Mar 2010, 20:55
Location: France
Has thanked: 6 times
Been thanked: 1 time


Return to Magic Rules Engine Programming

Who is online

Users browsing this forum: No registered users and 11 guests


Who is online

In total there are 11 users online :: 0 registered, 0 hidden and 11 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 11 guests

Login Form