Assignment 2

Due Tuesday, February 4

How to play Candy Trail

Three rows of candy are placed on the table, five candies in each row:
   row 1          *   *   *   *   *
   row 2          *   *   *   *   *
   row 3          *   *   *   *   *
 
For a turn a player may remove as many candies as she likes from any one row, but she must remove at least one candy.
The object of the game is to take the last candy.

Sample Game:
   row 1          *   *   *   *   *
   row 2          *   *   *   *   *
   row 3          *   *   *   *   *

Player 1 removes 2 candies from row 1
   row 1          *   *   *
   row 2          *   *   *   *   *
   row 3          *   *   *   *   *



Player 2 remove 3 candies from row 3
   row 1          *   *   *
   row 2          *   *   *   *   *
   row 3          *   *

Player 1 remove 3 candies from row 1
   row 1
   row 2          *   *   *   *   *
   row 3          *   *

 Player 2 remove 4 candies from row 2
   row 1
   row 2          *
   row 3          *   *




 Player 1 remove 1 candy from row 2
   row 1
   row 2
   row 3          *   *

 Player 2 remove 2 candies from row 3
   row 1
   row 2
   row 3
and wins !!!

Your job is to write a program that has the computer play Candy Trail with a human.  Start out by playing the game several times with friends.  Provide a nice display and a clear user interface.  This is an exercise in breaking a large task into smaller ones - writing functions.  Think about what information a particular function needs from main, and what information should be changed as a result of the function.  One function may call another function.


Some possible functions to build:
A function that draws the Candy Trail with the current number of candies in each row.
A function that serves as a dialogue, asking the user about his/her turn.
A function for that computes the computer's turn.  This may call other functions.
A function to perform the set up functions, describing the game, deciding who goes first.

Of course you may use other functions either in addition to or instead of these.