Project 2 - A Slot Machine

Due - Friday, March 2, 2007

The goal of this project is to give you experience using iteration and lists. You will write a slot machine program similar to what you might find in Las Vegas. There are lots of websites that allow you to play similar games online. You are encouraged to visit those sites to get a feel for how such a program should work.

This project is divided into three parts. You will complete the parts in order. For each part, I have specified the percentage it will contribute to the final project grade. For example, part 1 is worth 75%. That means that if you only complete part 1, you are still eligible to receive a C on the project.

Part 1 - 75%

For part 1, you will implement a main control loop that will execute until the user decides to stop playing the game. As long as the user wishes to continue, you will spin by selecting three random numbers in the range 0-9 and placing them in a list. You will display the list for the user and determine whether the user is a winner. For this portion of the project, a win occurs if the user has spun three of the same number. You will report a win or loss to the user and ask if she would like to spin again. You will also keep track of the total number of wins and losses and report each value to the user when she exits the program.

At minimum, you must implement the following functions:

Part 2 - 10%

For part 2, you will implement a simplified betting system. The user will start with 100 credits. For each loss, one credit is deducted. For each win, one credit is added. The play will stop if the user chooses not to spin again or if the user has gone bust (run out of credits).

Part 3 - 15%

For part 3, you will allow the user to bet 1, 2, or 3 credits for each spin. If a user does not spin three of the same number, she loses her bet. If she does spin three of the same number, she receives credit according to the following payout chart. For example, a user who bets 2 credits and spins 888 will receive a payout of 400 credits.
Spin1 credit2 credit3 credit
999300600900
888200400600
777100200300
66650100150
5554080120
444204060
333102030
22251015
111246
000123

Implementation Requirements and Hints

Due 1:30PM Friday March 2, 2007

  1. Complete and submit your working code. Turn in a hard copy in class and place a copy of your .py file in the submit directory /home/submit/cs110-s07/username.
  2. Make sure that each function is well documented. Your documentation should specify the type and function of the input parameters and output.
  3. Run your program on a variety of inputs ensuring that all error conditions are handled correctly.
Note: No portion of your code may be copied from any other source including another text book, a web page, or another student (current or former). You must provide citations for any sources you have used in designing and implementing your program.
Sami Rollins