# ALGORITMA MINIMAX PDF

Vamsi Sangam Hello people! In this post we will look at one of the most basic Artificial Intelligence algorithm, the MiniMax algorithm. MiniMax algorithm is used to implement basic AI or game logic in 2 player games. The most common scenario is implementing a perfect Tic-Tac-Toe player. So, in this article we will look at how to implement it.

 Author: Malasho Julabar Country: Namibia Language: English (Spanish) Genre: Education Published (Last): 24 February 2007 Pages: 301 PDF File Size: 12.22 Mb ePub File Size: 19.96 Mb ISBN: 484-4-36819-298-4 Downloads: 38591 Price: Free* [*Free Regsitration Required] Uploader: Gasida

Vamsi Sangam Hello people! In this post we will look at one of the most basic Artificial Intelligence algorithm, the MiniMax algorithm. MiniMax algorithm is used to implement basic AI or game logic in 2 player games.

The most common scenario is implementing a perfect Tic-Tac-Toe player. So, in this article we will look at how to implement it. Definition — Given that two players are playing a game optimally playing to win , MiniMax algorithm tells you what is the best move that a player should pick at any state of the game.

So, the input to MiniMax algorithm would be — State of the game. Whose turn it is. And the output would be the best move that can be played by the player given in the input. If O wins, the score is decreased by If it is a draw, then the score remains unchanged. So now, the bigger the number score has, the better it is for X, which means X will try to maximize score as much as possible. Similarly, the lesser the score, the better it is for O, so O will try to minimize the score as much as possible.

To understand this better, imagine you are player X and this is the current state of your game — So if you are in state 1 from the above diagram , you have 3 possible moves which lead to state 2, 3 and 4. So conceptually we know that player X must choose the winning move. This is done programmatically bu choosing the move which will return the maximum score. So, X will always try to maximize the score and will always choose that move which will fetch X the maximum score.

Thus, in the above scenario X chooses the move which goes to state 2. Now, to make sure you understand both sides of this algorithm. Can you draw a state diagram which will depict all the possible moves and the scores which will be returned by playing them? You can! You should get a diagram like this — Did you get a diagram like this? Player O has 3 possible moves and the scores are — if you choose to go to state 2. Player O will always try to minimize the score, so player O must select a move which will either lead to state 2 or 3 to win.

Firstly, have a clarity on the smaller pieces of logic and write methods for them first. You will need these 3 helper methods for your code — printGame game — which prints the state of Tic-Tac-Toe game.

So now you have a little clarity over the smaller pieces, code them first. Now, you are ready to write the MiniMax algorithm method. We can make a new class to return all the information we need. When in doubt come back and read the MiniMax algorithm theory and the implementation tips. Remember, you are trying to write the code for an ideal Tic-Tac-Toe player here, so you need to write the starter code for simulating a 2-player Tic-Tac-Toe game.

Take the case given below — So for the above case, player O will lose no matter the decision taken. If you think about this, if we apply the Minimax algorithm we formed so far, in this case Player O would choose state 2.

This is because state 2 is the first state it programmatically encounters while computing the minimum value. How do we implement this in our algorithm? So, if a player wins by taking more turns, the gain would be lesser and if the player took lesser turns, the gain would be more. Now our TicTacToe bot is an ideal bot! If you get stuck, you can refer to my code — Link to code — GitHub Congrats on taking your first step to build your dream AI!

Happy Coding!

FRANK VAHID AND TONY GIVARGIS PDF

## Algoritma Minimax Untuk Kecerdasan Buatan Dalam Permainan : Contoh Program + Source Code

Sistem seperti ini umumnya dianggap komputer. Kecerdasan diciptakan dan dimasukkan ke dalam suatu mesin komputer agar dapat melakukan pekerjaan seperti yang dapat dilakukan manusia. Beberapa macam bidang yang menggunakan kecerdasan buatan antara lain sistem pakar, permainan komputer games , logika fuzzy, jaringan syaraf tiruan dan robotika. Penelitian dalam AI menyangkut pembuatan mesin untuk mengotomatisasikan tugas-tugas yang membutuhkan perilaku cerdas. Termasuk contohnya adalah pengendalian, perencanaan dan penjadwalan, kemampuan untuk menjawab diagnosa dan pertanyaan pelanggan, serta pengenalan tulisan tangan, suara dan wajah. Hal-hal seperti itu telah menjadi disiplin ilmu tersendiri, yang memusatkan perhatian pada penyediaan solusi masalah kehidupan yang nyata.

CGE 2028 PDF

## MiniMax Algorithm

Suppose each player has three choices and consider the payoff matrix for A displayed on the right. Assume the payoff matrix for B is the same matrix with the signs reversed i. Then, the minimax choice for A is A2 since the worst possible result is then having to pay 1, while the simple minimax choice for B is B2 since the worst possible result is then no payment. However, this solution is not stable, since if B believes A will choose A2 then B will choose B1 to gain 1; then if A believes B will choose B1 then A will choose A1 to gain 3; and then B will choose B2; and eventually both players will realize the difficulty of making a choice.

CALVARY HILLSONG CHORDS PDF

## Pengertian Algoritma Minimax

Teori Game dan Algoritma Minimax Posted by Unknown Rabu, 30 Maret 0 comments Menurut Wikipedia, Teori permainan adalah bagian dari ilmu matematika yang mempelajari interaksi antar agen, di mana tiap strategi yang dipilih akan memiliki payoff yang berbeda bagi tiap agen. Menururt Dimiyati , teori permainan game theory adalah bagian dari ilmu pengetahuan yang berkaitan dengan pembuatan keputusan pada saat ada dua pihak atau lebih berada dalam kondisi persaingan atau konflik. Pihak-pihak yang bersaing ini disumsikan bersifat rasional dan cerdas, artinya masing-masing pihak akan melakukan strategi tindakan yang rasional untuk memenangkan persaingan itu, dan masing-masing pihak juga mengetahui strategi pihak lawannya. Selanjutnya pihak ini disebut pemain.

LA HERMANA SAN SULPICIO PDF

## IMPLEMENTASI ALGORITMA MINIMAX PADA PERMAINAN CATUR

Algoritma Minimax akan selalu mengecek semua kemungkinan yang ada sampai akhir permainan itu dilakukan, kemudian pengecekan tersebut akan menghasilkan pohon permainan yang berisi semua kemungkinan-kemungkinan tersebut. Pada permainan yang berbasis Minimax seperti catur, tentunya dibutuhkan resource yang sangat besar untuk memproses pencarian pohon permainan tersebut, karena kombinasi kemungkinan untuk permainan catur pada setiap gerakannya banyak sekali. Algoritma Minimax bekerja secara rekursif dan mampu menganalisis segala kemungkinan pada permainan yang dimanfaatkan untuk menghasilkan keputusan terbaik, sehingga dapat membuat lawan mengalami kerugian Minimum. Semua strategi lawan akan dihitung dengan algoritma yang sama terus-menerus. Pada langkah pertama komputer akan menganalisis seluruh pohon permainan, kemudian untuk setiap langkahnya, komputer akan memilih langkah yang akan membuat lawan mendapatkan kerugian Minimum dan membuat komputer itu sendiri mendapatkan keuntungan Maksimum. Dalam rangka untuk menentukan keputusan terbaik tersebut, dibutuhkan suatu nilai yang merepresentasikan kerugian atau keuntungan yang akan diperoleh jika langkah tersebut dipilih. Oleh karena itu, algoritma Minimax menggunakan sebuah fungsi Heurisitic untuk mengevaluasi nilai sebagai nilai yang merepresentasikan hasil permainan yang akan terjadi jika langkah tersebut dipilih, sebagai contoh, pada permainan Tic Tac Toe, digunakan nilai 1,0,-1 untuk mewakilkan hasil akhir permainan berupa menang, seri, dan kalah.