mage icon indicating copy to clipboard operation
mage copied to clipboard

Why Would You Do That: AI takes actions that have no (meaningful) effect

Open Zerrisx opened this issue 4 years ago • 10 comments

The AI sometimes takes actions that don't affect the board state, but cost time or resources, even when better actions that would affect the board state are also available. This should be avoided.

Since these types of issues can be intermittent or difficult to reproduce - and are also low priority - I'm just combining them all into one tracking issue, rather than testing to see which still occur. Some issues listed here may already be fixed.

  • [ ] AI with two Kiora's Followers will just use them to untap each other #1167

  • [ ] AI will tap and untap Basalt Monolith repeatedly #2023

  • [ ] AI crews vehicles in second main phase (and even when summoning sick) #4166

  • [ ] AI casts pump spells on its creatures when nothing threatens them and they cannot attack #4458

  • [ ] AI taps creature lands to pay for their own cost of activation #5615

  • [ ] AI re-activates creature lands that are already animated (i.e. Mishra's Factory) #5615 #6172

  • [ ] AI will bounce the land it just played when playing karoo/bounce lands #5773

  • [ ] AI targets indestructible creatures with Dark Hatchling #5778

  • [ ] AI casts Astral Cornucopia with X=0 #5894

  • [ ] AI re-equips Shining Armor to already equipped creature #6107

  • [ ] AI discards cards to pump Vampire Hounds when it can't attack #6118

  • [ ] AI uses Thespian's Stage to copy itself #6145

  • [ ] AI names colors that haven't been observed in the game with Prismatic Circle #6237

  • [ ] AI will regenerate beasts with Krosan Warchief when those beasts are not in danger of dying #6280

  • [ ] AI will use Marath, Will of the Wild's ability to take off and return the same counters #6281

  • [ ] AI will activate First of the Suns and Jodah, Eternal Archmage to cast already castable spells that cost less than five mana #6358

  • [ ] AI will cast Journey to Nowhere and Oblivion Ring without targets on the battlefield #6425

  • [ ] AI will pay life to regenerate Marrow Bats when it is not in danger of dying #6587

  • [ ] AI will target it's own equipment with Silverback Elder's destroy ability

Zerrisx avatar Jul 14 '20 16:07 Zerrisx

@Zerrisx don't close related issues. It's a different tasks with different bug reason and fixes.

JayDi85 avatar Jul 14 '20 17:07 JayDi85

I was thinking of making a new issue for some of those, but I guess I mention it here better:

The AI bounce the bounce land when there are not a basic in play, more specifically, turn 1 play Temple Garden, turn 2 Selesnya Sanctuary and bounce it, repeat this for like 3 turn in a row until star playing other land and later when it have a basic in play Santuary again and bounce a tap basic.

Every turn activate Detection Tower or Shadowspear for basically no reason, in the case Shadowspear it used several times wasting all its mana on it either on its turn or across several turns (tho one time is was kind of funny because it was beneficial to me)

I guess this apply to Equipment that don't grant stats bonus in general: the AI waste all its mana moving Swiftfoot Boots around on its creatures, last I try it was several version ago so I change it to Lightning Greaves, still waste time moving it around but at least it does not waste mana on it with that one. Tho Whispersilk Cloak seem to use it well, so I guess the equip cost is also a factor

It play Prototype Portal without imprinting anything, and later activate it to do nothing. I observe this one once, but I change the card immediately none the least.

It always took all the cards with Sylvan Library even if that kill it.

Sometime it fog itself with Glacial Crevasses (I mentioned this one as part of a previous issue)

Does not untap anything under Smoke effect, when I guess the most valuable creature is already untap.

It produce colors outside of its color identity with Selvala, Heart of the Wilds

Spam Asceticism effects on its creatures, sometimes several times on the same creature.


Well those are some of the why would you do that moments that come to mind at this time while playing with the AI

copperfield42 avatar Jul 14 '20 18:07 copperfield42

@Zerrisx You might want to add #6697 to your list...

allentiak avatar Jul 15 '20 02:07 allentiak

@Zerrisx You might want to add #6697 to your list...

That play is impressively dumb... but it does at least do something. I'm trying to restrict this just to actions that are equivalent to tapping 3 mana because you can, then saying go.

Zerrisx avatar Jul 15 '20 02:07 Zerrisx

I always tried to avoid putting AI specific code on the cards, but in order to fix many of these issues, that may be the only way. JayDi's trigger check for Duelist's Heritage is just one example. A while back, I believe it was LevelX2 who added code to try and stop repetitive actions by the AI, but it had limited success. I will experiment with some simple checks and see how it goes.

jeffwadsworth avatar Jul 16 '20 04:07 jeffwadsworth

BTW current test framework supports full AI testing. Commands:

  • aiPlayPriority() -- computer play one card/ability;
  • aiPlayStep() -- computer play all cards/abilities that it want until end step;

That's commands can be run after battlefield prepare (search commands for examples).

So all that repeats and wrong actions can be tested by unit tests. Even more -- you can see AI logs with actions list and scores tree (why it used or not used some actions or why AI repeats it).

  • AI cast/play cards/abilities only if it gives extra battlefield score (increase score for you or decrease score for opponent).
  • Scores calcs for each permanent/card in battlefield/hand and depends on card's characteristics and abilities (see GameStateEvaluator2, PermanentEvaluator, CombatEvaluator).
  • AI takes all possible actions to activate (all playable) and all possible targets for it. After that combines and simulates all possible games until resolve and selects actions list with best final score.
  • So it uses simulation for priority plays and targets selects, but uses direct choose code for another interactions (e.g. for choices/targets in resolve code).

JayDi85 avatar Jul 16 '20 04:07 JayDi85

I was testing the checkForRepeatedAction() code and it doesn't detect the Basalt Monolith cycle. The test suite used for it is not correct. Working on that aspect first.

jeffwadsworth avatar Jul 16 '20 16:07 jeffwadsworth

I have some more why would you do that moments

-cast X spell or used X activated abilities with X=0, some examples include: Increasing Confusion (casted for 0) and Folio of Fancies (activated for x=0) -Shred Memory (targeting cards for multiples greveyards) -Selhoff Occultist (mill itself) -Attack with creatures that die to effects of cards on the field like: Powerstone Minefield, Circle of Flame, Caltrops -Cast a boost spell or use a boost ability on a creature that isn't involve in combat or anything that care about power/thoughtness or do soo in the post combat main phase: like casting Overwhelming Stampede or putting Craterhoof Behemoth with a Natural Order on main 2, or using a Rhonas the Indomitable or Arahbo's abilities on creatures that can't attack that turn or the weren't declared as attackers. -flip jace, PW side +1 on its own creatures -use Rogue's Passage on opponent creature, when itself is creatureless -not untapping any tap land under Winter Orb when it have untap land -And oldie, but I guess is worth mentioning too, don't block a lethal attack and not block in general unless blocker can survive or trade on stats alone even if it have other abilities that make it a good blocker.

copperfield42 avatar Aug 17 '20 22:08 copperfield42

I think we may need a new approach to all of this. Please let me know if there is any reddit, discord or something to talk about all this issues.

ziqueiros avatar Mar 03 '21 22:03 ziqueiros

I think the answer is simple: card-by-card-based pseudo-AI algorithms simply do not scale for an ever-growing card universe. Period. Depending in the context, the same effect ("discard three cards"), even if applied to the same target, can be good or bad.

The only similar project I know of that really shines on the AI aspect is Magarena.

allentiak avatar Mar 04 '21 01:03 allentiak