Ai-Unit 3
Ai-Unit 3
Prepared by,
C.Usharani, AP/AD
Ramco Institute of Technology,
Rajapalayam-626117.
GAME PLAYING
• A game tree is a tree where nodes of the tree are the game states and
Edges of the tree are the moves by players. Game tree involves
initial state, actions function, and result Function.
• Example: Tic-Tac-Toe game tree:
• The following figure is showing part of the game-tree for tic-tac-toe
game. Following are some key points of the game:
• There are two players MAX and MIN.
• Players have an alternate turn and start with MAX.
• MAX maximizes the result of the game tree
• MIN minimizes the result.
Explanation:
• From the initial state, MAX has 9 possible moves as he starts first.
MAX place x and MIN place o, and both player plays alternatively
until we reach a leaf node where one player has three in a row or all
squares are filled.
• Both players will compute each node, minimax, the minimax value
which is the best achievable utility against an optimal adversary.
• Suppose both the players are well aware of the tic-tac-toe and
playing the best play. Each player is doing his best to prevent
another one from winning. MIN is acting against Max in the game.
• So in the game tree, we have a layer of Max, a layer of MIN, and
each layer is called as Ply. Max place x, then MIN puts o to prevent
Max from winning, and this game continues until the terminal node.
• In this either MIN wins, MAX wins, or it's a draw. This game-tree is
the whole search space of possibilities that MIN and MAX are
playing tic-tac-toe and taking turns alternately.
• Hence adversarial Search for the minimax procedure works as follows:
• It aims to find the optimal strategy for MAX to win the game.
• It follows the approach of Depth-first search.
• In the game tree, optimal leaf node could appear at any depth of the tree.
• Propagate the minimax values up to the tree until the terminal node
discovered.
• In a given game tree, the optimal strategy can be determined from the
minimax value of each node, which can be written as MINIMAX(n). MAX
prefer to move to a state of maximum value and MIN prefer to move to a
state of minimum value then:
Optimal Decisions in Games
Let us start with games with two players, whom we’ll refer to as MAX and
MIN for obvious reasons. MAX is the first to move, and then they take turns
until the game is finished. At the conclusion of the game, the victorious player
receives points, while the loser receives penalties. A game can be formalized
as a type of search problem that has the following elements:
initial state
Player
Actions
Result
Terminal-Test
Utility
• The game tree for tic-tac-toe is relatively short, with just 9! = 362,880
terminal nodes.
• However, because there are over 1040 nodes in chess, the game tree is
better viewed as a theoretical construct that cannot be realized in the actual
world
Optimal decision in Multiplayer Games
MINI MAX ALGORITHM IN AI
stochastic games.
Discrete Domain: It is an infinite domain which can have one state for
multiple variables. For example, a start state can be allocated infinite times for
each variable.