Tuesday, January 22, 2008

AI and Phases

I often talk about the AI aspect of MTG Forge for two reasons. One, the AI can be improved. Two, I am always looking for specific actions that will improve the AI that can be coded into the program. Just telling me that the computer plays Wrath of God badly doesn’t help. When should the computer play Wrath of God? And answering when he is losing is not the right answer. Currently the computer plays Wrath if he will destroy 2 more of his opponent’s creatures or if he is under 8 life. Obviously this solution is not perfect, but it is reasonable, and that is all I am going for.

The good news is that I’ve found a specific area that the computer can improve on. The computer could play a few spells, like removal, during his Main 1 phase and then play any other spells or creatures during his Main 2 phase. (If the creature has haste, it is played during Main 1.) Currently the computer just tries to play everything during Main 1, which gives away valuable information. Before blocking, I would always look to see what creature the computer just played and I would adjust my blocking according.

The extra good news is that I have implemented the above suggestion into currently released version of MTG Forge and it plays great. The computer attacks and then plays a creature. The results are very satisfying and the games seem more realistic. Before now it never occurred to me that some cards and abilities would be best played during the first or second Main phases. Yes, if I was playing a game of Magic I would use the card/ability during the appropriate phase but that was something that I totally overlooked when I programmed the computer. As Neal Armstrong once said, “One small step for man, one giant leap for MTG Forge.”

6 comments:

Nanocore said...

Just as an aside, I think this is the way the Microprose version of the AI player plays

Unknown said...

I was reading through that Magma documentation, and part of the string that represent card abilities is "best time to play". Basically, the AI of each card and more importantly, each individual effect, is built into its definition. This strategy might be something to consider, though it's still a rather subjective concept, as your Wrath of God example shows.... Magma would define best time to play Wrath as during the second main phase... but second main phase the first turn it shows up in the hand, or second main phase when you're more then 2 creatures down, and running out of life...?

I quite often get burned by the computer not giving me a chance to play spells during his turn, either on his second main phase or before the end of his turn. And planeswalker combat doesn't take destroyed creatures out of combat...

This blog is nice, but now the Sourceforge is back up, could you check in on the bug report section more often?

Anonymous said...

where can MTGForge be downloaded. I checked the page you listed earlier but it says invalid project. Thanks

Forge said...

Even though the Microprose version is 10 years old, is does some nice things. The computer sometimes makes a really good play and can respond when you play a spell. Currently the MTG Forge's AI can't respond and cannot play cards like Counterspell.

Hopefully in the next version of MTG Forge you will have all the phase stops like end of turn.

I like Magma's idea of "when is the best time to play this card." When building a deck you can also assign a "priority number" to each card to help the AI play better. The card with the highest priority will be played.

My Sourceforge project is all messed up. The download's don't work. Hopefully sooner or later I can get my project back on Sourceforge or another website that lets user's submit bugs.

You can download MTG Forge from http://www.mediafire.com/?3sgv3xs0nkj It is at the top, in the description of this blog.

Unknown said...

In general a good rule of thumb in magic is: play it as late as possible.

So if you want to shock the player, leave your mountain untapped until his EOT and shock him then, in case he plays an elf or a bird, in which case you can remove that.

I found that the AI does not do this at all. Wild mongrel attacks and pumps himself way too early. He should only pump after blockers are declared or not.

The only time (HUGE generalization) you want to play something sooner is when you can get an attack in or squeeze a spell through.

Forge said...

The AI is very basic and hopefully occansionally surprises you. The AI will never be able to win a PTQ tournament. Hopefully the AI will get to the point of being able to win a Friday night casual tournament.