Sei sulla pagina 1di 31

INT4204

INTELLIGENT
SYSTEMS
GAME PLAYING 2
AI and Game Playing
•A game consists of a set of two or more players, a set of moves for the
players, and a specification of payoffs (outcomes) for each combination
of strategies.
•Many different types of games:
• two-person zero-sum
• multi-player
• perfect information games
• imperfect information games
AI and Game Playing
Two-person Zero-sum
◦ These games involve only two players; they are The payoff matrix shown below
called zero-sum games because one player wins represents the payoff to player 1.
whatever the other player loses.
◦ Example: Odds and Evens
◦ Suppose that player 1 takes evens and player 2
takes odds. Then, each player simultaneously shows
either one finger or two fingers. If the number of
fingers matches, then the result is even, and player
1 wins the bet ($2). If the number of fingers does
not match, then the result is odd, and player 2 wins
the bet ($2). Each player has two possible
strategies: show one finger or show two fingers.
AI and Game Playing
Two-person Zero-sum
Basic Concepts of Two-Person Zero-Sum Games
This game of odds and evens illustrates important concepts of simple games.
•A two-person game is characterized by the strategies of each player and the
payoff matrix.
•The payoff matrix shows the gain (positive or negative) for player 1 that would
result from each combination of strategies for the two players. Note that the
matrix for player 2 is the negative of the matrix for player 1 in a zero-sum game.
•The entries in the payoff matrix can be in any units as long as they represent
the utility (or value) to the player.
•There are two key assumptions about the behavior of the players. The first is
that both players are rational. The second is that both players
are greedy meaning that they choose their strategies in their own interest (to
promote their own wealth).
AI and Game Playing
Multi-player
•More than one player at a time
•Spacewar is the first multiplayer game and running on a computer
(1961) (made more than $100 000)
•Tennis for Two is the very first multiplayer game running on an
oscilloscope(1958)

Spacewar Tennis for Two


AI and Game Playing
Multi-player
•Early Multiplayer Online Games - More than one player playing on the
same game session
•First example: Doom by ID software (1993)
◦ Using IPX for communication
◦ P2P (peer to peer topology)
◦ Every 1/35th of a second game collects user input and broadcasts
the network packets (sends it to other players)
AI and Game Playing
Multi-player
•Example: Quake (1996)
◦ Server-client topology
◦ No Tunnelling (quake was using directly internet protocols thus no
need to convert wan packets into different packets) which enabled
players to play via internet
◦ No need to meet in the same time and game room, Quake had its
own game rooms on internet
◦ Clients send only their own inputs to the server and get back the
new game state from the server
AI and Game Playing
Perfect Information Games
◦refers to the fact that each player has the same information that
would be available 
◦this is, each player knows or can see other player’s moves.
◦A good example would be chess, where each player sees the other
player’s pieces on the board.
AI and Game Playing
Imperfect Information Games
◦appears when decisions have to be made simultaneously, and players
need to balance all possible outcomes when making a decision.
◦A good example of imperfect information games is a card game
where each player’s card are hidden from the rest of the players.
AI and Game Playing
•AI has continued to improve, with aims set on a player being unable to
tell the difference between computer and human players - remember
Turin test?
Game AI is about the illusion of human behaviour
◦ Smart, to a certain extent (Creativity)
◦ Non-repeating behaviour
◦ Unpredictable but rational decisions
◦ Emotional influences (Irrationality, ‘Personality’)
◦ Body language to communicate emotions
◦ Being integrated in the environment
AI and Game Playing
Game AI needs various computer science disciplines
• Knowledge Based Systems
• Known as expert systems, which are so called because of their reliance on
human expertise.
• Machine Learning
• is an application of artificial intelligence (AI) that provides systems the
ability to automatically learn and improve from experience without being
explicitly programmed. 
• Multi-agent Systems
• A system composed of multiple interacting intelligent agents. Multi-agent
systems can be used to solve problems that are difficult or impossible for
an individual agent or a monolithic system to solve. 
AI and Game Playing
Game AI needs various
computer science disciplines
• Data Structures
• is a data organization,
management, and storage
format that enables efficient
access and modification. 
• Computer Graphics &
Animation
•  Animation means giving life
to any object in computer
graphics
AI and Game Playing
History and overview
•Minimax
◦ Developed by John von Neumann in 1928
◦ This algorithm is used extensively in game theory

•1960s
• Progress and success in Game AI.
• Creating a successful AI meant coming up with the right rules for it to follow.

•1970s-1980s
• Transition to games as entertainment
• Using search based AI to emulate entertaining characters

•Early 1990s
• Increased realism becomes the primary focus of the game industry
• A rift develops between the developers of popular games and AI researchers
AI and Game Playing
CONCEPTS
Technologies / techniques used
AI and Game Playing
CONCEPTS
Technologies / techniques used
Game Playing
Strategies

16
Game Playing
Strategies

17
Game Playing
Strategies

18
MinMax - Overview
•MinMax the heart of almost every computer board game
•Applies to games where:
◦ Players take turns
◦ Have perfect information
◦ Chess, Checkers, Tactics

•But can work for games without perfect information or


chance
◦ Poker, Monopoly, Dice
MinMax - Overview
Search tree
◦ Squares represent decision states (ie- after a move)
◦ Branches are decisions (ie- the move)
◦ Start at root
◦ Nodes at end are leaf nodes
◦ Ex: Tic-Tac-Toe

• Unlike binary trees can have any number of children


– Depends on the game situation
• Levels usually called plies (a ply is one level)
– Each ply is where "turn" switches to other player
• Players called Min and Max (next)
MaxMin - Algorithm

•Named MinMax because of algorithm behind data structure


•Assign points to the outcome of a game
◦ Ex: Tic-Tac-Toe: X wins, value of 1. O wins, value -1.
• Max (X) tries to maximize point value, while Min (O) tries
to minimize Max’s score point value
•Assume both players play to best of their ability
◦ Always make a move to minimize or maximize points

Goal: move to position of highest minimax value


 Identify best achievable payoff against best play
MinMax –Example
Max

Min

Max

Min

Circles represent Max, Squares represent Min


Values inside represent the value the MinMax algorithm
Red arrows represent the chosen move
Numbers on left represent tree depth
Blue arrow is the chosen move
An optimal procedure: The
Min-Max method
Designed to find the optimal strategy for Max and find
best move:
1. Generate the whole game tree, down to the leaves.
2. Apply utility (payoff) function to each leaf.
3. Back-up values from leaves through branch nodes:
◦ a Max node computes the Max of its child values
◦ a Min node computes the Min of its child values

4. At root: choose the move leading to the child of highest value.


Minimax Algorithm

Payoff for Max

24
Minimax Algorithm
(cont’d)

3 9 0 7 2 6

Payoff for Max

25
Minimax Algorithm
(cont’d)

3 0 2

3 9 0 7 2 6

Payoff for Max

26
Minimax Algorithm
(cont’d)
3

3 0 2

3 9 0 7 2 6

Payoff for Max

27
Minimax is done Depth-first
Serch
max

min

max

leaf
2 5 1

28
Minimax Algorithm

29
Game Tree Size
Tic-Tac-Toe
◦ b ≈ 5 legal actions per state on average, total of 9 plies in game.
◦ “ply” = one action by one player, “move” = two plies.
◦ 59 = 1,953,125
◦ 9! = 362,880 (Computer goes first)
◦ 8! = 40,320 (Computer goes second)

Chess
◦ b ≈ 35 (approximate average branching factor)
◦ d ≈ 100 (depth of game tree for “typical” game)
◦ bd ≈ 35100 ≈ 10154 nodes!!

30
Partial Game Tree for Tic-Tac-Toe

31

Potrebbero piacerti anche