Page 1 of 1

You may draw a card

PostPosted: 07 May 2015, 13:15
by PalladiaMors
"You may draw a card" is a very common ability - if you search for this text in the card explorer it returns 105 implemented cards.

Part of these cards have been coded as regular MayChoices - I believe the script version of the ability has been coded like that. Most groovy cards have this ability coded as a SimpleMayChoice with a default choice of yes (Bident of Thassa, Cold-Eyed Selkie and many others).

This is a case of a common ability where in the vast majority of the situations you want to make a certain choice. In some very rare spots, it can lead to disaster (you have 1 life and opponent has Underworld Dreams on the battlefield, or you're playing against a mill deck and there's zero cards left in your library).

I have no doubt that coding all cards with this ability as simple choices would result in an overall increase in the AI's playing strength, simply because the amount of situations where you do want to draw is immensely higher than the very rare situations where you don't want to do it. The drawback is that the AI would make game-losing errors in some specific spots. If I understand it correctly, once a choice is set as the default choice, the AI can't avoid making it.

I'm pretty sure there are other MayChoices where similar options could be made. Please discuss!

Re: You may draw a card

PostPosted: 07 May 2015, 14:17
by muppet
If I understand the way the ai makes a decision correctly it should be possible to bias them.
I think it simply counts the number of wins and loses and picks the line with the most wins.
Now if a decision makes almost no difference this makes it pretty random whether it will so one or the other. But if you add a bias so it needs say 75%wins to make the normally least optimal option e.g. not drawing the card then this should work. You might have to tweak the numbers till you found a good value.

Re: You may draw a card

PostPosted: 16 May 2015, 14:24
by PalladiaMors
Magarena has now extended SimpleMayChoice to other cases, and I was thinking about more cards that could also use it safely. Gempalm Incinerator and Gempalm Polluter came to mind, but while testing them to see if that worked I noticed that SimpleMayChoice doesn't allow a target choice. Would it be viable to extended it to targeted abilities in the future? I think that would improve AI handling of a considerable number of cards.

@muppet, if you pick the latest 1.62 build, some of the AI issues you've been mentioning should have been improved, like skipping life triggers or draws. Please playtest when you can if you're interested!

Re: You may draw a card

PostPosted: 16 May 2015, 15:30
by PalladiaMors
Also, considering

muppet wrote:Failed to search for a basic land when Solemn Simulacrum entered the battlefield.
"you may search for a basic land card and put it onto the battlefield" at first sight looks like another good candidate for SimpleChoice in script form. As usual, I'm pretty sure there will be some rare situations where you don't want to do it, but it's the correct choice in the vast majority of situations, so there should be a net gain for the AI's strength. I think it might be possible in the future to add exceptions for the known exceptional cases. For example, the SimpleMayChoice.DRAW_CARDS could include a check to verify if the opponent controls a permanent named "Underworld Dreams" or if the player's library size is < 10, and in those cases switch to a default choice of No. These are just examples, I know that there will be more cases than that and that it's difficult to keep track of every possibility, but I don't think it's impossible to include the exceptional cases as people report misplays by the AI.

Re: You may draw a card

PostPosted: 17 May 2015, 14:49
by jerichopumpkin
I wonder if it's possible to add a failsafe to SimpleMayChoiche: only check if doing the default action leads to immediate defeat (draw with zero cards in deck, search a land and put it on the battlefield with Zo-zu in play and less than 2 life, etc.), and in that case, do the opposite of the default. Is it possible without impacting the code and the game performance too much?