The Seventeen Game

"Seventeen" is a simple mathematical strategy game, where two players take turns removing marbles from a jar, and the player who removes the last marble loses the game.

The jar begins with seventeen marbles, and each player can remove one, two, or three marbles during each turn.

Version 1. Interactive Mode

The program should allow a human to play against a computer. The human always goes first. If the human enters incorrect input (anything other than 1, 2, 3, or a number larger than the number of marbles remaining in the jar), an error message should be displayed, and the human is prompted to try again.

The computer player can choose to remove marbles according to any strategy of your choosing. Some examples include: (i) always choose the same number as the human player, (ii) choose randomly. Note that it is possible, though not required for this assignment, to devise a straightforward strategy for the computer such that it will never lose, as long as the human player goes first.

At the end of each turn, the program should print out the number of marbles removed in the previous turn, and the number of marbles that remain in the jar. Once there are no more marbles in the jar, the program should declare the winner of the game.

You should save and submit a sample output of the game as a text file named 'i206_placein_output1_.txt', where is your ischool user id. See below for a sample output for the game.

Sample Output for Version 1

% python i206_placein_source1.py

Let's play the game of Seventeen!
Number of marbles left in jar: 17

Your turn: How many marbles will you remove (1-3)? 3
You removed 3 marbles.
Number of marbles left in jar: 14

Computer's turn...
Computer removed 1 marbles.
Number of marbles left in jar: 13

Your turn: How many marbles will you remove (1-3)? 2
You removed 2 marbles.
Number of marbles left in jar: 11

Computer's turn...
Computer removed 2 marbles.
Number of marbles left in jar: 9

Your turn: How many marbles will you remove (1-3)? 2
You removed 2 marbles.
Number of marbles left in jar: 7

Computer's turn...
Computer removed 2 marbles.
Number of marbles left in jar: 5

Your turn: How many marbles will you remove (1-3)? 4
Sorry, that is not a valid option. Try again!
Number of marbles left in jar: 5

Your turn: How many marbles will you remove (1-3)? 1
You removed 1 marbles.
Number of marbles left in jar: 4

Computer's turn...
Computer removed 3 marbles.
Number of marbles left in jar: 1

Your turn: How many marbles will you remove (1-3)? 0
Sorry, that is not a valid option. Try again!
Number of marbles left in jar: 1

Your turn: How many marbles will you remove (1-3)? 1
You removed 1 marbles.

There are no marbles left. Computer wins!