Monday, December 29, 2008

AI - Mana Smoothing

The computer AI used to stumble when playing mono-colored decks. The AI seemed slow and would actually play the same land twice, the cards ID numbers were the same. The problem was in the code that smoothed the computer’s land, also known as mana threading. The code presumed a two color deck. I fixed the code and now it will worked with 1,2,3,4 or 5 color decks. With a 2 color deck the computer’s mana is threaded like 1,2,1,2,1,2.

The computer’s land is threaded in a very particular order. The computer’s opening hand has no lands and then draws a land for the next 5 turns. You may be asking yourself, why? The idea is to increase the number of spells the computer has an opportunity to play. On the computer’s first turn he has 7 spells and 1 land. So hopefully he has a one mana spell in his hand. On the computer’s second turn, he draws a land and plays it. So now he has 6 or 7 spells in his hand, depending if he played a spell. The computer’s hand is all spells, increasing the “quality” of cards he has. Being technical, I guess the computer has “virtual card advantage,” but I don’t really know, lol.

The computer draws an additional land on his 8th and 11th turn. The computer will never have more than 7 lands in play at a time, assuming he doesn’t play cards that fetch lands. Threading the computer’s land like Forest, Mountain, Forest, Mountain, gives it an advantage. Assuming a 2 color deck, the computer will be able to play any double-costed spell like RR as early as turn 3 and always by turn 4.

p.s.
I probably should have made the "AI land smoothing" code optional, so the user could select when to turn it off and on. The only time I know of that this really backfires is if you play land destruction, but even then you are not guaranteed to win the game. If some card makes the computer shuffle his deck, this doesn't hurt the computer since his deck will be completely randomized. The lands that are not put on top of the computer's deck, are put on the bottom.

I'm thinking about implementing an optional feature that lets the AI draw 2 cards per turn. I'm not sure if this would really help the AI or not. Obviously this would hose discard decks but that is why I would make the feature optional.

5 comments:

DennisBergkamp said...

I think AI land smoothing is a great (albeit unrealistic) way of making the AI a bit stronger.

Handicapped in many ways (I mean heck, poor AI can't even play a counterspell), he could use all the help he can get :)

Forge said...

So far the problem isn't making the AI too hard to beat, lol. The land smoothing helps the AI a little bit, but not much. And you are right, the AI needs every bit of help it can get.

jacker said...

prada bags
prada wallets
prada bag
prada handbag
prada handbags

Joshua Smith said...

For businesses it needs to stay updated by using actual software solutions. Some solutions could be developed by outsourced company that provides mobile applications development for business companies.

Joshua Smith said...

Thanks for sharing with us this great info. You have nice chance to get info about online affiliate programs. The most common casino programs such as ace live and great poker rooms such as redbet poker affiliates.