Game Theory: Nim - Winning Strategy for 5 & 1000 Stones

In summary: Well, there is always a winning strategy in such games, but whether it's...The number of stones is irrelevant. There is a winning strategy. Period.
  • #1
Ikastun
10
0

Homework Statement



  • Two players: A and B.
  • Players can take 1 or 2 stones per turn.
  • The player who takes the last stone wins.
The question is: is there any winning strategy with 5 stones?, does it change with 1000 stones?.

Homework Equations



None.

The Attempt at a Solution



If there are 5 stones player A has a winning strategy if he takes 2 stones in his first turn. 3 stones left, so B can take 1 or 2 but in any case there are available stones and A wins.

If there are 1000 stones I don't know.
 
Physics news on Phys.org
  • #2
Ikastun said:

Homework Statement



  • Two players: A and B.
  • Players can take 1 or 2 stones per turn.
  • The player who takes the last stone wins.
The question is: is there any winning strategy with 5 stones?, does it change with 1000 stones?.

Homework Equations



None.

The Attempt at a Solution



If there are 5 stones player A has a winning strategy if he takes 2 stones in his first turn. 3 stones left, so B can take 1 or 2 but in any case there are available stones and A wins.

If there are 1000 stones I don't know.

Try a few cases like 4,6,7,8,9 stones etc and see if you notice anything.
 
  • #3
"Five stones" is pretty close to trivial. The first person takes 2 stones, leaving three. If the second person takes one stone, the first person takes the two remaining stones, winning. If the second person takes two stones, the first person takes the one remaining stone, winning.
 
  • #4
Ikastun said:
The attempt at a solution

If there are 5 stones player A has a winning strategy if he takes 2 stones in his first turn. 3 stones left, so B can take 1 or 2 but in any case there are available stones and A wins.

HallsofIvy said:
"Five stones" is pretty close to trivial. The first person takes 2 stones, leaving three. If the second person takes one stone, the first person takes the two remaining stones, winning. If the second person takes two stones, the first person takes the one remaining stone, winning.

Didn't the OP already observe that?
 
  • #5
Ikastun said:


If there are 1000 stones I don't know.


The number of stones is irrelevant. There is a winning strategy. Period.

It's been about 50 years since I knew the math on it but it's something like writing out the # of remaining stones in binary and then taking away a number of stones that does something (I forget what) the the form of the binary number.
 
  • #6
Presuming there are 1000 stones and player A gets to go first...

It seems to me that player A can ensure a victory every time as long as he doesn't take 2 stones at a time on the first turn ( I tried several cases myself ).

If player A only takes 1 stone on the first turn, he/she can force player B into the 5 stone scenario which you know is a guaranteed win. Just some stuff I was fiddling with.
 
  • #7
phinds said:
The number of stones is irrelevant. There is a winning strategy. Period.

Not always. It depends on the starting state.

It's been about 50 years since I knew the math on it but it's something like writing out the # of remaining stones in binary and then taking away a number of stones that does something (I forget what) the the form of the binary number.

But the OP's problem is a simple sub-version of the game of Nim. You don't need anything but a little reasoning to figure it out. Hopefully everyone will let the OP do that.
 
  • #8
LCKurtz said:
Not always. It depends on the starting state.

You are right of course. If the starting state has the binary number in the requisite form and they both know the strategy, then the starter cannot win. Good point.

EDIT: there IS still a winning strategy of course, just not for the starter in this case :smile:
 
  • #9
OH, I just realize that the OP is talking about a LIMITED form of NIM (yeah, LCKurtz, I see that you pointed that out --- I'm dense sometimes). That may not have a winning strategy for any number of starting stones. I think I remember now what the strategy that I was talking about is and it requires that you be able to remove up to half of the stones.
 
  • #10
I would also like to add to my previous post.

If it gets down to it, player A can win if they can force player B ( Of course presuming a perfect game is played ) to allow them to take stones when there are only 4, 5, 7, or 8 stones left.
 
  • #11
Hey everybody, enough with the hints and partial solutions. Let's wait for the OP to make some progress.
 
  • #12
LCKurtz said:
The number of stones is irrelevant. There is a winning strategy. Period.
Not always. It depends on the starting state.
Well, there is always a winning strategy in such games, but whether it's the first or second player that has it available depends on the starting state. The set of positions can be partitioned into two sets. In one set, every legal move leads to a position in the other set; the player having to play from such a position should lose. In the other set, there exists at least one move which leads to a position in the first set; that move is the winning line.
Viewed this way, it becomes a problem of control. You can often invert the criterion for a win (e.g. in Nim, whether the player to take the last stone wins or loses) without changing the essential strategy. Only a few positions in the endgame switch set.
 
  • #13
LCKurtz said:
Didn't the OP already observe that?
Yes, he did. I just didn't read all of the post! It looks to me like the first player can win if he moves so as to always leave an odd number of stones. Until the last move: if there are 1 or 2 stones left take them all, of course.
 
  • #14
HallsofIvy said:
Yes, he did. I just didn't read all of the post! It looks to me like the first player can win if he moves so as to always leave an odd number of stones.
That is not a winning strategy. Consider N=7. You have just given your opponent a winning state if you take away two stones. This is not too much of a hint because we already know that N=5 is a state that has winning strategy.
LCKurtz said:
Hey everybody, enough with the hints and partial solutions. Let's wait for the OP to make some progress.
Hear, hear. There is a generic solution to the problem. Everyone, please give the OP time to find it.
 
  • #15
Thank you all for your help. I think I got the solution after trying with n= 4, 6, 7, 8, 9 and 10.

When n=4 A takes 1, they remain 3 so B loses. A's winning strategy is 1 stone in his first turn.

When n=6 then A doesn't have any WS whether he takes 1 or 2 stones. If he takes 1 there are 5 left, so B wins. If he takes 2 there are 4, so B takes 1 and wins the game, since A only can take up to 2, but in any case B is the winner.

When n=7 then A does have a WS if he starts taking 1, so B must deal with n=6 which is the previous case.

When n=8 then A has a WS. He takes 2 and n=6. Same case.

When n=9 A doesn't have any WS. Regardless how many he takes in the first turn he cannot win (n=8 or n=7).

When n=10 A has a WN taking 1.

I think that the key is that A has a WS if the number of stones left that he has to confront isn't multiple of 3. If n=1000 A has to take 1 in his first movement, and then he has to follow the idea of multiple. Is it correct?.

Thanks in advance.
 
  • #16
Ikastun said:
I think that the key is that A has a WS if the number of stones left that he has to confront isn't multiple of 3. If n=1000 A has to take 1 in his first movement, and then he has to follow the idea of multiple. Is it correct?.
Correct. This is a trinary (base 3) rather than binary (base 2) problem.
 
  • #17
D H said:
Correct. This is a trinary (base 3) rather than binary (base 2) problem.
Well, it's not a ternary solution in the sense of standard Nim's binary solution. It is, as Ikastun says, just a modulo 3 criterion, which is simpler.
To relate this to my earlier post, since each player has to take 1 or 2 stones, the second player in a pair of turns can always arrange that the total of the two turns is 3 (provided there were at least 3 left). Thus the value mod 3 becomes a relevant property. If the objective is to take the last stone then leaving a multiple of 3 wins; if the objective is to leave the last stone then leaving 1 mod 3 wins.
We can make it a bit more like standard Nim by introducing multiple piles. You can take 1 or 2 stones, but only from one pile. I would guess a ternary solution analogous to that of standard Nim might apply.
 

What is game theory?

Game theory is a branch of mathematics that studies how individuals or groups make decisions in competitive situations. It involves analyzing the strategies and outcomes of different games and identifying optimal decision-making strategies.

What is Nim?

Nim is a two-player mathematical game that involves removing objects (such as stones or sticks) from a pile. The player who takes the last object from the pile wins the game.

What is the winning strategy for Nim with 5 stones?

The winning strategy for Nim with 5 stones is to always take 1 stone on your turn. This will force your opponent to take the remaining 4 stones, leaving you with the last stone and winning the game.

What is the winning strategy for Nim with 1000 stones?

The winning strategy for Nim with 1000 stones is more complex and involves creating a "safe" pile of stones that cannot be taken by your opponent. This can be done by dividing the pile into smaller piles with a specific number of stones in each pile. For example, you can divide the pile into piles of 4, 2, and 1 stones. By following this strategy, you can ensure that you always have a safe pile to take from, leading to a win.

How does game theory apply to real-life situations?

Game theory has applications in various fields, including economics, political science, and biology. It can help us understand and predict decision-making in competitive situations, such as pricing strategies in business, negotiations between countries, and evolutionary behaviors in animals. By studying game theory, we can make more informed decisions and strategize for optimal outcomes.

Similar threads

  • Set Theory, Logic, Probability, Statistics
Replies
7
Views
1K
  • Calculus and Beyond Homework Help
Replies
29
Views
1K
  • Calculus and Beyond Homework Help
Replies
2
Views
3K
  • Calculus and Beyond Homework Help
Replies
12
Views
2K
Replies
1
Views
1K
  • General Math
Replies
1
Views
7K
  • Quantum Interpretations and Foundations
Replies
2
Views
786
Replies
9
Views
2K
  • Calculus and Beyond Homework Help
Replies
12
Views
1K
  • Calculus and Beyond Homework Help
Replies
9
Views
1K
Back
Top