Upload
vance-newman
View
23
Download
3
Embed Size (px)
DESCRIPTION
חיפוש. בינה מלאכותית אבי רוזנפלד. סוגי חיפוש כלליים. UNINFORMED SEARCH -- חיפושים לא מיודעים במרחי מצבים BFS DFS INFORMED SEARCH – חיפושים מיודעים Dijkstra GREEDY A * http :// en.wikipedia.org/wiki/Dijkstra's_algorithm HILLCLIMBING. חיפוש נגד יריב (משחקים). - PowerPoint PPT Presentation
Citation preview
חיפוש
מלאכותית בינהרוזנפלד אבי
סוגי חיפוש כלליים
•UNINFORMED SEARCH חיפושים לא מיודעים -- במרחי מצבים
–BFS–DFS
•INFORMED SEARCHחיפושים מיודעים – –Dijkstra–GREEDY–A*–http://en.wikipedia.org/wiki/Dijkstra's_algorithm–HILLCLIMBING
חיפוש נגד יריב )משחקים(
איזה מידע יש בתוך המודל )עץ(•איך היריב משחק?•
אופטימאלי / לא אופטימאלי–איך אפשר להוריד את מרחב החיפוש•
–Alpha / Beta Pruning)גיזום של העץ( (Evaluation functionיצירת החישוב )––The Horizon Effect
4
סוגי משחקים
5
Game tree (2-player, deterministic, turns)
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)
Minimax עץ הMax
Min
Max
Min
Minimax Tree Evaluation
)לא הנחה פשוטה(UTILITYהנחה: יש פונקציה •כל צד רוצה למקסם את הצד שלו•יש מספיק מידע בתוך העץ לעשות את •
החישובים
(Minimaxעץ של המשחק )Max
Min
Max
Min
100
-24-8-14-73-100-5-70-12-470412-3212823
(Minimaxעץ של המשחק )Max
Min
Max
Min
100
-24-8-14-73-100-5-70-12-470412-3212823
28 -3 12 70 -4 -73 -14 -8
(Minimaxעץ של המשחק )Max
Min
Max
Min
100
-24-8-14-73-100-5-70-12-470412-3212823
21 -3 12 70 -4 -73 -14 -8
-3 -4 -73
(Minimaxעץ של המשחק )Max
Min
Max
Min
100
-24-8-14-73-100-5-70-12-470412-3212823
21 -3 12 70 -4 -73 -14 -8
-3 -4 -73
-3
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עוד דוגמא של
α-βגיזום של
אני יודע שאתה יודע שאני יודע...•שווה להוריד אופציות כדי שאפשר לחפש יותר•הפתרון: גיזום•
כל צד מוריד דבר שהוא בטוח שהצד השני –
וαהצד של
קטן, אם הערך הנוכחי MAX : )שמחפשים (α ל•(PRUNEמערך בענף אחר, תוריד את הענף )
גדול , אם הערך הנוכחי MIN, )שמחפשים (βל •(PRUNEמערך בענף אחר, תוריד את הענף )
17
α-β pruning example
18
α-β pruning example
19
α-β pruning example
20
α-β pruning example
21
α-β pruning example
a Cut example
10021 -3 12 70 -4 -73 -14
-3 -4
-3
-73
Max
Max
Min
a Cut example
• Depth first search along path 1
10021 -3 12 -70 -4 -73 -14
Max
Max
Min
a Cut example
• 21 is minimum so far (second level)• Can’t evaluate yet at top level
10021 -3 12 -70 -4 -73 -14
Max
Max
Min 21
a Cut example
• -3 is minimum so far (second level)• -3 is maximum so far (top level)
10021 -3 12 -70 -4 -73 -14
Max
Max
Min -3
-3
a Cut example
• 12 is minimum so far (second level)• -3 is still maximum (can’t use second node yet)
10021 -3 12 -70 -4 -73 -14
Max
Max
Min -3
-3
12
a Cut example
• -70 is now minimum so far (second level)• -3 is still maximum (can’t use second node yet)
10021 -3 12 -70 -4 -73 -14
Max
Max
Min -3
-3
-70
a Cut example
• Since second level node will never be > -70, it will never be chosen by the previous level
• We can stop exploring that node
10021 -3 12 -70 -4 -73 -14
Max
Max
Min -3
-3
-70
a Cut example
• Evaluation at second level is -73
10021 -3 12 -70 -4 -73 -14
Max
Max
Min -3
-3
-70 -73
a Cut example
• Again, can apply a cut since the second level node will never be > -73, and thus will never be chosen by the previous level
10021 -3 12 -70 -4 -73 -14
Max
Max
Min -3
-3
-70 -73
a Cut example
• As a result, we evaluated the Max node without evaluating several of the possible paths
10021 -3 12 -70 -4 -73 -14
Max
Max
Min -3
-3
-70 -73
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
b Cut example
• Some subtrees at second level already have values > min from previous, so we can stop evaluating them.
10021 -3 12 70 -4 73 -14
Min
Min
Max 21
21
70 73
למהa-b Pruningעובד
יותר טובMAX, 70לצד של • ייקח אותו MIN, אין מצב שאבל•
.21במקום 100
21 -3
12 70 -4
21
21
70
a-b Pruningהיתרון ל
MINIMAXאין השפעה על תוצאת •כן עוזר לרדת יותר עמוק בתוך העץ–
מאוד תלוי ב"מזל" בסידור של העץ•במצב הכי טוב, הוא מכפיל הגודל שאפשר לחפש –
בו
!?איך בונים את העצים
מאוד תלוי במשחק•יש צורך לראות את ה-כ-ל עד סוף המשחק )!(•- אם אתה 1 אם אני מנצח, 1ברמה הפשוטה: •
במצב תיקו.0מנצח, ברוב המשחקים יש ה-ר-ב-ה מצבים באמצע•
שמחט–דמקה–רצף ארבע )!(–
למשחקUTILITYבניית פונקציות
לכל מצב יש ציון• וכו'3, אביר שווה 10בשחמט מלכה שווה •בהרבה מקרים, הערכים הסתברותיים.•
–utility = aa + bb + cc
• For chess, typically linear weighted sum of featuresEval(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.
38
Utility Function
לא ניתן לראות קדימה עד סוף המשחק )אין סוף(•(Cut Offבונים עוץ בגודל מסויים )• בשחמט למחשב Cut Off, הALPHA BETAבלי גיזום •
4נורמאלי הוא "רק" גובה של שזה שווה לבנאדם רגיל–
!8, זה מגיע לALPHA BETAאם •.12 עבדו עד לגובה של Deep Blue וKasparovאבל •
39
הגבלות בפועל
הערכים לא משפעים על איזה פעולה לעשות!•
40
בהרבה מקרים גם הערכה היא "מספיק "טובה
• 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?
41
Deterministic games in practice
Originally published in Science Express on 19 July 2007Science 14 September 2007:Vol. 317, no. 5844, pp. 1518 – 1522Jonathan Schaeffer (University of Alberta), Neil Burch, Yngvi Björnsson, Akihiro
Kishimoto, Martin Müller, Robert Lake, Paul Lu, Steve SutphenThe 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.
42
Checkers is Solved
• 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.
43
Deterministic games in practice
משחקים הם לא משחק ילדים לאנשי מערכות •מידע...
איך הסוכן שלכם יעבוד!!!•
44
סיכום