1 / 44

חיפוש

חיפוש. בינה מלאכותית אבי רוזנפלד. סוגי חיפוש כלליים. UNINFORMED SEARCH -- חיפושים לא מיודעים במרחי מצבים BFS DFS INFORMED SEARCH – חיפושים מיודעים Dijkstra GREEDY A * http :// en.wikipedia.org/wiki/Dijkstra's_algorithm HILLCLIMBING. חיפוש נגד יריב (משחקים).

Télécharger la présentation

חיפוש

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. חיפוש בינה מלאכותית אבי רוזנפלד

  2. סוגי חיפוש כלליים • UNINFORMED SEARCH -- חיפושים לא מיודעים במרחי מצבים • BFS • DFS • INFORMED SEARCH – חיפושים מיודעים • Dijkstra • GREEDY • A* • http://en.wikipedia.org/wiki/Dijkstra's_algorithm • HILLCLIMBING

  3. חיפוש נגד יריב (משחקים) • איזה מידע יש בתוך המודל (עץ) • איך היריב משחק? • אופטימאלי / לא אופטימאלי • איך אפשר להוריד את מרחב החיפוש • Alpha / Beta Pruning (גיזום של העץ) • יצירת החישוב (Evaluation function) • The Horizon Effect

  4. סוגי משחקים

  5. Game tree (2-player, deterministic, turns)

  6. Minimax • Create a utility function • Evaluation of board/game state to determine how strong the position of player 1 is. • Player 1 wants to maximize the utility function • Player 2 wants to minimize the utility function • Minimax tree • Generate a new level for each move • Levels alternate between “max” (player 1 moves) and “min” (player 2 moves)

  7. Minimaxעץ ה Max Min Max Min

  8. Minimax Tree Evaluation • הנחה: יש פונקציה UTILITY(לא הנחה פשוטה) • כל צד רוצה למקסם את הצד שלו • יש מספיק מידע בתוך העץ לעשות את החישובים

  9. עץ של המשחק (Minimax) Max Min Max 100 Min 23 28 21 -3 12 4 70 -4 -12 -70 -5 -100 -73 -14 -8 -24

  10. עץ של המשחק (Minimax) Max Min Max 28 -3 -8 12 70 -4 100 -73 -14 Min 23 28 21 -3 12 4 70 -4 -12 -70 -5 -100 -73 -14 -8 -24

  11. עץ של המשחק (Minimax) Max Min -4 -3 -73 Max 21 -3 -8 12 70 -4 100 -73 -14 Min 23 28 21 -3 12 4 70 -4 -12 -70 -5 -100 -73 -14 -8 -24

  12. עץ של המשחק (Minimax) Max -3 Min -4 -3 -73 Max 21 -3 -8 12 70 -4 100 -73 -14 Min 23 28 21 -3 12 4 70 -4 -12 -70 -5 -100 -73 -14 -8 -24

  13. Minimax Evaluation • Given average branching factor b, and depth m: • A complete evaluation takes time bm • A complete evaluation takes space bm • Usually, we cannot evaluate the complete state, since it’s too big • Instead, we limit the depth based on various factors, including time available.

  14. עוד דוגמא שלMinimax

  15. גיזום של α-β • אני יודע שאתה יודע שאני יודע... • שווה להוריד אופציות כדי שאפשר לחפש יותר • הפתרון: גיזום • כל צד מוריד דבר שהוא בטוח שהצד השני

  16. הצד של α ו • ל α : (שמחפשים )MAX, אם הערך הנוכחי קטן מערך בענף אחר, תוריד את הענף (PRUNE) • ל β, (שמחפשים )MIN , אם הערך הנוכחי גדול מערך בענף אחר, תוריד את הענף (PRUNE)

  17. α-β pruning example

  18. α-β pruning example

  19. α-β pruning example

  20. α-β pruning example

  21. α-β pruning example

  22. a Cut example Max -3 Min -3 -4 -73 Max 21 -3 12 70 -4 100 -73 -14

  23. a Cut example Max • Depth first search along path 1 Min Max 21 -3 12 -70 -4 100 -73 -14

  24. a Cut example Max • 21 is minimum so far (second level) • Can’t evaluate yet at top level Min 21 Max 21 -3 12 -70 -4 100 -73 -14

  25. a Cut example Max • -3 is minimum so far (second level) • -3 is maximum so far (top level) -3 Min -3 Max 21 -3 12 -70 -4 100 -73 -14

  26. a Cut example Max • 12 is minimum so far (second level) • -3 is still maximum (can’t use second node yet) -3 Min 12 -3 Max 21 -3 12 -70 -4 100 -73 -14

  27. a Cut example Max • -70 is now minimum so far (second level) • -3 is still maximum (can’t use second node yet) -3 Min -70 -3 Max 21 -3 12 -70 -4 100 -73 -14

  28. a Cut example Max • Since second level node will never be > -70, it will never be chosen by the previous level • We can stop exploring that node -3 Min -70 -3 Max 21 -3 12 -70 -4 100 -73 -14

  29. a Cut example Max • Evaluation at second level is -73 -3 Min -70 -3 -73 Max 21 -3 12 -70 -4 100 -73 -14

  30. a Cut example Max • Again, can apply a cut since the second level node will never be > -73, and thus will never be chosen by the previous level -3 Min -70 -3 -73 Max 21 -3 12 -70 -4 100 -73 -14

  31. a Cut example Max • As a result, we evaluated the Max node without evaluating several of the possible paths -3 Min -70 -3 -73 Max 21 -3 12 -70 -4 100 -73 -14

  32. b cuts • Similar idea to a cuts, but the other way around • If the current minimum is less than the successor’s max value, don’t look down that max tree any more

  33. b Cut example Min • Some subtrees at second level already have values > min from previous, so we can stop evaluating them. 21 Max 21 70 73 Min 21 -3 12 70 -4 100 73 -14

  34. עובדa-b Pruningלמה • לצד של MAX, 70 יותר טוב • אבל, אין מצב שMIN ייקח אותו במקום 21. 21 21 21 -3 70 12 70 -4 100

  35. a-bPruningהיתרון ל • אין השפעה על תוצאת MINIMAX • כן עוזר לרדת יותר עמוק בתוך העץ • מאוד תלוי ב"מזל" בסידור של העץ • במצב הכי טוב, הוא מכפיל הגודל שאפשר לחפש בו

  36. איך בונים את העצים?! • מאוד תלוי במשחק • יש צורך לראות את ה-כ-ל עד סוף המשחק (!) • ברמה הפשוטה: 1 אם אני מנצח, 1- אם אתה מנצח, 0 במצב תיקו. • ברוב המשחקים יש ה-ר-ב-ה מצבים באמצע • שמחט • דמקה • רצף ארבע (!)

  37. בניית פונקציות UTILITY למשחק • לכל מצב יש ציון • בשחמט מלכה שווה 10, אביר שווה 3 וכו' • בהרבה מקרים, הערכים הסתברותיים. • utility = aa + bb + cc

  38. Utility Function • 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.

  39. הגבלות בפועל • לא ניתן לראות קדימה עד סוף המשחק (אין סוף) • בונים עוץ בגודל מסויים (Cut Off) • בלי גיזום ALPHA BETA, הCut Off בשחמט למחשב נורמאלי הוא "רק" גובה של 4 • שזה שווה לבנאדם רגיל • אם ALPHA BETA, זה מגיע ל8! • אבל Kasparov וDeep Blue עבדו עד לגובה של 12.

  40. בהרבה מקרים גם הערכה היא "מספיק טובה" • הערכים לא משפעים על איזה פעולה לעשות!

  41. 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 443,748,401,247 positions. • A precomputed endgame database? Would it be possible to extend the “endgame” all the way back to the beginning of the game, essentially “solving” checkers?

  42. Checkers is Solved Originally published in Science Express on 19 July 2007 Science 14 September 2007: Vol. 317, no. 5844, pp. 1518 – 1522 Jonathan Schaeffer (University of Alberta), Neil Burch, Yngvi Björnsson, Akihiro Kishimoto, Martin Müller, Robert Lake, Paul Lu, Steve Sutphen The game of checkers has roughly 500 billion billion possible positions (5 x 1020). The task of solving the game, determining the final result in a game with no mistakes made by either player, is daunting. Since 1989, almost continuously, dozens of computers have been working on solving checkers, applying state-of-the-art artificial intelligence techniques to the proving process. This paper announces that checkers is now solved: Perfect play by both sides leads to a draw. This is the most challenging popular game to be solved to date, roughly one million times as complex as Connect Four. Artificial intelligence technology has been used to generate strong heuristic-based game-playing programs, such as Deep Blue for chess. Solving a game takes this to the next level by replacing the heuristics with perfection.

  43. Deterministic games in practice • 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. Rybka was the 2008 and 2009 computer chess champion (uses an off-the-shelf 8-core 3.2GHz Intel Xeon processor), but was stripped of its titles for having plagiarized two other programs… • Othello: Logistello beats human world champion in 1997; 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.

  44. סיכום • משחקים הם לא משחק ילדים לאנשי מערכות מידע... • איך הסוכן שלכם יעבוד!!!

More Related