Nim is a well-known game with a number of variants.
We will consider the following variant, which has an interesting
winning strategy.
- Two players alternately take marbles from a pile.
- In each move, a player chooses how many marbles to take, then
removes the marbles.
The player must take
- at least one but
- at most half
of the marbles.
Then the other player takes a turn.
The player who takes the last marble loses.
You will write a program in which a computer plays
agains a human opponent:
- Generate a random number between 10 and 100 to denote the
initial size of the pile.
- Then start the game.
In your game the computer should move first.
Computer moves should be legal, but random.