Minimax
Now, to calculate the best move in a given game state, the algorithm puts 2 agents- Minimizer and Maximizer to play against each other. Both these agents play based on calculating the best possible move. The Minimizer tries to make Maximizer lose and vice versa. In this way, the Minimizer and Maximizer simulates an entire game, which is then repeated for all sets of possible moves in the given game state. After the algorithm does all the simulation, it then chooses the move which created highest probability of win with lowest no. of moves. Hence it returns the next best move. And then the computer plays the move.