Matchstick games
This presentation is the property of its rightful owner.
Sponsored Links
1 / 19

Matchstick Games PowerPoint PPT Presentation


  • 157 Views
  • Uploaded on
  • Presentation posted in: General

Matchstick Games. AE1APS Algorithmic Problem Solving John Drake. Outline of the course. Invariants – Chapter 2 River Crossing – Chapter 3 Logic Puzzles – Chapter 5 Matchstick Games - Chapter 4 Matchstick Games – Winning Strategies Subtraction-set Games Sum Games – Chapter 4

Download Presentation

Matchstick Games

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Matchstick games

Matchstick Games

AE1APS Algorithmic Problem Solving

John Drake


Outline of the course

Outline of the course

  • Invariants – Chapter 2

  • River Crossing – Chapter 3

  • Logic Puzzles – Chapter 5

  • Matchstick Games - Chapter 4

    • Matchstick Games – Winning Strategies

    • Subtraction-set Games

  • Sum Games – Chapter 4

  • Induction – Chapter 6

  • Tower of Hanoi – Chapter 8


Simple two player games

Simple two player games

  • The goal is to have some method (i.e. algorithm) do decide what to do next so that the eventual outcome is a win

  • The key to winning is to recognise the invariants

  • Remember - An invariant is something that does not change


Simple two player games1

Simple two player games

  • We will work with matchstick games

  • We identify winning and losing positions in a game

  • A winning strategy is therefore maintaining an invariant


Matchstick games1

Matchstick Games


Matchstick games2

Matchstick Games

  • Played with one or more piles of matches

  • Two players make alternate moves

  • A player can remove one or more matches from one of the piles, according to a given rule

  • The game ends when there are no more matches to be removed

  • The player who cannot take any matches is the loser, i.e. the player who took the last match(es) is the winner


Terminology

Terminology

  • This is an impartial, two person game with complete information.

  • Impartial means rules for moving apply the same to both players.

  • Complete information means that both players have complete information about the game i.e. they know the complete state of the game.

  • An impartial game that is guaranteed to terminate, it is always possible to characterise the positions as winning or losing positions.


Winning and losing moves

Winning and Losing Moves

  • A winning position is one from which we can assure a win.

  • A losing position is one from which we can never win.

  • A winning strategy is an algorithm for choosing moves from winning positions that guarantees a win (i.e. we maintain an invariant).


Identify positions

Identify Positions

  • Suppose there is one pile of matches, and a player can remove either 1 or 2 matches

  • How do we identify winning and losing positions?


Winning strategies

Winning Strategies

  • Draw a state transition diagram (p.70)

  • Nodes are labelled with the number of matches remaining

  • Edges define the transition of state when a number of matches removed on that turn

  • We can now label the nodes as winning or losing


State diagram

State Diagram

  • A node is winning if there is an edge to a losing position

  • A node is losing if every edge from the node leads to a winning node (i.e. we cannot escape from the losing situation)


State diagram1

State Diagram

  • Node 0 is losing, as there are no edges from it

  • Nodes 1 and 2 are winning, as there is an edge to node 0

  • Node 3 is losing, as both edges from 3 are to nodes 1 and 2 which are already labelled as winning

  • A clear pattern emerges; losing positions are where the number of matches is a multiple of 3


Winning strategy

Winning Strategy

  • Beginning from a state in which n is a multiple of 3, and making and arbitrary move, results in a state in which n is not a multiple of 3. Thus removing n mod 3 matches results in a state in which n is again a multiple of 3.

NB: Only labelled to 7


Formally

Formally

  • The terminology we use to describe the winning strategy is to maintain invariant property that the number of matches remaining is a multiple of 3


Initial situation

Initial Situation

  • If both players are perfect, the winner is decided by the starting position. If the starting position is a losing position, the second player is guaranteed to win. Starting from a losing position, you can only hope that your opponent makes a mistake, and puts you in a winning position.


Some variations

Some Variations

  • Some variations on the matchstick game:

  • There is one pile of matches, each player is allowed to remove 1, 3, 4 matches

  • There is one pile of matches, each player is allowed to remove 1, 3, 4 matches, except that you are not allowed to repeat the last move. So if you opponent removes 1 match you must remove 3 or 4.

  • What are the winning positions and what are the winning strategies.?


Subtraction subset

Subtraction Subset

  • What are the winning positions and what are the winning strategies?

  • {1, 3, 4} Subtraction subset

  • We can remove 1 or 3 or 4 matches.


Winning strategy1

Winning Strategy

  • Calculate the remainder r after dividing by 7i.e. mod 7

  • If r is 0 or 2, the position is a losing position. Otherwise it is a winning position.

  • The winning strategy is to remove 1 match if r=1,

  • Remove 3 matches if r=3 or r=5, remove 4 matches if r = 4 or r =6.


The daisy problem

The Daisy Problem.

  • Suppose a daisy (a flower) has 16 petals arranged symmetrically around its centre. Two players take it in turns to remove petals. A move means taking one petal or two adjacent petals. The winner is the person who removes the last petal. Who should win and what is the winning strategy.


  • Login