## Monday, November 2, 2009

### Why Programming AI is Hard - Part 2

I'm going to continue my thoughts about the AI algorithm min-max. Previously I said, "In order to use the min-max algorithm you have to be able to generate possible moves for both players."

Ideally you would generate all possible moves for both players until the game ends. Usually generating all possible moves is impossible even for simple games like checkers, so the trick is to use an "evaluation" function that evaluates the game. The evaluation function basically determines which player is winning.

A rough analogy would be a person's life points as a very simple evaluation function. Usually the person with the highest life points is winning, notice that I said "usually". A good evaluation function for Magic would look at both players' life totals, cards in hand and creatures in play to determine which player has the best chance of winning. Needless to say that the evaluation function for Magic would be very complicated considering creatures like Keiga, the Tide Star and Royal Assassin which can win games by themselves.

Creating a good evaluation function is very important. If your evaluation function is lousy, then your AI will be lousy. (There is probably a better word than "lousy" but it conveys the right idea.)

As you may or not remember, the XBox 360 game Duels of the Planeswalkers used min-max. You can read about the AI engine that the game uses here.

p.s.
Technically min-max can only be used for games that don't have any "hidden information" and in Magic, the cards in your hand and deck are "hidden information". Read my *astonishing*, earth-shattering post on Wednesday that solves the hidden information problem.

p.p.s. I just picked Phelddagrif because it had a weird picture.

Silly Freak said...

okay, when you come back to it, i won't say too much^^ i just wanted to note one thing:
the evaluation function roughly represents that what you do if you think about "is this move beneficial?"
this includes that an evaluation function can only use the information that the player sees, so
"A good evaluation function for Magic would look at both players' life totals, cards in hand and creatures in play to determine which player has the best chance of winning"
can of course only apply to your own hand (sort of... i don't want to take anything away from forge's next post)

AI is an interesting thing, as long as you don't try to implement it. chances are you get frustrated...

Huggybaby said...

"AI is an interesting thing, as long as you don't try to implement it."

Man, that's funny! lol

Anonymous said...

...If you do have hidden information, then you are dealing with probabilities.So you could/can change Min Max to deal with them. I wonder how much stronger could your AI be, if it could "go trough" your oponent deck cards before the duel... So AI would known your opponent cards before the game (not the order, just types and how many of them are in the deck) - AI should then be better prepared (strategy) for duel... But that could be difficult to implement... well maybe just an idea....

Rob Cashwalker said...

There's not much preventing the AI from cheating by peeking at exactly the cards in hand and deck... just the integrity of the developers. Even WITH that information, assigning a threat level to those cards is sufficiently difficult to make it useful information. Might as well just use the public information as best as possible.

Forge said...

My "astonishing answer" to the hidden information problem is just let the AI see everything. And the only "problem" is that the AI might become impossible to beat, which I doubt because the actual programming is complicated.

¥倶楽部 said...

ライブチャット said...

スタービーチ said...

グリー said...

SM度チェッカー said...

あなたのSM度を簡単診断、SM度チェッカーで隠された性癖をチェック！真面目なあの娘も夜はドS女王様、ツンデレなあの子も実はイジめて欲しい願望があるかも！？コンパや飲み会で盛り上がること間違いなしのおもしろツールでみんなと盛り上がろう

リッチセックス said...

gree said...

だれもが知っている日本で一番有名な出会い系スタービーチがついに復活、greeより面白い新生スタビをやってみませんか？理想のパートナー探し、合コンパーティーに興味がある方はぜひ無料登録してみてください

デリバリーホスト said...

リア友 said...

メル友らんどでは誰でも気軽にメル友が作れちゃう、参加無料でいつでも利用可能なコミュニティサイト♪ご近所の気の合うリア友や、真面目に彼氏彼女探しなど、楽しみ方は無限大！自分にぴったりの相手を見つけちゃおう

お家遊びに来てくれる人いないかなぁ？ said...

あなたのご近所の女の子たちと無料でカンタンにであえる家出掲示板！大学生・専門学生、まさかの女子○生まで！ちょっとしたお小遣い稼ぎに全国の女の子たちが殺到中！ノーピンクからちょっぴりHなお誘いまで…自分に合ったコを選んでメッセしちゃおう

モバゲー said...

セフレ専門出会い喫茶エンジョイラブは店舗型出会い喫茶 ENJOYグループのネット1号店としてオープンしました♪セフレ探しを目的とした出会いの専門店です。Hに満足していない女性達が多数登録。今すぐ即アポOK表示のHな女の子を新着順で紹介中です

mコミュ said...

mコミュで理想の恋人を見つけよう！某女性誌に紹介され、女の子の登録者が急増中です。新しい出会いの場としてあまり知られていない今ならメールの返信がすぐに返ってくるかも！？無料登録から始めてみよう

さびしがりやの素人女性や天然娘にメールやチャットで会話してあげるだけで儲かる新感覚のアルバイト「素人ホスト」！未経験者の方でも簡単、手軽に出来るお仕事です。詳細は当サイトでご確認ください

スタービーチ said...

ランク王国でもご紹介された右脳左脳チェッカー、天才肌を見分ける楽しい盛り上がりツールとして今、支持をうけております。みんなでやれば盛り上がる事は間違いなし診断結果でも全国ランキングなどにランクインされて面白さ倍増！話のネタに一度はどうぞ

セレブ said...

ゴージャスなリッチセレブリティ達のアダルトコミュニティーサイト！お金と時間に優雅なセレブ女性達はアダルトコミュで男性との秘密交際を楽しんでいるのです

スタービーチ said...

釦覀꟣芻菣芯맣莑볣莈諣莼鋦躢鷣膆臨ꪰ苣膌藣膡飣膳鿣芹뿣莼鏣莼臣膮ꧦ뒻臯벁诣莥볣芹뿣莼鏣莼臣膧ꫤ붓鏣膮꟣膂蓣芒鿦蒟韣膦诣膕