Adversarial search is a game-playing technique where the agents are surrounded by a competitive environment. A conflicting goal is given to the agents (multiagent). These agents compete with one another and try to defeat one another in order to win the game. Such conflicting goals give rise to the adversarial search. Here, game-playing means discussing those games where human intelligence and logic factor is used, excluding other factors such as luck factor. Tic-tac-toe, chess, checkers, etc., are such type of games where no luck factor works, only mind works.
Mathematically, this search is based on the concept of ‘Game Theory.’ According to game theory, a game is played between two players. To complete the game, one has to win the game and the other looses automatically.’
Techniques required to get the best optimal solution
There is always a need to choose those algorithms which provide the best optimal solution in a limited time. So, we use the following techniques which could fulfill our requirements:
- Pruning: A technique which allows ignoring the unwanted portions of a search tree which make no difference in its final result.
- Heuristic Evaluation Function: It allows to approximate the cost value at each level of the search tree, before reaching the goal node.
Elements of Game Playing search
To play a game, we use a game tree to know all the possible choices and to pick the best one out. There are following elements of a game-playing:
- S0: It is the initial state from where a game begins.
- PLAYER (s): It defines which player is having the current turn to make a move in the state.
- ACTIONS (s): It defines the set of legal moves to be used in a state.
- RESULT (s, a): It is a transition model which defines the result of a move.
- TERMINAL-TEST (s): It defines that the game has ended and returns true.
- UTILITY (s,p): It defines the final value with which the game has ended. This function is also known as Objective function or Payoff function. The price which the winner will get i.e.
- (-1): If the PLAYER loses.
- (+1): If the PLAYER wins.
- (0): If there is a draw between the PLAYERS.
For example, in chess, tic-tac-toe, we have two or three possible outcomes. Either to win, to lose, or to draw the match with values +1,-1 or 0.
Let’s understand the working of the elements with the help of a game tree designed for tic-tac-toe. Here, the node represents the game state and edges represent the moves taken by the players.
|A game-tree for tic-tac-toe|
- INITIAL STATE (S0): The top node in the game-tree represents the initial state in the tree and shows all the possible choice to pick out one.
- PLAYER (s): There are two players, MAX and MIN. MAX begins the game by picking one best move and place X in the empty square box.
- ACTIONS (s): Both the players can make moves in the empty boxes chance by chance.
- RESULT (s, a): The moves made by MIN and MAX will decide the outcome of the game.
- TERMINAL-TEST(s): When all the empty boxes will be filled, it will be the terminating state of the game.
- UTILITY: At the end, we will get to know who wins: MAX or MIN, and accordingly, the price will be given to them.
Types of algorithms in Adversarial search
In a normal search, we follow a sequence of actions to reach the goal or to finish the game optimally. But in an adversarial search, the result depends on the players which will decide the result of the game. It is also obvious that the solution for the goal state will be an optimal solution because the player will try to win the game with the shortest path and under limited time.
There are following types of adversarial search:
- Minmax Algorithm
- Alpha-beta Pruning.
Note: The types of adversarial search are discussed in the next section.by