In: Computer Science
In a game, if you base your moves on the minimax algorithm, you cannot do worse than the minimax score, even if your real opponent is not using minimax as their strategy.
Minimax is a kind of backtracking algorithm that is used in decision making and game theory to find the optimal move for a player, assuming that your opponent also plays optimally.
In Minimax the two players are called maximizer and minimizer. The maximizer tries to get the highest score possible while the minimizer tries to do the opposite and get the lowest score possible.
For two player games, the minimax algorithm is such a tactic, which uses the fact that the two players are working towards opposite goals to make predictions about which future states will be reached as the game progresses, and then proceeds accordingly to optimize its chance of victory. The theory behind minimax is that the algorithm's opponent will be trying to minimize whatever value the algorithm is trying to maximize (hence, "minimax"). Thus, the computer should make the move which leaves its opponent capable of doing the least damage.
Minimax is the method that minimizes the maximum possible loss.
At each step
of the game the assumption is made that player A is trying to
maximize the chances
of A’s winning, while player B is trying to minimize the chances of
A’s winning. We
call the player A—MAX, the player B -– MIN, and we assume that MAX
starts the
game. The player MAX makes the move that maximizes the minimum
value of the position resulting from the possible next moves of the
opponent and assigns a value
to each of his or her legal moves. Minimax assumes that opponent
always chooses
the best move, but opponents are human and may depart from
rationality – they can
choose an inferior move.
Though the actual endgame is many turns away, it will choose the maximum of those three for the best possible result. Note that, if the opponent does not behave as predicted, the calculation can simply be re-run, taking the current state as the starting node, and a result as good (or better) than what was predicted will still be achieved.