Games, Graphs, and Computers How to win without actually cheating. - PowerPoint PPT Presentation

1 / 42
About This Presentation
Title:

Games, Graphs, and Computers How to win without actually cheating.

Description:

Puzzle 1: Seven Bridges of K nigsberg. How to Win: Graphs & Counting ... Left as exercises for the student! Play one another to test! Develop a Hypothesis! ... – PowerPoint PPT presentation

Number of Views:132
Avg rating:3.0/5.0
Slides: 43
Provided by: scienceou
Category:

less

Transcript and Presenter's Notes

Title: Games, Graphs, and Computers How to win without actually cheating.


1
Games, Graphs, and Computers(How to win without
actually cheating.)
  • Wayne Brehaut
  • Science Outreach - Athabasca

2
Outline 1
  • Puzzle 1 Seven Bridges of Königsberg
  • How to Win Graphs Counting
  • Game 1 3-Pile Nim (3, 4, 5) Play it!
  • How to Win Binary Numbers Adding
  • Game 2 31-Pile Nim (1, 2,,31) Play it?
  • How to Win Using a Computer
  • Puzzle 2 Instant Insanity
  • How to Win Graphs and Cycles

3
Outline 2
  • General Games--Game Theory
  • Payoff Matrix Saddle Points Mixed Strategies
  • Predator vs. Prey
  • Simulation
  • Java Applets
  • Phase Plots for Equilibrium Graphs
  • Evolutionarily Stable Strategy vs. Extinction
  • Wolves vs. Rabbits vs. Grass
  • http//www.shodor.org/interactivate/activities/
  • Games Against (Mother) Nature

4
Puzzle 1 Seven Bridges of Königsberg
  • Königsberg, Prussia is on the Pregel River.
  • It has two large islands connected to each other
    and the mainland by seven bridges.
  • Q1 Is it possible to find a path that crosses
    each bridge exactly once?
  • Q2 Can you do that and return to where you
    started (a tour)?
  • Solved by Leonard Euler gtEulers Theorem,
    Euler Path, Euler Tour!

5
Puzzle 1 Hints
  • Forget the Details!
  • Try Small Examples!
  • Look for Clues Patterns!
  • Develop a Hypothesis!
  • Test the Hypothesis!
  • State it as a Theorem and Prove it!

6
Puzzle 1 Hint 1
  • Forget the Details!
  • Each separate region becomes a vertex v (drawn as
    small circle).
  • Each bridge becomes an edge e (drawn as line or
    curve).
  • Add labels to vertices and edges so theyre easy
    to refer to---use different sets for V and E.

7
Puzzle 1 Hint 2
  • Try Small Examples! Graph 1 (G1),, G5

G1 start _at_ 1, finish _at_ 2 start _at_ 2, finish _at_
1 Paths P1 1, a, 2 P2 2, a, 1 Start
at one, finish at the other. G2 start _at_ 1,
finish _at_ 1 start _at_ 2, finish _at_ 2 Paths P1 1,
a, 2, b, 1 P2 2, a, 1, b, 2 or b then a
in each Start at one, finish at the same
one. G3 start _at_ 1, finish _at_ 2 start _at_ 2,
finish _at_ 1 Paths P1 1, a, 2, b, 1, c, 2 P2
2, a, 1, b, 2, c , 1 Start at one, finish at
the other. G4 start _at_ 1, finish _at_ 2 start _at_ 2,
finish _at_ 1 Paths P1 1, a, 2, b, 1, c, 2, d, 1
P2 2, a, 1, b, 2, c , 1, d, 2 Start at one,
finish at the same one. G5 start _at_ 1, finish _at_
2 start _at_ 2, finish _at_ 1 Paths P1 1, a, 2, b,
1, c, 2, d, 1, e, 2 P2 2, a, 1, b, 2, c , 1,
d, 2, e, 1 Start at one, finish at the
other. Any permutation ( ordering) of (a, b,
c,) gives a different path but start and finish
are the same!
8
Puzzle 1 Hint 2
  • Look for Clues Patterns!
  • The degree of a vertex is the number of edges
    meeting it.
  • Whenever both vertices have even degree you must
  • start at one vertex and finish at the same
    vertex.
  • Whenever both vertices have odd degree you must
  • start at one vertex and finish at the other
    vertex.

9
Puzzle 1 Hint 2
  • Stronger Statements--Even Vertices
  • Start at an even vertex gt must finish there
  • number of outgoing edges number of incoming
    edges!
  • Dont start at an even vertex you cant finish
    there
  • number of incoming edges number of outgoing
    edges!

10
Puzzle 1 Hint 2
  • Stronger Statements--Odd Vertices
  • Start at an odd vertex gt cant finish there
  • number of outgoing edges number of incoming
    edges 1!
  • Dont start at an odd vertex you must finish
    there
  • number of outgoing edges number of incoming
    edges - 1!
  • Useful Fact
  • A path has just one start and one finish.

11
Puzzle 1 Hint 2
  • Useful Fact
  • A path has just one start and one finish.
  • Develop a Hypothesis!
  • If a graph has more than two odd vertices it has
    no Euler path.
  • One would be the start, one would be the finish,
    what about the others? Each must be either a
    start or a finish!
  • If a graph has exactly two odd vertices it has an
    open Euler path.
  • It must start at one odd vertex and finish at the
    other.
  • If a graph has no odd vertices it has a closed
    Euler path (an Euler tour).
  • It may start at any vertex and then must finish
    there too.

12
Test the Hypothesis (1)!
13
Test the Hypothesis (2)!
14
Solve the Puzzle!
Q1 Is it possible to find a path that crosses
each bridge exactly once?
No! The graph of this puzzle has four odd
vertices! So forget Q2 also!
15
Nim The Impartial Game pt. I
  • Rules
  • Several heaps of beans
  • On your turn, select a heap, and remove any
    positive number of beans from it, maybe all
  • Goal
  • Take the last bean
  • Example w/4 piles (2,3,5,7)

16
Combinatorial Games
  • Two players (L R) move alternately.
  • No chance, such as dice or shuffled cards
  • Both players have perfect information.
  • No hidden information
  • The game is finite it must eventually end.
  • There are no draws or ties.
  • Normal Play Last to move wins!
  • Misere Play Last to move loses!

17
Game 1 3-Pile Nim (3, 4, 5)
  • Three rows of counters 3, 4, and 5.
  • Players (First Second) alternate turns.
  • Turn take any number from one row.
  • Winner player who takes the last counter.
  • Try it!

18
Game 1 Hints
  • Try Small Examples!
  • One-pile Nim
  • Two-pile Nim
  • Three-pile Nim
  • Look for Clues Patterns!
  • Develop a Hypothesis!
  • Test the Hypothesis!
  • State it as a Theorem and Prove it!

19
One-Pile Nim
Normal First player always wins by being greedy
take the whole row! Misere First player always
wins by being greedy take all but one! Solution
Take turns going first gt Boring!
20
Two-Pile Nim
  • Normal
  • Second player always wins if rows are even
  • take same number as First but from opposite row!
  • First player always wins if rows are not even
  • even the rows then pretend youre Second!
  • Misere First wins if rows are even and gt 1
    leave Second with 1!

21
Three-Pile Nim
  • Normal
  • Games 1 to 4 First player wins--take all row 1,
    play Two-pile Nim!
  • Game 5 Second player wins--try all possible
    first moves to see!
  • First takes row 1gt Second plays Two-pile Nim as
    First and wins!
  • Otherwise, First changes it to one of Games 1 to
    4
  • Second plays Two-pile Nim as First and wins
  • Game 6 Same as Game 5--order doesnt matter,
    just sizes!
  • Game 7 First can always win--find the winning
    opening move!

22
Three-Pile Nim
  • Misere Player who takes the last counter loses
  • Left as exercises for the student!
  • Play one another to test!
  • Develop a Hypothesis!

23
Three-Pile Nim
24
Three-Pile Nim
  • The row sizes and their binary notations are
  • 3 0 1 1
  • 4 1 0 0
  • 5 1 0 1
  • The sum is 0 1 0
  • To convert this sum to all zeros we need to
    remove the red 1 that is, remove two counters
    from row 1.

25
Nim The Impartial Game pt. I
  • Someone elses description
  • Rules
  • Several heaps of beans
  • On your turn, select a heap, and remove any
    positive number of beans from it, maybe all
  • Goal
  • Take the last bean
  • Example w/4 piles (2,3,5,7)
  • Use out theory to solvethis game!

26
Three-Pile Nim

Play online at this site http//www.robtex.com/fr
ames.htm
27
Instant Insanity
  • Problem
  • There are 4 equal cubes, each side is one of 4
    colors.
  • Stack the cubes atop one another
  • so that each of the 4 colors appears on each side
    of the tower.
  • Colors red (R), white (W) , blue (B), and green
    (G).

28
Puzzle 2 Instant Insanity
  • You have 4 equal cubes each side is one of 4
    colors.
  • Colors red (R), yellow (Y) , blue (B), green (G).
  • Stack the cubes atop one another so that
  • each of the 4 colors appears on each side of the
    tower.
  • There are four sides left, right, front, and
    back.
  • The picture below shows the tower laying down.

29
Puzzle 2 Instant Insanity
  • Each block can be placed in 24 different
    positions in the stack.
  • The number of possible stacks is
  • 242 331,776 possible arrangements
  • only 41,472 are unique because of symmetry.
  • Try for a few minutes--you may get lucky!

30
Puzzle 2 Hints
  • Try Small Examples? There are none--need all
    four!
  • Look for Clues Patterns? Would take a long
    time!
  • Develop a Hypothesis? Based on what?
  • Test the Hypothesis?
  • State it as a Theorem and Prove it?
  • Aha-theres the clue! Hire a Mathemagician to
    figure it out!
  • Google W.T. Tutte Graph Theory

31
Puzzle 2 Hints
  • Represent each cube by a graph of the colors that
    appear on opposite pairs of faces.
  • Four nodes stand for the four colors.
  • Edges link nodes corresponding to two colors on
    opposite faces.
  • If a pair of opposite sides has the same color,
    you draw a loop connecting the node to itself.

32
Puzzle 2 Hints
  • Here are the layout plans for four cubes

33
Puzzle 2 Hints
  • Represent each cube by a graph of the colors that
    appear on opposite pairs of faces.
  • R----Y
  • G----B

34
Puzzle 2 Hints
  • Combine the four graphs into one representation.
  • This graph shows the color relationship of the 12
    pairs of opposite faces of the four cubes.
  • R----Y
  • G----B

35
Puzzle 2 Hints
  • Because the puzzle's solution requires that the
    cubes be arranged in a row, eight of the 12
    numbered edges give you the colors of each of the
    row's four sides.
  • Find in this combined graph two separate
    subgraphs that each use all four nodes just once
    and each of four edges, numbered from 1 to 4.
  • Each node will have only two edges (or the two
    ends of a loop) meeting it.
  • One subgraph would represent the four front-back
    pairings, and the other would represent the four
    left-right configurations.

36
Puzzle 2 Hints
  • There is only one way of selecting two such
    subgraphs without using any edge twice. (A given
    edge cannot represent both front-back and
    top-bottom at the same time.)
  • These two Hamiltonian Cycles can then be used to
    arrange the cubes and solve the puzzle it's just
    a matter of following the edges in the right
    order along a particular cycle of the subgraph.
  • R----Y
  • G----B

37
Puzzle 2 Solution!
  • The graphs mean
  • Put the first cube with Y and G on the left and
    right, and with black and red on the front and
    back.
  • Put the second cube with red and green on the
    left and right, and with green and white on the
    front and back.
  • Put the third cube with black and red on the left
    and right, and white and black on the front and
    back.
  • Put the fourth cube with white and black on the
    left and right, and red and green on the front
    and back.
  • R----Y
  • B----G

38
Puzzle 2 Solution!
39
General Games--Game Theory
  • Payoff Matrix Saddle Points Mixed Strategies
  • Predator vs. Prey
  • Simulation
  • Java Applets
  • Phase Plots for Equilibrium Graphs
  • Evolutionarily Stable Strategy vs. Extinction
  • Wolves vs. Rabbits vs. Grass
  • http//www.shodor.org/interactivate/activities/
  • Games Against (Mother) Nature

40
General Games--Game Theory
  • Two-Person Zero Sum Game
  • http//people.hofstra.edu/Stefan_Waner/RealWorld/S
    ummary9.html
  • In a two-person zero sum game, each of the two
    players is given a choice between several
    prescribed strategies at each turn, and each
    player's loss is equal to the other player's
    gain.
  • The payoff matrix of a two-person zero sum game
    has rows labeled by the row player's strategies
    and columns labeled by the column player's
    strategies. The ij entry of the matrix is the
    payoff that accrues to the row player in the
    event that the row player uses strategy i and the
    column player uses strategy j.

41
General Games--Game Theory
  • Fundamental Principles of Game Theory
  • When analyzing any game, we make the following
    assumptions about both players
  • Each player makes the best possible move.
  • Each player knows that his or her opponent is
    also making the best possible move

42
General Games--Example
  • Paper, Scissors, Rock
  • Rock beats (crushes) scissors scissors beat
    (cut) paper, and paper beats (wraps) rock.
  • Each 1 entry (payoff) is a win for the row
    player, -1 is a loss (a 1 win for the column
    player), 0 indicates a tie.
  • Play the real game twice!
  • Play the matrix version twice!
  • Play the computer twice!

Blue
Red
Write a Comment
User Comments (0)
About PowerShow.com