Adversarial Search جستجوی تخاصمی Chapter 6 Section 1 – 4 Modified by Vali Derhami 1/24 Outline • Optimal decisions • α-β pruning • Imperfect, real-time decisions 2/24 Games vs. search problems • "Unpredictable" opponent specifying a move for every possible opponent reply • در اکثر بازی ها زمان محدود است. • ممکن است بدست آوردن بهترین تصمیم Optimal Decision امکان پذیر نباشد.لذا راه حل معقول انتخاب می شود. • محدودیت های زمانی=> هدف باید تخمین زده شود. 3/24 بازی به عنوان یک مسأله جستجو • • • • حالت اولیه :موقعیت صفحه بازی و تعیین نوبت حرکت فرض MAX :شروع کننده تابع پسین (عملگرها) :حرکت های مجاز هر بازیکن آزمون پایانی :تعیین اتمام بازی. تابع سودمندی :اختصاص مقدار به حاالت پایانی. – باالترین مقدار :برنده شدن MAX – پایین ترین مقدار :برنده شدن MIN – مقدار میانی :تساوی MAX باید یک راهبرد اقتضایی بیابد که با توجه به حرکات MINمنجر به برنده شدن آن بشود. 4/24 Game tree (2-player, deterministic, turns) 5/24 Minimax Perfect play for deterministic games • • Idea: choose move to position with highest minimax value = best achievable payoff against best play بهترین امکان دست یافتنی در مقابل بهترین حرکت حریف .( می گیریمMAX) در سطح حریف مینیمم و در سطح خودمان • E.g., 2-ply game: • 6/24 Minimax algorithm 7/24 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 • 8/24 α-β pruning example 9/24 α-β pruning example 10/24 α-β pruning example 11/24 α-β pruning example 12/24 α-β pruning example 13/24 Properties of α-β • Pruning does not affect final result • هرس شاخه هایی که در نتیجه نهایی تاثیری ندارند • Good move ordering improves effectiveness of pruning )• With "perfect ordering," time complexity = O(bm/2 doubles depth of search ( αبیشترین مقدار) :بهترین مقدار یافت شده در امتداد مسیر MAX (βکمترین مقدار) :بهترین مقدار یافت شده در امتداد مسیر MIN به محض آنکه مقدار گره جاری از مقدار ( αبرای سطح )MAXو (βبرای سطح )MIN بدتر شود شاخه های باقی مانده از گره هرس می شوند. 14/24 Why is it called α-β? • α is the value of the best (i.e., highestvalue) 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 • 15/24 The α-β algorithm 16/24 The α-β algorithm 17/24 Example 18/24 Resource limits محدودیت های منابع در مسایل پیچیده امکان بررسی کامل درخت بازی بخاطر مشکل زمان و فضا وجود ندارد .نمونه واضح آن مساله شطرنج است. Standard approach: (تست محل قطع به جای آزمون هدف) • cutoff test: )e.g., depth limit (perhaps add quiescence search (تخمین ارزش بجای تابع سودمندی) • evaluation function = estimated desirability of position 19/24 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. :• ویژگی های یک تابع تخمین ارزش .حاالت انتهایی را همانند تابع سودمندی مرتب کند حجم محاسباتی کم وابستگی مناسب به شانس برنده شدن – – – 20/24 21/24 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 22/24 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. 23/24 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 • بازیهای دارای عامل شانس را خودتان بخوانید 24/24
© Copyright 2025 Paperzz