2. Adversarial search is search when there is an
"enemy" or "opponent" changing the state of
the problem every step in a direction you do not
want.
3. Adversarial search is a search, where we examine
the problem which arises when we try to plan
ahead of the world and other agents are planning
against us.
• A single agent that aims to find the solution
which often expressed in the form of a sequence
of actions.
• There might be some situations where more than
one agent is searching for the solution in the
same search space, and this situation usually
occurs in game playing.
4. • The environment with more than one agent is termed
as multi-agent environment, in which each agent is an
opponent of other agent and playing against each
other. Each agent needs to consider the action of other
agent and effect of that action on their performance.
• Searches in which two or more players with
conflicting goals are trying to explore the same search
space for the solution, are called adversarial searches,
often known as Games.
• Games are modeled as a Search problem and heuristic
evaluation function, and these are the two main
factors which help to model and solve games in AI.
5. Types of Games in AI
• Perfect information: A game with the perfect
information is that in which agents can look
into the complete board. Examples are Chess,
Checkers, Go, etc.
• Imperfect information: In a game agents do
not have all information about the game and
not aware with what's going on, such as tic-
tac-toe, Battleship, blind, Bridge, etc.
6. • Deterministic games: games which follow a strict
pattern and set of rules for the games, and there
is no randomness associated with them.
Examples are chess, Checkers, Go, tic-tac-toe, etc.
• Non-deterministic games: games which have
various unpredictable events and has a factor of
chance or luck. Ex. dice or cards.
• These are random, and each action response is
not fixed. Such games are also called as stochastic
games. Example: Backgammon, Monopoly, Poker,
etc.
7. Zero-Sum Game
• Zero-sum games are adversarial search which involves
pure competition.
• In Zero-sum game each agent's gain or loss of utility is
exactly balanced by the losses or gains of utility of
another agent.
• One player of the game try to maximize one single
value, while other player tries to minimize it.
• Each move by one player in the game is called as ply.
• Chess and tic-tac-toe are examples of a Zero-sum
game.
8. Zero-sum game: Embedded thinking
• The Zero-sum game involved embedded
thinking in which one agent or player is trying
to figure out:
• What to do.
• How to decide the move
• Needs to think about his opponent as well
• The opponent also thinks what to do
9. There were two reasons that games appeared to
be a good domain in which to explore machine
intelligence:
They provide a structured task in which it is very easy
to measure success or failure.
They did not obviously require large amounts of
knowledge. They were thought to be solvable by
straightforward search from the starting state to a
winning position.
9
10. 10
To improve the effectiveness of a search based
problem solving program two things can be
done:
Improve the generate procedure so that only good
moves(or paths) are generated.
Improve the test procedure so that the best
moves(or paths) will be recognized and explored
first.
11. 11
• The problem of playing chess we use simple legal
move generator , then the test procedure will
have to look at each of them.
• Instead of a legal move generator, we use a
plausible-move generator in which only some
small number of promising moves are generated.
• The test procedure can afford to spend more
time evaluating each of the moves it is given so it
can produce a more reliable result.
12. 12
• We have to incorporate heuristic knowledge into
both the generator and the tester, so that the
performance of the overall system can be
improved.
• In order to choose the best move, the resulting
board positions must be compared to discover
which is most promising.
• This is done by using a static evaluation function,
which uses whatever information it has to
evaluate individual board positions by estimating
how likely they are to lead eventually to a goal.
13. Formalization of the problem
A game can be defined as a type of search in AI
which can be formalized of the following
elements:
• Initial state: It specifies how the game is set up at
the start.
• Player(s): It specifies which player has moved in
the state space.
• Action(s): It returns the set of legal moves in
state space.
• Result(s, a): It is the transition model, which
specifies the result of moves in the state space.
14. • Terminal-Test(s): Terminal test is true if the game
is over, else it is false at any case. The state where
the game ends is called terminal states.
• Utility(s, p): A utility function gives the final
numeric value for a game that ends in terminal
states s for player p. It is also called payoff
function. For Chess, the outcomes are a win, loss,
or draw and its payoff values are +1, 0, ½. And for
tic-tac-toe, utility values are +1, -1, and 0.
15. Game tree
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.
16.
17.
18. Mini-Max Algorithm
• Mini-max algorithm is a recursive or backtracking
algorithm used for decision-making in game theory.
• It provides an optimal move for the player assuming
that opponent is also playing optimally.
• It uses recursion to search through the game-tree.
• Min-Max algorithm – Ex: Chess, Checkers, tic-tac-toe,
go, and various two-players game (turn-based games).
• Algorithm computes the minimax decision for the
current state, two players play the game, one is called
MAX and other is called MIN.
19. • Both the players fight it as the opponent player gets
the minimum benefit while they get the maximum
benefit.
• Both Players of the game are opponent of each other,
where MAX player will select the maximized value and
MIN player will select the minimized value.
• It performs a depth-first search algorithm for the
exploration of the complete game tree.
• It proceeds all the way down to the terminal node of
the tree, then backtrack the tree as the recursion.
• The goal is to find the best possible move for a player.
20. • Every board state has a value associated with it.
• If the MAX player has upper hand then, the score
of the board be some positive value.
• If the MIN player has the upper hand then board
state be some negative value.
• The values of the board are calculated by some
heuristics which are unique for every type of
game.
• It is based on the zero-sum game concept where
the total utility score gets divided between the
two players.
21. Implementation
• There are two players one is called Maximizer and
other is called Minimizer.
• Maximizer will try to get the Maximum possible
score, and Minimizer will try to get the minimum
possible score.
• Apply DFS, in the game-tree, and go all the way
through the leaves to reach the terminal nodes.
• At the terminal node, the terminal values are
given so we will compare those value and
backtrack the tree until the initial state occurs.
22. • Step-1: The algorithm generates the entire
game-tree and apply the utility function to get
the utility values for the terminal states.
• Ex: A is the initial state of the tree. Suppose
maximizer takes first turn which has worst-
case initial value =- infinity, and minimizer will
take next turn which has worst-case initial
value = +infinity.
23.
24. Step 2: Now, first we find the utilities value for
the Maximizer, its initial value is -∞
25. Step 3: In the next step, it's a turn for minimizer,
so it will compare all nodes value with +∞
26. Step 3: Now it's a turn for Maximizer, and it will again
choose the maximum of all nodes value and find the
maximum value for the root node.