Download Sample Past Writing - Math

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Game mechanics wikipedia , lookup

Deathmatch wikipedia , lookup

Minimax wikipedia , lookup

Chicken (game) wikipedia , lookup

Artificial intelligence in video games wikipedia , lookup

Reversi wikipedia , lookup

Transcript
SAMPLES OF HIGHER RATED WRITING: LAB 1
1. introduction
Sample 1
Imagine yourself immersed in an intense and furious battle of strategies with an opponent. It’s nearing the
end, and you find yourself in a position with tons of possibilities; your foe is backed in a corner, and you’re
ready to finish the job. However, it’s your opponent’s turn, and with a sly grin on his face he makes one move
that completely turns the game around, and now it’s YOU who faces certain defeat! How can you prevent
such embarrassment? Enter the mathematics of Two-Player Game Theory. With mathematics under your
belt, it becomes a simple matter of equations to secure victory every time.In this report, you will see the
numbers behind three combinatorial games- subtraction games, Nim, and Euclid’s Game.
First, some definitions:
• Finite Combinatorial Game: A game for two players. The game must be FINITE (the game eventually ends), TWO-PLAYER, WIN-LOSE (There cannot be any draws)(The game eventually ends),
and PERFECT-INFORMATION (each player knows exactly what the other can do) in format.
• Subtraction Game: A finite combinatorial game in which players start with one large positive integer
(i.e. n = 35) or "pile" and a set of smaller positive integers (i. e. S = {2, 3, 5}). Players, in turns,
subtract an amount from the large integer equal to one of the members of the set until no legal
moves remain, in which a legal move is a move that does not cause the "pile" to go negative. The
last player to make a legal move wins.
• Nim: A finite combinatorial game in which players start with a certain number of "piles" with amount
equal to some positive integers (i.e. 3 piles worth 10, 12 and 15). Players take turns subtracting a
positive integer from one pile less than or equal to the amount of that pile (i.e. one player might
take 6 from the 12 pile, leaving 6 left) until no more legal moves can be made. The last player to
make a legal move (in effect, the player to take the remainder of the last remaining pile) wins.
• Euclid’s Game: A finite combinatorial game based upon Euclid’s Algorithm. The game begins with
two non-negative integers (i.e. 186 and 13). Players take turns subtracting nonzero multiples of one
integer from the other without using or creating a negative number (i.e. Player 1 takes 65 (5 ∗ 13)
from 186, creating 121, so the game becomes 121 and 13). The game ends when no more legal moves
can be made (when the remaining integers are some integer and 0); the last player to make a legal
move wins.
• Strategy: In terms of game theory, a strategy of Player 1 is defined as a function F(t(i))=o(i+1)
with a finite domain sequence t(0), t(1),... t(m), where t(i) is a possible move of Player 2 in inning
i, and an output o(i+1) defined as a legal move for Player 1.
• Winning Strategy: A strategy F for 1 is a Winning strategy if for every t(i), there is an o(i+1) that
puts Player 1 in an optimal winning position.
• Zermelo’s Theorem: States that in ANY finite combinatorial game, one player, Player 1 or Player 2,
has a winning strategy. Also known as the Fundamental Theorem of Combinatorial Games.
The problem becomes this: Given a combinatorial game, which player has the winning strategy? We here
discuss the answer to this question for the games of Subtraction, Nim, and Euclid’s Game.
Sample 2
A game is a competition, or challenge, which involve wins or losses between two or more players who follow
official rules. There are many types of games involving various conditions. There are games for entertainment
purposes such as chess, cards, and Settlers of Catan, as well as real-world games in areas such as economics,
politics, and biology. Even though there is a vast array of games with differing rules and conditions, they all
Date: February 4, 2015.
1
2
SAMPLES OF HIGHER RATED WRITING: LAB 1
seem to have a common goal. This goal is to win. Mathematically analyzing games can aid in this common
goal. We will be able to indicate the best course of action for each player.
We will be focusing finite combinatorial games. Specifically, we will be analyzing the Subtraction game,
the game of Nim, and Euclid’s game. We hope that by dissecting each of these games we will be able to find
patterns, which will allow us to make predictions about the outcome. Given each instances of combinatorial
games, we hope to determine which player has the winning strategy.
Finite combinatorial games involve two players, player ONE and player TWO, in which each player
alternates moves starting with player ONE. We assume that there is perfect information such that the game
situation is perfect and the players’ have perfect memories. Also, the game will end after finitely many moves
where one player wins and the other player loses, no draws.
Definition 1. Strategy
Player ONE:
A function F with:
(1) Domain finite sequences ∅, · · · , (t1 , · · · , tm ) where
(2) Each ti is a possible move of TWO in inning i, and
(3) Each value oi+1 = F (t1 , · · · , ti ) is a legal move of ONE
Strategy for TWO is defined similarly.
Definition 2. Play
A maximal sequence: o1 , t1 , o2 , t2 , ...
(1) If the sequence ends in an o, player ONE is the winner.
(2) If the sequence ends in a t, player TWO is the winner.
Definition 3. F-play
A play made that follows the F stratgey.
Definition 4. Position
There are two types of positions in a two-player game:
(1) P − position if the player who just payed has a winning strategy from that position.
(2) N − position if the player to play next has the winning strategy from that position.
Theorem 1 (Zermelo’s Theorem.). In each perfect information two-player win-lose games, some player has
a winning strategy.
2. Technical Findings: Subtraction Games
Sample 1
First on our list is the humble Subtraction Game. The rules are simple: Keep taking ’till you can’t take
any more. In more precise terms, the game starts with one large, set integer- say, a row of bottles- and a
ruleset, or the amounts a person can take at any given time.
Let’s make an example. Fred and Charlie are playing Subtraction using wine bottles. They have 64
bottles in all. They each take turns removing 3, 5, or 7 bottles. Fred starts by taking 3 bottles. Charlie
takes 5, leaving 56. Their moves continue: Fred 5 (51), Charlie 3 (48), Fred 7 (41), Charlie 7 (34), Fred 3
(31), Charlie 3 (28), Fred 7 (21), Charlie 5 (16), Fred 5 (11), Charlie 3 (8), Fred 7 (1). Fred is declared the
winner, as Charlie cannot make any more moves. However, did Fred employ a winning strategy, or did he
win by dumb luck?
To find out, working backwards is essential. The ruleset in this example is defined as S = {3, 5, 7}. Let
us define a P-position as a position in which the player who just moved has the winning advantage, and
an N-position as a position in which the next player to move has a winning strategy. 0, 1, and 2 bottles
remaining are naturally P-positions in this case, as these three positions allow no more legal moves. 3 is an
N-position, as the next player can simply take 3 and leave 0 left, making them the winner. 4, 5, 6, 7, 8 and
9 are N-positions for similar reasons: by taking 3, 5 or 7 bottles, the remainder becomes 0, 1 or 2. 10 is a
P-position, as any move made by the next player will result in an N-position for his opponent’s turn; 11 and
12 are P-positions for the same reasons. Observe that a player in an N-position can optimize his situation
SAMPLES OF HIGHER RATED WRITING: LAB 1
3
by removing enough bottles to create a P-position, while a player in a P-position can do nothing but place
his opponent in an advantageous N-position. With this in mind, we can fill in the rest:
0, 1, 2 = P
3→9=N
10, 11, 12 = P
13 → 19 = N
20, 21, 22 = P
23 → 29 = N ...
Observe that the P-N pattern repeats every 10 entries. Knowing this, we realize that 64 becomes an
N-position. As 64 is the opening position, the next player to move would be Fred. Also of note: Every move
that Fred made put Charlie in a P-position, while every move that Charlie made gave Fred the N-position.
Thus, we can say that Fred did in fact employ a winning strategy. On the other hand, suppose the game
began with 52 bottles. Since 52 is a P-position, the player with the winning strategy would be Charlie, as
every move made by Fred would put Charlie in an N-position.
Naturally, this pattern will not be the same for all rulesets. Should Fred and Charlie have picked a different ruleset- say, S = {2, 5}- then the pattern would look very different. 0 and 1 would remain P-positions,
but 2 becomes an N-position. 3 and 5 would remain N-positions, but 4 is a P-position. To sum up, the
pattern would appear as below:
0, 1 = P
2, 3 = N
4=P
5, 6 = N
7, 8 = P
9, 10 = N
11 = P
12, 13 = N
14, 15 = P ...
This time, the pattern of P’s and N’s repeats every 7 entries. In this pattern, 64 becomes a P-position,
meaning Charlie would have had the winning strategy.
However, to avoid having these be called fluke coincidences, we need a formula that determines the player
with the winning strategy without fail in any given ruleset.
Proposition: Let S be a ruleset for a game of Subtraction. We show that the player with the winning
strategy is determined by the initial value and by S.
Proof. Let us pick 2 arbitrary values p and q, p < q, to represent our ruleset: S = {p, q}. We know that
any value less than p is a P-position, as no more legal moves could be made after the fact.
0 → (p − 1) = P
Continuing from here becomes dependent on p’s relation to q. We know q > p, but by how much? Is
q > 2p? 3p? First, let us explore the case that 2p > q > p. In this case, we know that any position from
p to (q + p − 1) must be an N-position, because the next player (be they Fred or Charlie) can take p or q
bottles away and leave no remaining legal moves for his opponent.
p → (q + p − 1) = N
At (q + p), we have another P-position, as the player moving next has no choice but to put his opponent
in an N-position. This holds true for all values from (q + p) to (q + 2p − 1).
(q + p) → (q + 2p − 1) = P
4
SAMPLES OF HIGHER RATED WRITING: LAB 1
(q + 2p) → (2q + 2p − 1) = N
We can see that the pattern is repeating itself every p + q entries; recall that in Fred and Charlie’s games,
the pattern repeated itself every 10 entries when the ruleset had minimum value 3 and maximum value 7,
and every 7 entries when the ruleset’s minimum was 2 and the maximum was 5. But what of the case when
q is ridiculously large in comparison to p? To observe this effect, let us assume 7p > q > 6p. The beginning
p entries remain P-positions:
0 → (p − 1) = P
p is an N-position. So is every entry up to and including (2p − 1). But from there, since q is so very large,
we encounter more P-positions as our only option is to take p bottles at a time.
p → (2p − 1) = N
2p → (3p − 1) = P
3p → (4p − 1) = N
4p → (5p − 1) = P
5p → (6p − 1) = N
Upon reaching 6p, we have P-positions until- hurrah!- we reach q. Then we continue with N-positions
until we reach (q + p − 1), and from our earlier observations we can conclude that the pattern will repeat
itself after that.
6p → (q − 1) = P
q → (q + p − 1) = N
(q + p) → (q + 2p − 1) = P ...
Observe how, unlike when 2p > q > p, the P-N pattern fluctuates considerably before repeating. We
observed a small example of this back-and-forth effect when the ruleset was S = {2, 5}; unlike in the other
ruleset, there was no intermediary values to "cover" the value 4. Observe that depending on the values of
the ruleset and the initial value picked for the game, either Player 1 will have a winning strategy (if the initial value is an N-position) or Player 2 will have a winning strategy (if the initial value is a P-position). Q.E.D.
3. Technical Findings: NIM
Sample 1
In the game of Nim there are multiple piles of variable sizes. S = {a, b, c...}where a, b, c, ...N. Each player
must subtract a value n such that n < |a| where a is the pile n is being subtracted from. In the Nim, the
last player to subtract a value from a pile wins the game. Examples of the game are listed below.
Example: Equal Pile Two-Pile Nim Game 1
Pile A Pile B
Player One
Player Two
10
10
-9 from Pile A
1
10
-9 from Pile B
1
1
-1 from Pile A
0
1
-1 from Pile B
0
0
Player Two Wins
Example: Equal Pile Two Pile Nim Game 2
Turn number
1
2
3
4
5
SAMPLES OF HIGHER RATED WRITING: LAB 1
5
Pile A Pile B
Player One
Player Two
Turn number
20
20
-19 from Pile A
1
1
20
-19 from Pile B
2
1
1
-1 from Pile A
3
0
1
-1 from Pile B
4
0
0
Player Two Wins
5
We chose these examples because it is representative of a larger class of equal two-pile games.
From the above two games, Ashley and I noticed that the second player will always win by taking the
same action as the first player on the other pile.
Conjecture 2: Solution to an equal pile two pile game of Nim.
The second player will always win a equal pile two pile game of Nim.
Proof:
The second player is always able to win because they can mirror the other players moves, this will always
win them the game because they will always have the last turn due to the other players.
Conjecture 3:
In a Nim game with three equal sized piles the first player will always win.
Proof:
The first player will always win a Nim game of three piles, because they can take away an entire pile and
become the second player in a two equal sized pile game which via conjecture 2 is the winner of the game.
Further investigation of different conditions of the Nim game made us realize that the game becomes very
complicated with more elaborate starting conditions. In class we learned about Bouton’s theory which provides a winning strategy for the Nim game regardless of the starting conditions.
Bouton’s 1902 Theorem
L L
N (n1 , ..., nk )is a P -position if, and only if, B(n1 ) ... B(nk ) = B(0)
Bouton’s theorem uses base two, because essentially there are two options for each pile either to remove
the entire pile or remove less than the entire pile from the pile.
Example 1: Application of Bouton’s theorem
B(15) = (1, 1, 1, 1, 1, 0, 0, ...)
B(16) L
= (0, 0, 0, 0, 1, , 0, 0, ...)
B(15) B(16) = (1, 0, 0, 0, 1, 0, 0, ...) = 2
In order for player one to be the winning player there must be a possible move for them that makes the Nim
sum equal to zero. So in this example reducing 16 to 15 creates the following Nim sum of zero.
B(15) = (1, 1, 1, 1, 1, 0, 0, ...)
B(15) L
= (1, 1, 1, 1, 1, 0, 0, ...)
B(15) B(16) = (0, 0, 0, 0, 0, 0, 0, ...) = 0
Because the first player is able to make the new Nim sum equal zero they have the winning position.
This is another way to prove our second and third conjectures.
Sample 2
6
SAMPLES OF HIGHER RATED WRITING: LAB 1
Multiple stacks allowing any size removal greater than or equal to one, from only one stack at at time:
Suppose there are two stacks of 3 elements each, and Players 1 and 2 may remove as many elements as
they want from just one stack on their turn. Player 2 has a winning strategy by copying Player 1s move but
with the other stack, keeping the two stacks equal. Player 2 then takes the last element, winning by leaving
Player 1 with no possible moves.
That is a simple illustration of a winning strategy, but this game allows several initial stacks as long as
the number is a whole number, and the number of elements in each stack can be different and of any finite
whole number size.
Experimentation supports a published winning strategy that was taught in class. The number of elements
in each stack must be written as binary numbers with an equal number of digits, using zeros as necessary to
keep their value. Next, a new binary number is created from this list of binary numbers to represent them.
We look the number of 1s in each place (16s, 8s, 4s 2s or 1s place) for the entire group of numbers. If the
number of 1s in a particular place is even, we assign a zero to that place in the new number. If the number
of 1s is odd, we assign a one for that place in the number.
For example, look at the following three numbers: 100101, 010101 and 000011. For the far left place,
there is a 1, a 0 and a 0 for the three number, which is an odd number of 1s, which gets a 1 assigned to
the far left place of the representative number. For the far right place, there is 1, 1, 1, which is also an odd
number of 1s, so that 1 is assigned. So the number that represents these three numbers is 110011. Since
110011 is not Nim equal to zero, the player whose turn it is has a winning strategy. The player must remove
an odd number of 1s from the first two places and the last two places, doing so by removing elements from
just one of the three stacks, which means only one of the three numbers can be changed. Assume the 32nd
place is on the left. Removing the entire third stack would fix the last two digits to zero, but not the first
two. In this case, only the first stack is large enough to affect all 6 digits, and every group of stacks always
has a largest. We look at 100101, and need to change the first two and last two by an odd number, which
is 1, and leave the middle two the same. This results in 010010. To find out how to get from 100101 to
010010, we subtract the second from the first. Let’s convert to decimal to make this easy. The first number
is 37 and our goal number is 18. This means we must remove 19 elements from the first number to reach
Nim zero. Verify that 010010, 010101 and 000011 add to Nim zero. Player 2 can’t maintain Nim zero, since
there is no way to remove an even number of elements from any one binary place. A non zero number must
be removed, and binary does not have 2 in place, and Player 2 may only take from one pile. This makes it
very convincing that the binary system is perfect.
The published results taught in class claim that the player that can make the representative number equal
to zero has a winning strategy. They claim that the then losing player is only capable of changing the number
to a non-zero number, and that the winning player can change it back to zero each time, eventually making
the last winning move. There are many available proofs online, which we opted not to copy.
4. Technical Findings: Euclid’s Game
Sample 1
Now let’s talk about Euclid’s Game. In this game, the players start with two positive integers, one smaller
than the other, and they subtract a non-zero multiple of the smaller number from the larger in which the
result is nonnegative. The game ends when the remaining integers are of the format (x, 0). The player to
make the last legal move wins.
So our lucky boys Fred and Charlie start up another competition, this time the battle being Euclid’s
game. They settle on (192, 17) for their beginning integers, and Fred starts the game.
(192, 17) Start
(22, 17) After Fred 1
(5, 17) After Charlie 1
(5, 7) After Fred 2
(5, 2) After Charlie 2
(3, 2) After Fred 3
(1, 2) After Charlie 3
SAMPLES OF HIGHER RATED WRITING: LAB 1
7
(1, 0) After Fred 4
So Fred wins. But has he employed a winning strategy in this case? To find out, we must consult the
basis for this game- Euclid’s Algorithm. Euclid’s Algorithm, based on long division, in this case, will predict
certain moves that must appear in a given game: the moves in which the small integer suddenly becomes
bigger than the other. Observe:
192 = 11(17) + 5
17 = 3(5) + 2
5 = 2(2) + 1
2 = 2(1) + 0
Observe that when we plug in the large integer for a and the small integer for b, each r value in the
formula a = q(b) + r becomes the new "small" integer while b becomes the big integer.
At this point we need to create a couple of definitions.
• Integer-Change Move: A move in which a player creates a new set of integers where the smaller
integer in the previous set becomes the larger integer in the new set.
• Forced Move: A move in which a player has no choice but to complete an integer-change move. In
terms of long division, q = 1 in a forced move.
• Manipulable Move: A move in which a player can choose whether or not to complete an integerchange move or simply reduce the larger integer without crossing over. In terms of long division,
q > 1 in a manipulable move.
Look again at the Euclid’s Algorithm we just went through. In every case, q > 1, so each of these steps
are manipulable. Let’s write down these integer-change moves with spaces in between to demonstrate the
possibility of an intermediary move.
(192, 17)
(5, 17)
(5, 2)
(1, 2)
(1, 0)
Now, the player with the winning strategy will be the one who makes the winning move, so we can infer
that no new moves will be placed in between the final two moves. The player with the winning strategy will
need to manipulate his opponent into doing their bidding- in other words, they need to shove their opponent
into a forced-move situation in such a way as they will always get a manipulable move. In this game, this
would be achieved by forcing the opponent into doing every integer-change, so we know that moves exist in
between all spaces besides the final space:
(192, 17)
(22, 17)
(5, 17)
(5, 7)
(5, 2)
(3, 2)
(1, 2)
(1, 0)
8
SAMPLES OF HIGHER RATED WRITING: LAB 1
So in this scenario, by counting backwards, we see that Player 1 (Fred) has the winning strategy. Another
point to note: The player who has the first manipulable move (even if that move happens to be the move
just before the end of the game) will be the winner, as they can choose their moves in order to ensure it is
their turn during any future manipulable moves (including the final move, which by the game’s rules will
always be manipulable). So we have two ways to confirm that Fred indeed does have the winning strategy:
(1) We go through the absolutely necessary moves, then see how the winner can ensure their win, and count
backwards, and (2) we look for the player who has the first chance to manipulate a move (Player 1 in this
case).
Sample 2
Euclid’s game is played with a and b such that a, bN. Each turn a player subtracts a multiple of
either a or b from the other number. A subtraction can nor be done if it will generate a negative number,
and the last player to make a move is the winning player.
In class we were reminded of Euclid’s theorem:
Let a < b be positive integers
b=q∗a+r
0≤r<a
To being our investigation of Euclid’s game, we started by playing a sample game.
Example: Euclid’s Game with initial conditions a = 723 and b = 122
a
b
Player One
Player Two
Turn
723 122 722-122*5
1
113 122
113-122
2
113 9
113-(9*12)
3
5
9
9-5
4
5
4
5-4
5
1
4
4-(1*4)
6
1
0
Player Two Wins
7
We noticed when playing this game that you are only able to take a certain number of multiples of the
smaller number from the larger number.
Conjecture 4:
In Euclid’s game of E(a, b), the game state E(a, r) will always be reached, where b = q ∗ a + r.
Proof:
According to Euclid’s theory, there is a set number of multiples of athat can be taken out of b. If q + 1
multiples were subtracted, r would become a negative number which is prohibited by the rules of the game.
The players are unable to subtract the larger number b from a because it will generate a negative number.
Thus the only option the players have is to continue subtracting multiples of afrom b until the game has
reached the state E(a, r).
Application of Conjecture 4:
Consecutively applying conjecture 4 allows all of the “intersection points” of Euclid’s game to be computed.
The following program and its output are a good example of the applications of Euclid’s theorem in this
context.
SAMPLES OF HIGHER RATED WRITING: LAB 1
9
There are forced and choice moves. Forced moves are when you only have the option of taking away
one multiple. Choice moves are when you can decide to take away a number of multiples.
Conjecture 5:
The first player to have a choice move will win the game.
Proof:
The last nonzero position in the game is an N position because the next player has the last move. From this
point forward, the points that have only one multiple are the opposite position of the position before them.
All of the positions with more than one multiple are N positions, because player One at these positions can
successively apply Euler’s theorem to find if the next position is a P or N position. If the player sees that
the next position is a P position, they will take all of the multiples away leaving the other player with the
losing position. If they see that the next position is an N position they can leave one multiple and force the
10
SAMPLES OF HIGHER RATED WRITING: LAB 1
other player to give them the winning position. The following code allows two players to quickly play a game of Euclid’s game.
What if a and b are consecutive Fibonacci numbers?
Playing the game with consecutive fibonacci numbers yielded a very interesting result. The values transversed down the sequence of Fibonacci numbers. This suggests that the Fibonacci numbers can be defined
using Euclid’s division theorem! Below is the output of the above program for the Fibonacci numbers.
SAMPLES OF HIGHER RATED WRITING: LAB 1
11
What if a and b are Fibonacci numbers with only one Fibonacci number between them?
When you play a game with Fibonacci numbers that have a space between them, it becomes very similar to playing without the space. Except the first move, and the first move only, is a choice move. After
either one or two multiples of the smaller Fibonacci number have been subtracted, you are left with a game
with consecutive Fibonacci numbers.
12
SAMPLES OF HIGHER RATED WRITING: LAB 1
Does the number of moves before the game is over depend on some way on a and b?
Looking at the application of Conjecture 4, we can find the minimum and maximum number of moves
in a game of Euclid’s game. Each possible multiple that can be taken off of one number represents a possible
turn in the game. If the players were to take only one multiple off each turn, the number of moves would
be the sum of the q’s found with each iteration of Euclid’s theorem on the initial a and b. The shortest
possible game would be if the players took off q multiples each turn. The number of moves would then be
the number of times Euclid’s theorem was applied before r equaled zero.
Does the parity of the number of moves before the game is over depend on a and b in some way?
We do not believe that the parity of the number of moves can be determined by a and b because there
are no fixed number of moves available to make; there is only a possible range of moves that can be made.
Therefore, we cannot tell whether the number of moves will be odd or even in a game in which no strategy
is followed.
What if in the previous two questions, a winning strategy is followed?
If a winning strategy is applied, the number of moves can be predicted because a winning strategy in
Euclid’s game the opponent is given no choice, and the number of moves that the player with the winning
strategy makes is dictated by the strategy. Because we were able to predict the number of moves each player
makes, we could determine the parity of the number of moves that would be made.