120 likes | 338 Views
Pertemuan 15 Game Playing. Matakuliah : T0264/Intelijensia Semu Tahun : Juli 2006 Versi : 2/1. Learning Outcomes. Pada akhir pertemuan ini, diharapkan mahasiswa akan mampu : << TIK-99 >> << TIK-99>>. Outline Materi. Materi 1 Materi 2 Materi 3 Materi 4 Materi 5. 12.1. Overview.
E N D
Pertemuan 15Game Playing Matakuliah : T0264/Intelijensia Semu Tahun : Juli 2006 Versi : 2/1
Learning Outcomes Pada akhir pertemuan ini, diharapkan mahasiswa akan mampu : • << TIK-99 >> • << TIK-99>>
Outline Materi • Materi 1 • Materi 2 • Materi 3 • Materi 4 • Materi 5
12.1. Overview • Mudah untuk menentukan ukuran kesuksesan dan kegagalan (menang atau kalah). • Perhatikan permainan Catur (chess). • Rata-rata setiap node bercang sebanyak 35. Tiap pemain rata-rata bergerak 50 kali. Sehingga total dalam satu pohon permainan akan terdapat posisi sebanyak 35100. • Netoda-metoda yang digunakan dalam game : • Depth-limited search. • Statistic evaluation function. • Credit assignment problem. • Minimax search algorithm.
A B C D (8) (3) (-2) A B C D K E F G I H J (9) (0) (0) (-3) (-6) (-2) (-4) 12.2. Prosedur pencarian MINIMAX • One-Ply Search : • Two - Ply Search :
Prosedur pencarian MINIMAX • Backing Up the Values of a Two-Ply Search
Algorithm : MINIMAX (Position,Depth, Player) 1. If DEEP-ENOUGH(Position, Depth), then return the structure VALUE = STATIC(Position, Player); PATH = nil This indicates that there is no path from this node and that its value is determined by static evaluation function. 2. Otherwise,generate one more ply of the tree by calling the function MOVEGEN(Position,Player) and setting SUCCESORS to the list it returns. 3. If SUCCESORS is empty, then there are no moves to be made, so return the structure that would have been returned if DEEP-ENOUGH had returned true.
Algorithm contd’ 4. If SUCCESORS is not empty, then examine each element in turn and keep track of the best one. This is done as follows. Initialize BEST-SCORE to the minimum value that STATIC can return. It will be update to reflect the best score that can be achieved by an element of SUCCESORS. For each element SUCC of SUCCESORS, do the following : • Set RESULT- SUCC to MINIMAX(SUCC, Depht + 1, OPPOSITE(Player)) This recursive call to MINIMAX will actually carry out the exploration of SUCC. • Set NEW-VALUE to - VALUE(RESULT-SUCC). This will cause it to reflect the merits of the position from the opposite perspective from that of the next lower level. • If NEW-VALUE > BEST-SCORE, then we found a succesor that is better than any that have been examined so far. Record this by doing the following :
Algorithm contd’ • Set BEST-SCORE to NEW-VALUE. • The best known path is now from CURRENT to SUCC and then on to the appropriate path down from SUCC as determined by the recursive call to MINIMAX. So set BEST-PATH to the result of attaching SUCC to the front of PATH(RESULT-SUCC). 5. Now that all the succesors have been examined, we know the value of Position as well as which path to take from it. So return the structure VALUE = BEST-SCORE PATH = BEST-PATH
MAX B A C D -6 -2 -2 -4 MIN E F G J K L H 9 -6 0 -2 -4 -3 1 I 0 Prosedur pencarian MINIMAX
Prosedur pencarian MINIMAX • Pada MINIMAX terdapat 2 prosedur yang dijalankan yaitu : maximize dilakukan oleh “saya” dan minimize dilakukan oleh “lawan”. • Diperlukan fungsi evaluasi statis yang menyatakan nilai yang mungkin didapat oelh pemain. • Pada level pertama “saya” melakukan maximize dan pada level kedua “lawan” melakukan minimize. • Kelemahan metoda MINIMAX adalah harus mengunjungi semua node yang ada sebelum memutuskan langkah yang diambil.
<< CLOSING >> Untuk memperbaiki kelemahan metoda MINIMAX digunakan -Cutoff atau -pruning End of Pertemuan 15 Good Luck