Download as pdf or txt
Download as pdf or txt
You are on page 1of 41

Chapter 5:

Games:
Adversarial Search

Textbook: Artificial Intelligence Foundations of


Computational Agents, 2nd Edition, David L.
Poole and Alan K Mackworth, Cambridge
University Press, 2018.
Asst. Prof. Abdulle Hassan 1
Outline
• Games vs. search problems
• MAX-MIN pruning
• Imperfect, real-time decisions
Introduction
Why study games?

1. Fun; historically entertaining

2. Interesting subject of study because they are hard


to solve.

3. Easy to represent and agents restricted to small


number of actions whose outcomes are defined rules
Asst. Prof. Abdulle Hassan 3
Asst. Prof. Abdulle Hassan 4
There are two extremes in the study of multiagent
systems:
1. Fully cooperative, where the agents share the
same utility function, and
2. Fully competitive, when one agent can only
win when another loses; in zero-sum games,
for every outcome, the sum of the utilities for
the agents is zero

Asst. Prof. Abdulle Hassan 5


AI Games

• Games have engaged the intellectual faculties of


humans.

• Sometimes to an alarming degree as long as


civilization has existed

Asst. Prof. Abdulle Hassan 6


Games vs. search problems
• "Unpredictable" opponent  specifying a move
for every possible opponent reply

• Time limits  unlikely to find goal, must


approximate
Games vs. search problems
Theorists call
• Deterministic or Turn-taking or Two-player or zero-
sum or perfect information

• In AI, this means deterministic, fully observable


environ in which there are two agents whose
actions must alternate and in which the utility value
at the end of the game are always equal and
opposite
Asst. Prof. Abdulle Hassan 8
Types of Games
Games might be either:-

1. Zero-sum games: a player’s gains are exactly


subtracted from other player’s score(chess)

2. Non-zero-sum games: players can gain or lose


without an exact change on others (prisoners’
dilemma)

Asst. Prof. Abdulle Hassan 9


Zero-sum games

Rules:
1. If a player wins a game ( +1 )
2. If a player loses a game ( - 1 )
3. Otherwise a draw (0)

10 Asst. Prof. Abdulle Hassan


Example1: Pick Stick Game
Strategy:
1. PC Vs User each picks min 1 stick or maximum 3
sticks first
2. User starts picks first
3. Payoff
PC must win always ( + 1 )

11 Asst. Prof. Abdulle Hassan


Example2: Pick Stick Dame
Play:
1. Range of picks = 3
2. (n mod 3) ==0
3. Sticks = 9

User PC Total Sticks =9


2 1 6
1 2 3
2 1 0
PC
12
wins ( + 1 ) Asst. Prof. Abdulle Hassan
Example3 : Pick Stick Game
Play:
1. Range of picks = 4
2. (n mod 4) ==0
3. Sticks = 12

User PC Total Sticks =12


3 1 8
2 2 4
1 3 0
PC
13
wins ( + 1 ) Asst. Prof. Abdulle Hassan
Example4 : Pick Stick Game
Play:
Range of picks = 5; (n mod 5) ==0; Sticks = 25

User PC Total Sticks =25


4 1 20
2 3 15
3 2 10
1 4 5
3 2 0
PC
14
wins ( + 1 ) Asst. Prof. Abdulle Hassan
Game of Coins

Strategy:
1. Initial state:7 matches in a pile
2. Each player must divide a pile into two non-empty
unequal piles
3. Player who can’t do that loses
Payoff
+1 win, -1 loss

15 Asst. Prof. Abdulle Hassan


Game of Coins

16 Asst. Prof. Abdulle Hassan


Example of Game of Coins

17 Asst. Prof. Abdulle Hassan


Class Work
You and your partner have 11 Coins. Each
player must divide the pile of 11 Coins into two
non-empty unequal piles. The player who can’t do
that loses

Asst. Prof. Abdulle Hassan 18


TICTACTOE

19 Asst. Prof. Abdulle Hassan


TICTACTOE

20 Asst. Prof. Abdulle Hassan


Winning Strategy

Asst. Prof. Abdulle Hassan 21


Winning Strategy

Asst. Prof. Abdulle Hassan 22


Winning Strategy

Asst. Prof. Abdulle Hassan 23


Winning Strategy

Asst. Prof. Abdulle Hassan 24


Winning Strategy

25 Asst. Prof. Abdulle Hassan


Winning Strategy

Class work
How many potential Winning strategies are
there in TicTacToe Game?

26 Asst. Prof. Abdulle Hassan


Minimax Game

27 Asst. Prof. Abdulle Hassan


Minimax Game
• MIN((3, 12, 9), (2, 4, 6), (14, 5, 2)) = 3, 2, 2

Asst. Prof. Abdulle Hassan 28


Minimax Game
• MIN((3, 12, 9), (2, 4, 6), (14, 5, 2)) = 3, 2, 2

• MAX(3, 2, 2) = 3

Asst. Prof. Abdulle Hassan 29


Minimax Game
• MIN((3, 12, 9), (2, 4, 6), (14, 5, 2)) = 3, 2, 2

• MAX(3, 2, 2) = 3

• MIN(3) : FAILS

Asst. Prof. Abdulle Hassan 30


Minimax Game

31 Asst. Prof. Abdulle Hassan


Rock – Paper – Scissors Game
• Alice chooses a row and Bob chooses a column,
simultaneously. This gives a pair of numbers: the
first number is the payoff to the row player (Alice)
and the second gives the payoff to the column
player (Bob).
• Note that the utility for each of them depends on
what both players do.
• An example of an action profile is ⟨scissorsAlice,
rockBob⟩, where Alice chooses scissors and Bob
32
chooses rock. In Asst.
this action, Alice receives the
Prof. Abdulle Hassan
utility of −1 and Bob receives the utility of 1.
Rock – Paper – Scissors Game

33 Asst. Prof. Abdulle Hassan


Imperfect, real-time decisions
• Imperfect-information game is a partially
observable game, an agent does not fully know
the state of the world or the agents act
simultaneously.
• Partial observability for the multiagent case is
more complicated than the fully observable
multiagent case or the partially observable
single-agent case.

Asst. Prof. Abdulle Hassan 34


Imperfect, real-time decisions
• The kicker can kick to his left or right and the
goalkeeper can jump to left or right.

Asst. Prof. Abdulle Hassan 35


Imperfect, real-time decisions
• A resource with two agents may want to fight over.
Each agent chooses to act as a hawk or as a dove.
• If both agents act as doves, they share the
resource.
• If one agent acts as a hawk and the other as a
dove, the hawk agent gets the resource and the
dove agent gets nothing.
• If they both act like hawks, there is destruction of
the resource and the reward to both is −D, where D
> 0. Asst. Prof. Abdulle Hassan 36
Imperfect, real-time decisions

Asst. Prof. Abdulle Hassan 37


Programming Assignment: [2% Marks]
Sticks:
• Write a program that solves the Sticks Problem

Deadline: 30 Oct. 2022

Asst. Prof. Abdulle Hassan 38


Programming Assignment: [2% Marks]
TicTacToe:
• Write a program that solves the Tictactoe Problem

Deadline: 30 Oct. 2022

Asst. Prof. Abdulle Hassan 39


Programming Assignment: [2% Marks]
Rock, Paper & Scissor Game:
• Write a program that solves the RSP Problem

Deadline: 30 Oct. 2022

Asst. Prof. Abdulle Hassan 40


End

Asst. Prof. Abdulle Hassan 41

You might also like