124/ Adversarial Search جستجوی تخاصمی Chapter 6 Section 1 – 4 Modified by Vali...

24
124/ Adversarial Search ی م ص ا خ تی و ج ت س جChapter 6 Section 1 – 4 Modified by Vali Derhami

Transcript of 124/ Adversarial Search جستجوی تخاصمی Chapter 6 Section 1 – 4 Modified by Vali...

124/

Adversarial Searchتخاصمی جستجوی

Chapter 6

Section 1 – 4

Modified by Vali Derhami

224/

Outline

• Optimal decisions

• α-β pruning

• Imperfect, real-time decisions

324/

Games vs. search problems

• "Unpredictable" opponent specifying a move for

every possible opponent reply

• . است محدود زمان ها بازی اکثر در

تصمیم • بهترین آوردن بدست است Optimalممکن

Decision . می انتخاب معقول حل راه لذا نباشد پذیر امکان

شود.

•. >= شود زده تخمین باید هدف زمانی های محدودیت

424/

جستجو مسأله یک عنوان به بازی

• : حرکت نوبت تعیین و بازی صفحه موقعیت اولیه حالتکننده MAXفرض: شروع

• :) بازیکن ) هر مجاز های حرکت عملگرها پسین تابع•. : بازی اتمام تعیین پایانی آزمون•. : پایانی حاالت به مقدار اختصاص سودمندی تابع

– : شدن برنده مقدار MAXباالترین– : شدن برنده مقدار ترین MINپایین– : تساوی میانی مقدارMAX حرکات به توجه با که بیابد اقتضایی راهبرد یک باید

MIN. بشود آن شدن برنده به منجر

524/

Game tree )2-player, deterministic, turns(

624/

Minimax• Perfect play for deterministic games

حریف حرکت بهترین مقابل در یافتنی دست امکان بهترینخودمان سطح در و مینیمم حریف سطح . (MAX)در گیریم می

• E.g., 2-ply game:

• Idea: choose move to position with highest minimax value = best achievable payoff against best play

724/

Minimax algorithm

824/

Properties of minimax

• Complete? Yes )if tree is finite(• Optimal? Yes )against an optimal opponent(

! است بهینه هم روش کند، بهینه حرکت حریف اگر• Time complexity? O)bm(

•. شود بررسی باید جستجو درخت کل• Space complexity? O)bm( )depth-first exploration(• For chess, b ≈ 35, m ≈100 for "reasonable" games

exact solution completely infeasible

••

924/

α-β pruning example

1024/

α-β pruning example

1124/

α-β pruning example

1224/

α-β pruning example

1324/

α-β pruning example

1424/

Properties of α-β

• Pruning does not affect final resultندارند تاثیری نهایی نتیجه در که هایی هرسشاخه

• Good move ordering improves effectiveness of pruningdoubles depth of search

α :) گره ) برای شده یافت مقدار بهترین مقدار MAXبیشترینβ :) گره) برای شده یافت مقدار بهترین مقدار MINکمترین

مقدار از جاری گره مقدار آنکه محض سطح ) αبه سطح) βو( MAXبرای ( MINبرای. شوند می هرس گره از مانده باقی های شاخه شود بدتر

• With "perfect ordering," time complexity = O)bm/2(

1524/

Why is it called α-β?

• α is the value of the best )i.e., highest-value( choice found so far at any choice point along the path for MAX

• If v is worse than α, MAX will avoid it prune that branch

• Define β similarly for MIN•

1624/

The α-β algorithm

1724/

The α-β algorithm

1824/

Example

1924/

Resource limitsمنابع های محدودیت

بازی درخت کامل بررسی امکان پیچیده مسایل در . واضح نمونه ندارد وجود فضا و زمان مشکل بخاطر

است شطرنج مساله .آنStandard approach:• cutoff test: ) هدف آزمون جای به قطع محل )تست

e.g., depth limit )perhaps add quiescence search(

• evaluation function ) تابع بجای ارزش تخمین)سودمندی= estimated desirability of position

2024/

Evaluation functions

• For chess, typically linear weighted sum of features

Eval(s) = w1 f1)s( + w2 f2)s( + … + wn fn)s(

• e.g., w1 = 9 with

f1)s( = )number of white queens( – )number of black queens(, etc.

•: ارزش تخمین تابع یک های ویژگی–. کند مرتب سودمندی تابع همانند را انتهایی حاالتکم – محاسباتی حجمشدن – برنده شانس به مناسب وابستگی

2124/

2224/

Cutting off search

MinimaxCutoff is identical to MinimaxValue exceptشکل در ها جایگزینی اگر است هم مانند روش 17و 16اسالیدهای 7-6دو

شود .داده1. Terminal? is replaced by Cutoff?2. Utility is replaced by Eval

Does it work in practice?باشد داشته ثانیه در نود میلیون یک ارزیابی توان ما کامپیوتر اگرbm = 106, b=35 m=4

4-ply lookahead is a hopeless chess player!– 4-ply ≈ human novice– 8-ply ≈ typical PC, human master– 12-ply ≈ Deep Blue, Kasparov

2324/

Deterministic games in practice• Checkers: Chinook ended 40-year-reign of human world champion

Marion Tinsley in 1994. Used a precomputed endgame database defining perfect play for all positions involving 8 or fewer pieces on the board, a total of 444 billion positions.

• Chess: Deep Blue defeated human world champion Garry Kasparov in a six-game match in 1997. Deep Blue searches 200 million positions per second, uses very sophisticated evaluation, and undisclosed methods for extending some lines of search up to 40 ply.

• Othello: human champions refuse to compete against computers, who are too good.

• Go: human champions refuse to compete against computers, who are too bad. In go, b > 300, so most programs use pattern knowledge bases to suggest plausible moves.

2424/

Summary

• Games are fun to work on!

• They illustrate several important points about AI

• perfection is unattainable must approximate

• good idea to think about what to think about

• بخوانید خودتان را شانس عامل دارای بازیهای