Ai Unit 2
Ai Unit 2
Minimax :
1. Game Tree:
operates on a game tree, where each node represents a game state, and
edges represent possible moves.
2. Players:
3. Utility Function:
assign a numerical value to terminal nodes (end states) of the game tree.
This value represents the desirability of that state for the maximizing player
(e.g., a win might be +1, a loss -1, and a draw 0).
4. Backtracking:
The algorithm backtracks through the tree, propagating the values up to the
root node.
Applications
Game Playing: Widely used in AI for games like chess, checkers, tic-tac-toe, and
other turn-based games.
Decision Making: Can be applied in scenarios where two opposing agents make
decisions, such as in economic models or competitive environments.
Alpha-Beta Pruning
is an optimization technique for the Minimax algorithm used in decision-making and game-
playing AI.
It reduces the number of nodes evaluated in the game tree, allowing the algorithm to run
more e iciently.
This is particularly useful in games with large search spaces, such as chess or checkers.
Alpha (α): The best value that the maximizing player (Max) can guarantee at
that level or above. It represents the minimum score that the maximizing
player is assured of.
Beta (β): The best value that the minimizing player (Min) can guarantee at
that level or above. It represents the maximum score that the minimizing
player is assured of.
2. Pruning:
During the search, if the algorithm finds a move that proves to be worse than
a previously examined move, it can "prune" (ignore) that branch of the tree.
This means that the algorithm does not need to explore that branch further,
as it cannot influence the final decision.
1. Initialization:
Start with initial values: ( alpha = -infty ) (for Max) and ( beta = +infty ) (for
Min).
2. Tree Traversal:
Traverse the game tree using the Minimax algorithm, but at each node,
update the alpha and beta values:
For a maximizing node, update ( alpha ) with the maximum value
found so far.
3. Pruning Condition:
If at any point ( alpha ) (the best option for Max) is greater than or equal to (
beta ) (the best option for Min), prune the remaining branches. This means
that the current path will not yield a better outcome for the maximizing player
than what has already been found.
is a classic problem in AI that involves measuring a specific amount of water using two
jugs of di erent capacities.
The problem can be framed as a state-space search problem, where the goal is to reach
a desired amount of water in one of the jugs through a series of allowed operations.
Problem Definition
1. Jugs: You have two jugs with capacities ( A ) and ( B ) liters, respectively. The jugs can
hold a maximum of ( A ) and ( B ) liters of water.
3. Goal State: The goal is to measure exactly ( C ) liters of water in one of the jugs,
where ( C ) is less than or equal to the maximum capacity of either jug.
4. Allowed Operations:
Pour water from one jug to the other until one jug is either full or the other is
empty.
Example
Tiles Problem :
Problem Definition
1. Grid Configuration:
2. Allowed Moves:
A tile can slide into the empty space if it is adjacent to the empty space. This
means that the possible moves depend on the current position of the empty
space.
3. Goal State: