Lecture 13 Minimax Search
Games and Adversarial Search
Introduction to Competitive Environments
Competitive environments, where multiple agents have conflicting goals, naturally lead to adversarial search problems.
These settings are common in games but also apply to real-world scenarios like negotiations, strategic planning, and competitive bidding.
Focus: Deterministic, two-player, turn-taking, perfect information, zero-sum games.
We will primarily discuss games that have clear rules, involve two players alternating turns, provide complete information to both players, and have a zero-sum property (one player's gain is exactly the other's loss).
Brief Coverage: Multiplayer games are also relevant but will be discussed more briefly.
Key Game Characteristics
Deterministic Games: In these games, the outcome is entirely determined by the players' decisions; there is no element of chance (e.g., rolling dice).
Examples: Chess, Checkers, Go, Tic-Tac-Toe.
Perfect Information: Both players have complete knowledge of the game state at any given time. No hidden information or uncertainty exists.
Examples: Chess, Checkers, Go, Tic-Tac-Toe.
Counter-Examples: Poker, Bridge (imperfect information due to hidden cards).
Zero-Sum (Constant-Sum): The total payoff to all players is constant. In a two-player game, this means one player's gain is the other's loss, creating direct opposition.
Examples: Most classic board games.
Action and State Definitions
Action = move: A specific choice a player can make.
State = position: The configuration of the game at a particular point.
Solved Games: Some games have been "solved," meaning the outcome can be determined from any position, assuming both players play optimally.
Example: Tic-tac-toe is a solved game; with perfect play, it always ends in a draw.
Formalising a Game
To use search algorithms, a game must be formalized by specifying:
**Initial State:
**The starting configuration of the game.
Player to Move in State s
A function that identifies which player's turn it is to move in a given state.
Legal Moves/Actions in State s
A function that lists all valid moves available to the current player in a given state.
Transition Model: Result of Action a in State s
A function that defines how a specific action
achanges the statesto a new state.Terminal Test for State s
A function that determines when the game is over. It identifies terminal states (e.g., win, lose, draw).
Utility Function (Payoff/Objective Function): Usefulness of State s for Player p
A function that assigns a numerical value to a terminal state from the perspective of player
p, indicating the desirability of that state.
Game Tree
Tic-Tac-Toe Example
Tic-tac-toe has 5,478 distinct states, representing all possible board configurations that can occur during a game.
The game tree, which represents all possible game sequences, has fewer than 362,880 terminal nodes (end states).
Minimax Values
Optimal Strategy
The optimal strategy against an optimal opponent is based on minimax values.
In game theory, the minimax theorem states that in a two-player zero-sum game, there exists a pair of strategies, one for each player, such that each strategy is optimal given the other player's strategy. These strategies minimize the maximum loss that a player can incur.
Minimax Value
The minimax value of a state is the utility of that state for player MAX, assuming both players play optimally. It represents the best possible outcome for MAX if MAX starts in that state and both players make the best possible moves.
Minimax Algorithm
The pseudo code for the minimax algorithm is given as follows:
function MINIMAX-SEARCH(game, state) returns an action
player ← game.TO-MOVE(state)
value, move ← MAX-VALUE(game, state)
return move
function MAX-VALUE(game, state) returns a (utility, move) pair
if game.Is-TERMINAL(state) then return game.UTILITY(state, player), null
v ← -∞
for each a in game.ACTIONS(state) do
v2, a2 ← MIN-VALUE(game, game.RESULT(state, a))
if v2 > v then
v ← v2; move ← a2
return v, move
function MIN-VALUE(game, state) returns a (utility, move) pair
if game.Is-TERMINAL(state) then return game.UTILITY(state, player), null
v ← +∞
for each a in game.ACTIONS(state) do
v2, a2 ← MAX-VALUE(game, game.RESULT(state, a))
if v2 < v then
v ← v2; move ← a2
return v, move
Notes on the Minimax Algorithm
Exploration: Complete depth-first exploration of the game tree.
The algorithm explores all possible paths from the current state to the terminal states.
Complexity
Let = maximum depth of the game tree, and = maximum legal moves for a state.
The full game tree has at most nodes.
Time Complexity: , which is impractical for non-trivial games because the time it takes to explore grows exponentially with the depth of the game tree.
Space Complexity: , due to depth-first search; at most function calls on the call stack.
Multiplayer Games
Generalization: Minimax generalizes to multiplayer games using vectors of values for each player.
Instead of a single utility value, each state is assigned a vector of utilities, one for each player.
Vector: Utility of the state for each player, assuming perfect play.
Each element in the vector represents the utility of that state for the corresponding player.
Backed-Up Vector: From the successor state with the greatest value for the player whose turn it is.
When backing up values, the algorithm chooses the successor state that maximizes the utility for the player whose turn it is.
Alliances: Alliances can form in multiplayer zero-sum games due to optimal play.
Players may find it beneficial to temporarily ally with each other to prevent another player from winning.
Collaboration may emerge from purely selfish behavior.