Transcript Slide 1

.
Lecture6
•
•
•
•
•
•
Admin
Plagiarism forms
Answer football cup final problem.
//Daisy Problem hints e.g. try a smaller size.
General problem solving ideas. Show see.
Mention coursework.
Sums of games
• Previously we looked at a matchstick game, using
one pile of matches.
• We can have more than one pile of matches.
• First a pile must be chosen, then matches may be
removed from the chosen pile according to some
rule (which may differ from pile to pile).
• The game is thus a combination of two games.
• This particular way of combining games is called
summing games.
• There are other ways.
In General
• We have two games, each with its own rules.
• Let us call the two games, the left and right
games.
• A position in the sum game is the combination
of the position in the left game and the right
game.
• A move in the sum game is a move in one of
the left or right games.
Example – A graph
•
•
•
•
•
•
•
The single game.
Show figure 4.4 page 53
Each graph represents a game.
The positions are represented by nodes.
The moves are represented by edges.
Imagine a coin placed on a node.
(CAPITAL LETTER, lower case letter) e.g. (X, y)
• In the sum game, two coins are used.
• One coin being placed over a node in each of
the two graphs.
• A move is then to choose one of the coins,
and move it along an edge to another node.
• A move changes the position of one of the
coins.
• Are we looking at a state transition diagram?
Why/why not?
Labelling Positions in Sum Games
• The two games are unstructured, thus we
have to use brute force to determine if they
are winning or losing positions.
• The left game has 15 positions, the right game
has 11 positions.
• How many positions are there in the sum
game?
Computational Effort.
• There are 15.11 positions.
• Brute force is not a desirable approach.
• We now look at how to compute a strategy for
the sum of two games.
• We find that the computation effort needed
to find winning and losing states is not the
product, but the sum of the computational
effort for the individual games.
A simple sum game, Matchsticks.
• Suppose there are two piles of matches.
• A move is to choose a pile of matches, and
remove at least one match from that pile.
• The game is lost when a player cannot remove
any matches.
The single matchstick game.
• Given a pile of matches, remove at least one.
• The winning positions are the positions where
there is at least one match.
• The winning strategy is to remove all the
matches.
• The losing position contains no matches.
• Draw the state transition diagram.
Sum game strategy
• The single game strategy cannot be applied
directly to the sum game.
• Why not?
Strategy
• Symmetry between left and right allows us to
identify a winning strategy.
• Let m, n represent the number of matches in
the two piles.
• In the end m=n=0.
• This suggests m=n identifies losing positions.
• Choose the larger pile and restore the
property that m=n.
Initial Property
• The property n!=m is the precondition for the
winning strategy to be applied.
• Equivalently m<n or n<m.
• If m<n , we infer 1 <= n-m <=n
• So n-m matches can be removed from the pile
with n matches.
• After the assignment n:=n-(n-m), the property
m=n will hold.
More Simple Sum Games
• Suppose K matches can be removed (K is
fixed).
• This restriction disallows some winning
moves.
• We are not allowed to remove m-n matches
when K<m-n
• The property m=n no longer characterises
losing positions.
Example K=1
•
•
•
•
Example K=1
Lets set K=1
(2, 0).
A player is forced to move to (1, 0) and the
opponent can then win the game.
Symmetry Restrictions
• Seems that the strategy of restoring symmetry
no longer applies.
• Worse, if the number of matches we are
allowed to remove from the two piles differs.
• E.g. M and N (N!=M)
• Or the left and right games may be completely
different!!!
• E.g. matchstick game and daisy game.
One Pile game with K
• With one pile of matches, where M matches
at most can be removed,
• Is to continually restore the property that the
remainder after dividing the number of
matches by M+1 is 0 (i.e. m mod (M+1) == 0)
• The number, m mod (M+1) == 0, determines if
the position is winning or not.
Two Pile Game
• The one player game suggests the symmetry
as
• m mod (M+1) == n mod (N+1)
• In the final position (0,0), this property is
satisfied.
The MEX function p57
•
•
•
•
•
•
Consider the sum of two games.
The position in the sum game is (l, r).
A move affects one component
Assignments are l := l’ or r :=r’
(i.e. the left or right component is affected)
Define two functions L and R on the left and right
positions such that,
• (l, r) is a losing position exactly when L(l) = R(r).
Analysis
• L and R must have equal values on end positions.
• Every move from a losing position (l,r) should result in
a winning position satisfying L(l) !=R( r)
• Applying the winning strategy from a winning position,
should result in a losing position. i.e. start with
• We require that:
• For end positions L.l=R.r=0
• For every l’ such that there is a move from l to l’ L.l !=
L.l’
• For any number m < R.r, it is possible to move from r to
r’ such that R.r’=m (similar for left).
Definition of Mex Function
• Let p be a position in a game. The mex value of p
(mex.p), is defined as the smallest natural number, n,
such that
•
There is no move in the game from p to position q
satisfying mex.q=n
•
For m < n, there is a move from p to q satisfying
mex.q=m.
• Informally, mex.p is the minimum number that is
excluded from the mex numbers of positions q to
which a move can be made from p (i.e. q is a successor
of p).
• This is a recursive definition.
Using the MEX function
• Show figure 4.4, and 4.6 page 60. DAG
• The graph do not have regular structure, so
the mex numbers must be calculated by hand.
• End positions have a mex number of 0,
• A mex number can be give to a node when all
its successors have been assigned a mex
number.
• The number is the smallest number that is not
included in the mex numbers of its successors.
Playing the game
• Suppose we start with “Ok” (O,k) as our position.
• This is a winning position because the mex
numbers are different.
• The winning strategy is to move the right graph to
node i which has the same mex number as “O”.
i.e. we are restoring the balance (making R.r = L.l)
• The opponent will then disrupt the balance
(making this an inequality).
• The first player the repeats the strategy of making
the mex numbers equal, until the opponent can
move no further.
Lack of Structure
• Note that due to the lack of structure, the mex
number of the 15 left and 11 right positions
were calculated individually.
• In total we did 15+11 calculations, and not
15*11 (=165) calculations.
Tetrominoes
• Problem statement:
• Suppose a rectangular (n x m) board is covered with T Tetrominoes,
show that the number of squares is a multiple of 8
• Clearly it must be a multiple of 4.
• Placing a tetrominoe on the board is modelled by the assignment c
:= c+4
• c is the number of squares covered.
• Initially c = 0
• Thus c mod 4 is invariant.
• In words we say c is a multiple of 4
• c = n.m and is a multiple of 4.
• Therefore either n or m or both are a multiple of 2.
Light and Dark
• We introduce two type of T Tetrominoes.
(show colouring on board)
• B counts the number of black squares covered
and w white.
• Placing a dark T is modelled by
• d, b, w := d+1, b+3, w+1
• Placing a light T is modelled by
• l, b, w := l +1, b+1, w+3
Invariants
An invariant of both assignments is
• b – 3d –l
• (prove on board for both assignments, p18)
• Similarly, w – 3l –d
Glass Chessmen
• There is a 100-floor building. We have two glass
chessmen. We should use these two glass
chessmen to test the lowest floor that the glass
chessman would broken if they drop from this
floor. If two glass chess men are both broken, it's
failed. There are many methods. But the problem
is ask us to give the optimum measuring method.
It means that the times of dropping should be as
fewer as possible considering the worst
possibility. For instance, if we drop floor by floor,
it maybe 1 times or 100 times, it is the worst
method.