Monday, November 28, 2011

Sealed and Drafting the Forge Way

(This card is an Innistrad token picture which is pretty cool for just a token.)

Forge’s quest mode is fully realized and fleshed out, while the sealed and drafting modes are bare bones. Obviously Forge’s sealed and drafting modes don’t have questing “levels” and it is easy to win against the computer.

Unfortunately the drafting mode is very easy. While the AI does create his deck from the cards that he picks, the decks are mediocre at best. The AI could draft much better if the card set was much smaller. Trying to give 9,000+ cards a power rating, such as A or C, is much harder than only giving 350 cards a rating. Forge does allow the user to create a custom set to draft from but it is complicated.

I do not know how to make the AI better at sealed deck. Basically you are trying to create a deck that is “good” with a semi-random collection of cards. The deck should have a basic mana curve with mostly creatures, some removal is possible, and a few creatures/spells that are good finishers: either creatures with evasion or spells that cause direct damage. While I understand the basics of deck building, I don’t know how to specifically program the AI to build better decks.

Programming a better drafting AI seems impossible because you need to create a specific formula for the computer to follow. Human intuition is trained through observation but computer programming is accomplished through logical steps, if this is true then do that. Programming is like following a recipe with mathematical precision, there is no “flavor to taste”.

Basically the computer is an idiot and computer programming makes the idiot appear smarter than he really is. (If you have ever seen an unintelligible error message, you will quickly realize how dumb the computer really is.)

From the very beginning, I knew that Forge’s drafting and sealed mode would not feel like real life but it would it be an approximation. When you draft in Forge you still have to watch your mana curve, choose good creatures, splash for big spells, and stay in your colors, all of the things that you have to do when you draft in real life. I’ve never drafted or played sealed deck in real life, so for me Forge is as close as it gets. (I’m guessing that most people have haven’t drafted or played sealed deck in real life but who knows.)

Question of the week:
Have you played draft or sealed deck in real life?

Currently not programming but has thoughts
of programming again some day…

--Part of this blog is just me hammering the fact that programming is very hard. Programmers understand this but many other people do not. Think of Java code as concrete. Concrete cannot be randomly thrown around and neither can code.

--Artificial intelligence is just an illusion, like a magic trick. The illusion can be strong but it doesn’t mean that it is true. I have no fear of computers learning to think and becoming sentient. (Despite many movies to the contrary.)

Someone once asked, “Can a computer think?”

He replied, “Does a submarine swim?”

(Stolen from here.)


Anonymous said...

I have been playing with the idea of jumping into the Forge project.

The way I'd try it would be to get the computer to look for creatures with a power or toughness higher than their converted mana cost or those whose power/toughness plus number of abilities is equal to or greater than their converted mana cost.

Removal...I'd say that removal should look at colour, then effect, then compare the CMC to a value set for each colour (4 mana removal is good for white, crap for blue).

Spells that deal damage should compare CMC to damage.

Then tell the computer what order to prioritise (for a draft I'd go with creatures > everything else) and if it's got two possible cards of the same priority the highest usefulness number minus CMC wins.

Also tell the computer to pick freely until it reaches 2-3 colours in hand, then restrict future picks to those colours or colourless.

Unknown said...

You can train your drafting AI by using Reinforcement Learning or Neural Networks for example. I'd go with the first :)

Raufbold said...

Well, I've posted a message about quest and draft modes here recently (don't know where has it gone). I spoke about how fun is the quest mode and how not fun is the draft. I regularly play drafts with friends in real life and it is one of my favorite formats. But programming the computer to think it over... it seems to be almost impossible.
But then I don't mind it at all. Forge is still the best MTG program around. The only thing it really lacks is the network mode to play with friends.
Keep on good work!

P.S. Illusions of Grandeur card is glitchy. When I donate it to the opponent and Illusions eventually leaves play, it is me who loses 20 life, not the opponent...

Anonymous said...

I think you may use genetic coding as well. If Forge users are letting their drafts to be uploaded as me, you may take them and their statistics too and update AI's choosing style. You ll be only coding how to read given information and a way to compress data.

That way AI will learn through our experience and it will be good at draft as well as Forge community's average player. Same can be applied to Sealed Decks too.

An example to what i tried to tell. You know, I know some coding but some. So this may be more complicated, but at least you don't have to figure out how to teach that to AI. Draft players will do.

Anonymous said...

I have a few suggestion..I am not good in programming but here are some my idea can you compare the card that being build by human. In that way you can create a good AI counter attack deck.

I also would like to suggest to add some restriction to the system where one deck can be build base on one expansion. Example if you choose invasion means all the card must be in invasion expansion only other cards are ban.

I really like this Forge project especially the quest is really interesting idea you have there..sorry for my bad english hope this few idea can lit some light to a better improvement

dismal_denizen said...

"Programming a better drafting AI seems impossible because you need to create a specific formula for the computer to follow."

I have to disagree with this statement. As much as I love Forge, the drafting AI is *terrible* and as such improving on it should not be that hard. In particular, well-defined draft formats such as triple RoE should not leave you with a 14th pick Ulamog (this is just an example, but that kind of thing is extremely common). Even if the deck construction itself is difficult for AI, the card selection aspect has been pretty well implemented by existing sites with draft bots and demonstrates how Forge could be improved in the future. At the moment neither card-picking nor playing skill is tested much - addressing the former would certainly be a step in the right direction.

By considering defined draft formats individually (block drafts, etc) an overall card-ranking (to make sure bombs are snapped up early) coupled with a per-archetype ranking (so the AI can construct proven, playable decks) can be created. Lots of data is out there, and it appears to be lost on Forge at the moment. As for drafting with the entire card pool... that seems a lot harder for a much lesser reward. I wouldn't worry too much about it.

Colours definitely need to be restricted more for the AI as well - they get colour-screwed so often. Contrary to an earlier comment, having formulae based on power vs CMC, etc seems like a bad idea. User data is a much better way to go, as well as the learning algorithms hinted at in other comments.

I understand that this comment is a bit critical, but I hope it's taken as intended - I care about this program and want to see it get even better.

PS I draft occasionally in real life and find it to be one of the most fun things you can do with Magic cards.

Angels said...

He replied, “Does a submarine swim?”
Great answer))) FOr me it's very hard to understand programming and I can't draw it, but many people create it without any problems, question is what proportions are among people who can and who can't

Forge said...

Thanks for the many suggestions.I still have fun drafting even though the AI is pretty bad at it.

I do read some theoretical stuff and I know (some) about many of the technology mentioned such as neural networks, genetic algorithms, and reinforcement learning.

Part of the problem is that AI programming is unlike other coding (read files, graphic stuff) and is especially complicated.

My bachelor's degree in computer didn't touch AI. Of course my bachelor's degree didn't cover "read world programming" and we only wrote 100 or 200 lines of code per assignment.

(Well...technically the cobol assignment were longer because it just takes more lines of cobol to do simple stuff.)

Zach Howell said...

It might be easier to make the player draft/seal two decks and then pilot one. That's how I've been drafting right now, but the AI still gives me some really dumb stuff - like bomb rares later in draft.
To make the drafting better, simply let the player import drafts from other programs like which lets people export decks as Apprentice or MWS. Then just read those files in and go! I have no idea how responsive these people are, but someone could also try contacting to see if they could let people download AI pools. There are a fair number of these drafting sites & some of them might be interested!

Anonymous said...

@Raufbold Illusions of Grandeur is now fixed. Thanks.

Anonymous said...

I think you definitely need a heuristic to make a decent drafting/sealed AI.

"Fuzzy logic" could also be used to pick between cards that have seemingly equivalent power levels when the choice is not obvious.

I think you'd want something that basically goes like:

Figure out what colors have enough creatures to support a deck.

Set up a "pool" to fill with 2-drops, 3-drops, 4- and 5-+ drops.

Fill out a pool of spells and spell-types (removal) that need to be filled.

Evaluate which colors best fill the pools (can probably just brute force this by doing all color combinations (5! I believe, or 120, could be wrong)), then pick whichever combination fills the pools best ("best" being defined by filling the pools optimally in some way, such as having exactly the amount in each pool etc.).

Evaluate the cost-ramp for each potentially best color combination (as determined by whatever results you get out of the previous step filling the pools), and figure out where the pools are short/heavy, then modify (i.e., if the pool is heavy, figure out what the distribution of mana costs is and swap some out from different parts of the distribution).

Ideally, the drafting heuristic would be done in a scripting language so that it could be modified and improved on by players and quickly iterated on in general. Certain functionality would need to call into Java functions for speed (filling pools and other evals).

Just some thoughts off the top of my head.

Anonymous said...

I posted above, but one thing (a bit janky, really, but it might be interesting) would be to have the AI take into account online data regarding the card to make a decision on whether or not the card is considered to be "good" or not.

I think you'd want to do something where you first consider rarity (in picking bombs at least) THEN take into account the current price of the card, as more expensive rares/mythic rares are typically better cards than their less expensive counterparts.