CSC 551: Web Programming
Spring 2001

JavaScript Project


For your class project, you are to write an interactive Web page that allows the user to play the game Mastermind (Copyright (c) 1981, Pressman Toy Corporation). Recall the rules of the game:

  1. The Mastermind (in this case, your program) selects four colored pegs out of a large collection, with six possible colors each.
  2. The player tries to guess the color and order of the Mastermind's pegs by proposing 4 pegs of their own.
  3. The player keeps guessing until they get the pegs correct (in which case they win) or until they have made eight incorrect guesses (in which case they lose).

Your page must provide a reasonable interface that allows the user to enter guesses, receive feedback, and peruse past guesses. When making a guess, the user should be able to tentatively select colors, changing their mind up until the point that they explicitly commit to a guess. All past guesses and the results of those guesses must be displayed at all times. If the user wins, the Mastermind's pegs should be revealed and the number of required guesses displayed. If the user is unable to guess correctly in eight guesses, a loss should be acknowledged and the Mastermind's pegs reveled. To assist the user, the rules of the game should be available for review.

You may work with a partner in developing this project. In fact, working as a team is encouraged, since discussions about design and debugging often leads to a more robust, user-friendly application. If you do work in a team, only one program need be submitted for the team. To allow plenty of time for collaboration and feedback from the instructor, this assignment will be spread over the rest of this semester.

Part 1 (Week 11)

At this point, you must have a working user interface for the game. The user must be able to select pegs and submit guesses, and the page should display some sort of feedback. However, you do not have to implement the logic of the game at this point. It would be sufficient for the page to simply indicate "?" for each of the feedback numbers. The option of viewing the rules of the game should be provided in this page as well.

Part 2 (Week 13)

At this point, you must have a working but not necessarily robust game. The program must randomly select its pegs and correctly respond to user guesses. It should recognize a win or a loss, and display the appropriate message in either case (as described above). The program does not need to check for illegal (i.e., out-of-order) entries by the user at this point.

Final Version (Week 14)

For the final version of the program, you are to disallow out-of-order guesses. That is, if the user attempts to enter a guess in a round other than the one currently being played, the move should be disallowed and a warning message displayed. Also, your program should add score-keeping capabilities using a cookie. The program should keep track of the number of wins and losses, and the fewest guesses required by a particular user/browser, and display these results after each game.

Reminder: You are expressly forbidden to look at anyone else's source code for a Mastermind program.