The Skunk Game


Due Dates:(UPDATED 11/9/98)

Notes on the assignment

Since everyone in the class is creating the same program, each student must take reasonable steps to make sure there assignment is not copied. Recall that academic dishonesty includes supplying information as well as receiving information. Towards this end, you are not to have your assignment readable in any directory of your account until the day after the last due date for the assignment. Any student who does not follow this will receive a grade of zero for the assignment.

In order to work on this assignment, you are to use the "Open File" option in the Netscape browser to view and run your assignment. Remember that this will only open a file on the physical machine that you are working with. If you are running Netscape on one of the EECS machines, you can open any file in your account (not only the ones in your WWW directory). If you are not running Netscape on one of the EECS machines, you will have to transfer the file to the machine your are working on before you can open the file in Netscape. To transfer the file, use either FTP or Fetch.

Another note on academic dishonesty, you should never show your written code for an assignment to another student. You may discuss ideas related to the project, but code must be entirely written on your own. If you and another student must discuss code, you must discuss an example other than the assignment.

The Assignment

You are to write a JavaScript program that will allow a person to play the game of "Skunk" against three computer players. Skunk is a dice game that uses two 6 sided dice. You program will have to use the random() function in JavaScript to simulate the dice rolls.

The goal of the game is to roll the dice for points and the first person who gets 100 points wins. The player determines how many times they wish to roll the dice during their turn provided they don't get "skunked". Once a player gets skunked, their turn is over and may lose some or all of their points as a result.

There are two ways to get skunked:

  1. One of the two dice can roll a one. This is a "single skunk". In this case the person loses all points that were earned during this turn.
  2. Both dice roll a one. This is a "double skunk". In this case the person loses all of their points and return to zero points.

The player can end their turn at any time after they have made at least one roll. A roll consists of rolling both dice. If a "one" does not appear, the value on both dice are added to the players score. Let us look at some examples turns to better understand the game.

Assume player 1 currently has 27 points. The following table will show how the player's turn went:
CommentsDice RollScore
Start of turn27
Roll 13434
Roll 25443
Roll 32247
Roll 46356
End of turn56
Player 1 ends their turn with a score of 56.

Assume player 2 currently has 52 points. The following table will show how the player's turn went:
CommentsDice RollScore
Start of turn52
Roll 12559
Roll 261Single Skunk
End of turn52
Player 2 ends their turn with a score of 52. They lost all points earned this turn because of the single skunk.

Assume player 3 currently has 70 points. The following table will show how the player's turn went:
CommentsDice RollScore
Start of turn70
Roll 15479
Roll 22384
Roll 311Double Skunk
End turn0
Player 3 ends their turn with a score of 0, because of the double skunk.

Your program must have three computer players to play against.

Your program must show the points of each of the computer players. It must also describe what happened during their last turn(perhaps the best way is to display an alert box after each computer player's turn that summarizes what occurred).

The user player always goes first. When their turn is over the three computer players get turns (one turn per computer player). When a player wins, there must be a message displayed stating who the winner of the game was. One way to do this is by alert box.

Your program must have a "New Game" button. When clicking on this button, all players return to zero points and the game starts with the user player taking their turn. Your program must also have a "Quit" button. When clicking on this button, the previous web page it redisplayed (this is nothing but a "back" button"). Your program must have three additional HTML pages that provide supporting information.

Make sure your code is written using good programming style. This includes the use of comments, indentation, blank lines and meaningful identifier names. Each function that you write must have comments at the start explaining the purpose of the function. Also, at the top of your HTML file must have a comment explaining the purpose of the file including your name, and lab section day and time.

As always, late assignments will not be accepted.

You must electronically submit your assignment using the UNIX command turnin. Note that since this assignment does not have to be in your WWW directory, you will be graded based on what is turned in. If you do not turn in your assignment correctly, your grade will suffer. To electronically hand in your assignment using the UNIX turnin type one of the following commands depending on which lecture your are registered, where FILELIST is the names of all of the files you are submitting.

 i101@eecs.uic.edu
 Department of Electrical Engineering and Computer Science
 University of Illinois at Chicago