Monday, October 13, 2008

AI and Limited Decks

While constructed decks are very focused, limited decks are not. Limited decks tend to be composed of good cards with a general theme. Limited decks tend to be more generalized because they rely on a mix of creatures and spells. The AI is very good at playing creatures since it just plays the biggest one and then attacks with it. I feel that the AI’s attacking and blocking strategy can be greatly improved in version 2.

So if MTG Forge is a limited simulator why does it matter? In case you forgot, the most important cards in limited are the commons, so I plan to program more commons in the future.

Commons are the least complicated cards, thus making them the easiest to program, and I plan to start with the commons of the Shards of Alara. (Everyone loves new cards, even programmers!!!) I’m not saying that I won’t program any uncommons or rares, I’m just saying that I will focus on the commons first.

And to tell you the truth, the effects on the common cards don’t give me nightmares like the rares. Programming one replacement effect is easy enough, but having multiple replacement effects is downright confusing. Most uncommons usually can be added with a little bit more effort. The fact of the matter is that it still takes loads of time and energy to program Magic cards, even the simple ones. If someone ever programs a whole block, bless his weary soul.


Anonymous said...

hi, can i suggest you too add ai by deck, example
in ai file we can add the exception rule for the deck ai

IF card1,card2 IN HAND
ELSEIF Card3(Demonic Tutor) IN HAND
ELSEIF ..........

so the standard ai your program will be replaced with AI FILE rule if the condition match.
this will help computer to play combo card more effective.

may be this will be new type coding for the MTG player to make their DECK more strong to played by AI Computer, or you can make tournament AI for computer hahaha

Unknown said...

Forget programming a block. Forget programming a whole set. Just give us the framework to implement all the generic effects that show up on cards throughout history, and the future across all rarities. All the funky, tricky, special cards can wait.

I like the idea. Here's my take on it... the "If in hand" is implied, and the order of the entries is the preference of priority.

Main10=Land Forest
Main11=Creature Birds of Paradise
Main12=Creature Llanowar Elves
Main20=Sorcery Commune With Nature

Main10=Land Forest
Main11=Land Swamp
Main12=Creature Canopy Spider
Main13=Creature Misshapen Fiend
Main20=Sorcery Night's Whisper


Main10=Land Forest
Main11=Land Swamp
Main20=Sorcery Overrun
Attack11=IfPlay(Overrun) Attack All

These are all just hints... if the computer doesn't have them in hand, or can't pay, then it reverts to either prior turn hints or default AI behavior (knee-jerks). If the Attack is yes, then it uses normal AI. It could use some sort of logic like I show for choosing to alpha after playing Overrun, for example.

I'd also like to see the cards have more AI defined. A lot of cards just can CanPlayAI return False, just because the card was cool and funky for humans, but not so good for a computer. Add some elements of randomness, which can be weighted by the "skill" setting of the computer AI, like when in quest mode.

Unknown said...

I forgot to add some other possibilities, like activated abilities...

So you could also have

Main10=Land Forest
Main11=Land Swamp
Main12=Ability Imperious Perfect 2

This would indicate that the AI should play the 2nd ability (G, T: Put the elf in play)

Alternatively, like this:

Main10=Land Forest
Main11=Land Swamp
Main20=Elvish Warrior
OppEOT10=Ability Imperious Perfect

Anonymous said...

Ola, I don't agree with that idea, what if there is Karma or Power Surge in play. With putting lands in play you can only lose life point's. It is not that easy to program AI. I believe that it would be best to teach computer with nevron networks /genetic programing. Because there is so many cards and rules this is not easy task, but i think this is best option.

Anonymous said...

The AI Troll is back again ^_^;
Good luck Forge, I'm personally working on improving my own AI, but it's not easy.
I'm currently going with some "learning" stuff. The AI will remember which cards in your deck did the most damage to it or its creatures.
Definitely not the best approach, but easy to program, and it might give a good illusion (which is what an AI is about, IMO)...

Anonymous said...

hum, willow, you must remember not all deck depend on damage, some base on combo (discard, land destroyer, control deck etc). so i think in next progamming is better AI made base on deck because each deck have diffirent approach and different way to win :) so if we can make computer AI think like us think how to win for each type of deck (it is different for each deck depend on what type deck do you use)

but for standard AI for attacking, assign damage, tap mana etc can be handle in current AI becase it is normal condition

for more challanging, i think we can add scripting AI (hehe like

i hope Forge can think again about this, because make perfect AI is near imposible (need long...... time) but make simple AI for Deck is POSIBLE

Forge said...

AI is a very hard problem, just like world peace. I'm hoping to use an alpha-beta search algorithm, but I haven't ever used it before and the hard part is not using alpha-beta but making sure that the rest of the program is setup in a way to use alpha-beta. It is like creating a car that can go forward and then trying to make a car go backward, the actions are similar but different. MTG Forge AI will have to go forward to see what cards to play and then backward to the current game state. Hopefully that makes sense.

Forge said...

The algorithm, alpha-beta, is just a search algorithm and does not learning. So each game would be new without knowledge of the previous game. While this isn't perfect, I don't think anyone will notice.

Forge said...

AI is always an illusion, that is the reason the current brain-dead MTG Forge AI works at all, the illusion of intelligence. And I admit the current AI is very weak.

Gando the Wandering Fool said...

Nah it does ok for a braindead ai. I mean the cheats alone make it interesting to play I suppose...though not necessarily in fun ways.

Forge said...

Well all AI have to cheat some since it is just a computer program. In Magic, the AI probably won't ever cheat because it is just too complicated. It is easier to build a non-cheating AI that looks into the future, plays a card and then evaluates the result.

Gando the Wandering Fool said...

Cheating to win isnt the same as fudging the rules to enhance functionality.

Forge said...

In a way the AI does cheat. The computer's deck is "stacked" so he doesn't get mana screwed or flooded. That might help the computer 5-10% but I'm not really sure.

Forge said...

Since the computer's deck is stacked, late in the game the computer won't draw a land when it really needs a spell. So in a way, the long game slightly favors the computer, but it doesn't really matter since the computer isn't usually competative.