Games and Strategies Vedran Kasalica Last time Proofs by induction - - PowerPoint PPT Presentation

games and strategies
SMART_READER_LITE
LIVE PREVIEW

Games and Strategies Vedran Kasalica Last time Proofs by induction - - PowerPoint PPT Presentation

Games and Strategies Vedran Kasalica Last time Proofs by induction This lecture Games and Strategies Modelling Computing Systems The book is called Modelling Computing Systems - but so far we have studied: sets functions


slide-1
SLIDE 1

Games and Strategies

Vedran Kasalica

slide-2
SLIDE 2

Last time

Proofs by induction

slide-3
SLIDE 3

This lecture

Games and Strategies

slide-4
SLIDE 4

Modelling Computing Systems

The book is called Modelling Computing Systems - but so far we have studied:

  • sets
  • functions
  • relations
  • propositional and predicate logic
  • induction

... but these are all very static concepts. There's hardly any computation or interaction.

slide-5
SLIDE 5

Games

Today we will study how to apply these ideas to model a series of interactions. Interactions can be:

  • computers interacting
  • brokers buying/selling shares, etc.

We focus on a more restricted form of interactions, namely games.

slide-6
SLIDE 6

Games

Not computer games. Instead focus on well-specified interactions between players. The players can:

  • win the game
  • lose the game
  • potentially draw the game
slide-7
SLIDE 7

Chance in games

We can distinguish between different kinds of games:

  • Games of chance - like roulette - where there is no good strategy

for winning.

  • Games of no chance - like tic-tac-toe - where it is clear how to win.

These are two extremes: the most fun games have some element of luck (e.g. monopoly).

slide-8
SLIDE 8

Games of no chance

We'll study the games without any chance element. Furthermore, we focus on games of perfect information (e.g. chess). Finite games - if the game could continue indefinitely call it e.g. “a draw” Rules according to which the player makes a move on each turn make a strategy.

slide-9
SLIDE 9

Strategies

Winning strategy - guarantees a victory regardless the moves of the

  • pponent

Drawing strategy - guarantees that the opponent will not win regardless the moves of the opponent A position in a game can be:

  • winning - there is a winning strategy for the current player
  • losing - there is a winning strategy for the non-current player
  • drawing - neither player has a winning strategy
slide-10
SLIDE 10

Example: Tic Tac Toe

Drawing position

slide-11
SLIDE 11

Example: Tic Tac Toe

Losing position

slide-12
SLIDE 12

Strategies

Theorem In a two-player game-of-no-chance of perfect information, either one the two players has a winning strategy, or they both have drawing strategies.

slide-13
SLIDE 13

Proof

Case 1: Player X has a winning strategy Claim: The other one cannot have a winning strategy If we fix the two strategies only one player will win and only the strategy of that player was the winning one

slide-14
SLIDE 14

Proof

Case 2: Neither player has a winning strategy Claim: Both players have a drawing strategy First player (X) doesn’t have a winning strategy, so player O can always respond in

  • rder to win or draw. Ensuring that player X

doesn’t win. Similarly, player X can ensure that the player O doesn’t win. Thus, they both have a drawing strategies.

slide-15
SLIDE 15

Proof

Case 2: Neither player has a winning strategy Claim: Both players have a drawing strategy First player (X) doesn’t have a winning strategy, so player O can always respond in

  • rder to win or draw. Ensuring that player X

doesn’t win. Similarly, player X can ensure that the player O doesn’t win. Thus, they both have a drawing strategies.

slide-16
SLIDE 16

Strategies

Theorem In a two-player game-of-no-chance of perfect information, either of the players has a winning strategy or they both have drawing strategies. Corollary If a game cannot end in a draw, one of the two players has a winning strategy.

slide-17
SLIDE 17

Example game

Game: Starting with a pile of 10 coins, 2 players take turns removing either 2 or 3 coins from the pile. The winner is the one that takes the last pile; if one coin remains, then the game is a draw.

slide-18
SLIDE 18

Example game

Game: Starting with a pile of 10 coins, 2 players take turns removing either 2 or 3 coins from the pile. The winner is the one that takes the last pile; if one coin remains, then the game is a draw.

slide-19
SLIDE 19

Game tree

  • each node is a position
  • circle (W)
  • square (L)
  • blank (D)
  • edge represents a move
slide-20
SLIDE 20

Game tree: Tic Tac Toe

W/D/L labels are omitted

...

slide-21
SLIDE 21

Nim

slide-22
SLIDE 22

Nim

Game:

  • Board consists of an arbitrary number of piles, where each has

arbitrary number of coins

  • 2 players take turns removing each time 1 or more coins from

exactly one pile

  • Goal is to take the last coin
slide-23
SLIDE 23

Nim

Game:

  • Board consists of an arbitrary number of piles, where each has

arbitrary number of coins

  • 2 players take turns removing each time 1 or more coins from

exactly one pile

  • Goal is to take the last coin
slide-24
SLIDE 24

Nim

Game:

  • Board consists of an arbitrary number of piles, where each has

arbitrary number of coins

  • 2 players take turns removing each time 1 or more coins from

exactly one pile

  • Goal is to take the last coin
slide-25
SLIDE 25

Nim

Game:

  • Board consists of an arbitrary number of piles, where each has

arbitrary number of coins

  • 2 players take turns removing each time 1 or more coins from

exactly one pile

  • Goal is to take the last coin
slide-26
SLIDE 26

Nim

Game:

  • Board consists of an arbitrary number of piles, where each has

arbitrary number of coins

  • 2 players take turns removing each time 1 or more coins from

exactly one pile

  • Goal is to take the last coin
slide-27
SLIDE 27

Nim

Game:

  • Board consists of an arbitrary number of piles, where each has

arbitrary number of coins

  • 2 players take turns removing each time 1 or more coins from

exactly one pile

  • Goal is to take the last coin
slide-28
SLIDE 28

Nim

Winning strategies

  • 1 pile game
slide-29
SLIDE 29

Nim

Winning strategies

  • 1 pile game
slide-30
SLIDE 30

Nim

Winning strategies

  • 1 pile game (W)
slide-31
SLIDE 31

Nim

Winning strategies

  • 1 pile game (W)
  • 2 pile game
slide-32
SLIDE 32

Nim

Winning strategies

  • 1 pile game (W)
  • 2 pile game
  • piles are equal
slide-33
SLIDE 33

Nim

Winning strategies

  • 1 pile game (W)
  • 2 pile game
  • piles are equal (L)
slide-34
SLIDE 34

Nim

Winning strategies

  • 1 pile game (W)
  • 2 pile game
  • piles are equal (L)
  • piles are not equal
slide-35
SLIDE 35

Nim

Winning strategies

  • 1 pile game (W)
  • 2 pile game
  • piles are equal (L)
  • piles are not equal (W)
slide-36
SLIDE 36

Nim

Winning strategies

  • 1 pile game (W)
  • 2 pile game
  • piles are equal (L)
  • piles are not equal (W)
  • 3 pile game
  • 2 piles are equal
slide-37
SLIDE 37

Nim

Winning strategies

  • 1 pile game (W)
  • 2 pile game
  • piles are equal (L)
  • piles are not equal (W)
  • 3 pile game
  • 2 piles are equal (W)
slide-38
SLIDE 38

Nim

Winning strategies

  • 1 pile game (W)
  • 2 pile game
  • piles are equal (L)
  • piles are not equal (W)
  • 3 pile game
  • 2 piles are equal (W)
  • piles contain 1, 2 and 3 coins
slide-39
SLIDE 39

Nim

Winning strategies

  • 1 pile game (W)
  • 2 pile game
  • piles are equal (L)
  • piles are not equal (W)
  • 3 pile game
  • 2 piles are equal (W)
  • piles contain 1, 2 and 3 coins
slide-40
SLIDE 40

Nim

Winning strategies

  • 1 pile game (W)
  • 2 pile game
  • piles are equal (L)
  • piles are not equal (W)
  • 3 pile game
  • 2 piles are equal (W)
  • piles contain 1, 2 and 3 coins
slide-41
SLIDE 41

Nim

Winning strategies

  • 1 pile game (W)
  • 2 pile game
  • piles are equal (L)
  • piles are not equal (W)
  • 3 pile game
  • 2 piles are equal (W)
  • piles contain 1, 2 and 3 coins
slide-42
SLIDE 42

Nim

Winning strategies

  • 1 pile game (W)
  • 2 pile game
  • piles are equal (L)
  • piles are not equal (W)
  • 3 pile game
  • 2 piles are equal (W)
  • piles contain 1, 2 and 3 coins
slide-43
SLIDE 43

Nim

Winning strategies

  • 1 pile game (W)
  • 2 pile game
  • piles are equal (L)
  • piles are not equal (W)
  • 3 pile game
  • 2 piles are equal (W)
  • piles contain 1, 2 and 3 coins
slide-44
SLIDE 44

Nim

Winning strategies

  • 1 pile game (W)
  • 2 pile game
  • piles are equal (L)
  • piles are not equal (W)
  • 3 pile game
  • 2 piles are equal (W)
  • piles contain 1, 2 and 3 coins (L)
slide-45
SLIDE 45

Nim

Winning strategies

  • 1 pile game (W)
  • 2 pile game
  • piles are equal (L)
  • piles are not equal (W)
  • 3 pile game
  • 2 piles are equal (W)
  • piles contain 1, 2 and 3 coins (L)
  • arbitrary number of coins (?)
slide-46
SLIDE 46

Nim

Winning strategies

  • 1 pile game (W)
  • 2 pile game
  • piles are equal (L)
  • piles are not equal (W)
  • 3 pile game
  • 2 piles are equal (W)
  • piles contain 1, 2 and 3 coins (L)
  • arbitrary number of coins (?)
slide-47
SLIDE 47

Nim

Universal winning strategy: 1) Write out number of coins in piles in binary representation

slide-48
SLIDE 48

Nim

Universal winning strategy: 2) Add up the columns module 2

slide-49
SLIDE 49

Nim

Universal winning strategy: If all of the columns have even parity, the position is balanced,

  • therwise it’s unbalanced
slide-50
SLIDE 50

Nim

Observation:

1.

If the position is balanced, then every move will lead to an unbalanced position

2.

If the position is unbalanced, then there exists a move that will lead to a balanced position

3.

Empty board is a balanced position

slide-51
SLIDE 51

Nim

Universal winning strategy: 3) If the position is unbalanced (W), player should make a move to make it balanced each time and he is insured to win

slide-52
SLIDE 52

Nim

Universal winning strategy: 4) If the position is balanced (L), the opponent has a chance to use the same strategy to win

slide-53
SLIDE 53

Chomp

slide-54
SLIDE 54

Chomp

Game:

  • we have a n x m bar where leftmost-topmost square is poisonous
  • two players take turns to bite of the bar, where each player has to

choose a remaining square and eat all the squares below it and to the right from it

  • the player that eats the poisonous square lost the game
slide-55
SLIDE 55

Chomp

Game:

  • we have a n x m bar where leftmost-topmost square is poisonous
  • two players take turns to bite of the bar, where each player has to

choose a remaining square and eat all the squares below it and to the right from it

  • the player that eats the poisonous square lost the game
slide-56
SLIDE 56

Chomp

Strategies:

  • 1 x 1
slide-57
SLIDE 57

Chomp

Strategies:

  • 1 x 1 (L)
slide-58
SLIDE 58

Chomp

Strategies:

  • 1 x 1 (L)
  • 1 x n
slide-59
SLIDE 59

Chomp

Strategies:

  • 1 x 1 (L)
  • 1 x n (W) - take all the squares apart from the poisonous one
slide-60
SLIDE 60

Chomp

Strategies:

  • 1 x 1 (L)
  • 1 x n (W) - take all the squares apart from the poisonous one
  • 2 x n
slide-61
SLIDE 61

Chomp

Strategies:

  • 1 x 1 (L)
  • 1 x n (W) - take all the squares apart from the poisonous one
  • 2 x n (W) - take the bottom-right square (and keep that structure)
slide-62
SLIDE 62

Chomp

Strategies:

  • 1 x 1 (L)
  • 1 x n (W) - take all the squares apart from the poisonous one
  • 2 x n (W) - take the bottom-right square (and keep that structure)
  • n x n
slide-63
SLIDE 63

Chomp

Strategies:

  • 1 x 1 (L)
  • 1 x n (W) - take all the squares apart from the poisonous one
  • 2 x n (W) - take the bottom-right square (and keep that structure)
  • n x n (W) - remove (n-1) x (n-1) squares and mimic the payer

response in the following moves

slide-64
SLIDE 64

Chomp

Strategies:

  • 1 x 1 (L)
  • 1 x n (W) - take all the squares apart from the poisonous one
  • 2 x n (W) - take the bottom-right square (and keep that structure)
  • n x n (W) - remove (n-1) x (n-1) squares and mimic the payer

response in the following moves

  • n x m (?)
slide-65
SLIDE 65

Chomp

Strategies:

  • 3 x 4
slide-66
SLIDE 66

Chomp

Theorem: Except for the 1 x 1 case, the first player always has a winning strategy.

slide-67
SLIDE 67

Chomp

Theorem: Except for the 1 x 1 case, the first player always has a winning strategy. Proof: Suppose that the second player has a winning strategy. Draw a contradiction.

slide-68
SLIDE 68

Hex

slide-69
SLIDE 69

Hex

Game:

  • played on a board consisting of n x n hexagons
  • territories in NE and SW belong to player 1
  • territories in SE and NW belong to player 2
  • players take turns marking empty cells with their respective

symbol

  • the winner is the player that connects the two disconnected

territories first with an unbroken chain of their symbols

slide-70
SLIDE 70

Hex

Game:

  • played on a board consisting of n x n hexagons
  • territories in NE and SW belong to player 1
  • territories in SE and NW belong to player 2
  • players take turns marking empty cells with their respective

symbol

  • the winner is the player that connects the two disconnected

territories first with an unbroken chain of their symbols

slide-71
SLIDE 71

Hex

Theorem: The game of Hex can never end in a draw.

slide-72
SLIDE 72

Hex

Theorem: The first player always has a winning strategy in Hex.

slide-73
SLIDE 73

Bridg-it

slide-74
SLIDE 74

Bridg-it

Game:

  • played on a staggered n x n board
  • a pair of opposing borders belongs to each player (S&N and W&E)
  • players take turns connecting neighbouring dots of their respective

color, horizontally or vertically

  • the winner is the player that connects their

the two opposite borders

  • 2 lines are not allowed to cross
slide-75
SLIDE 75

Bridg-it

Theorem: The game of Bridg-it can never end in a draw.

slide-76
SLIDE 76

Bridg-it

Theorem: The game of Bridg-it can never end in a draw.

slide-77
SLIDE 77

Bridg-it

Theorem: The first player always has a winning strategy in Bridg-it.

slide-78
SLIDE 78

Bridg-it

Winning strategy:

slide-79
SLIDE 79

Conclusion

We have learned:

  • How to model player interactions
  • How to formalise a game
  • How to evaluate the quality of a position
  • How mathematical theory can be used to make a winning strategy

These concepts are quite useful in Game theory - application of agent interactions in economics, social sciences, computer science, etc. (e.g. auction, bargaining) Agents might have different goals and potentially cooperate

slide-80
SLIDE 80

Material

Modelling Computing Systems Chapter 10