Project P4 for CS1050: Jeu de Nim. Individual submission. Due Feb 21

Write a program that will play (and try to win) the game of Nim with 3 piles.

The rules: Your software selects 3 random numbers, each between 3 and 15. They represent the number of stones in each one of the 3 piles. The players (user and program) take turns. Match involves two games (both with the same randomly chosen starting numbers of stones in the piles). The user starts the first game. The computer starts the second. At each turn, the player (user or computer) must remove one or more stones from a single pile. (The player may chose which pile and how many stones to remove). Whoever takes the last stone wins.

Produce a web page with an applet where the user can play the game against the computer by using mouse clicks. It should contain a link to your sourcre code.

Produce a PPP for this project with a link to the applet and an explanation of the scheme S1 below, with your proof that is is (or is not) a winning scheme.

Develop a GUI:
Make a window of 3x15 square cells. Each row represents a pile. Its stones are represented by filled disks, one per square, packed from the left.
After each move, the program should show the remaining number of stones (disks).
The user should be able to click on a square. If the square is empty, nothing happens.
If the square contains a disk, then that disk (stone) and the ones to its right will be removed from the row (pile).
Just after the user has played, the program should execute the user's move, wait for about a second, then do its own move.

Develop a first scheme S1:
Implement the following strategy for your program's move. The objective is that after the move, if possible, one of the longest piles has the same number of stones as the other two combined. For example, if wo piles are equal, you may remove the third one completely, leaving two equal piles. If you start with (5,3,1), reduce the 5 by emoving 1 to 3+1=4 hence leaving the piles (4,3,1).

Is this a winning scheme?
A scheme S is the logic for playing the game. S is a winning scheme if it ensures victory of at least one of the two games of a match.
Conclude whether the S1 scheme proposed is a winning scheme. Prove your conclusion (by a formal proof or by listing the starting conditions and steps of two games of the same match both lost by the computrer).