CSC 551: Web Programming
Spring 2004

JavaScript Project


For your class project, you are to write an interactive Web page that allows the user to play the Skip-3 solitaire game discussed in class. In Skip-3, cards are dealt one at a time from a standard deck and placed in a single row. If the rank or suit of a card matches the rank or suit either 1 or 3 cards to its left, then that card (and any cards in the pile beneath it) can be moved on top of the matching card. For example, suppose the three of clubs, five of diamonds, nine of clubs, and jack of hearts are initially dealt. They would be placed in a row, in left-to-right order, as shown below.

3C 5D 9C JH

If the next card dealt is the three of hearts, then that card is placed to the right and is found to match the jack of hearts immediately to its left. Thus, the three of hearts can be moved on top of the jack of hearts, shortening the row of cards. The consolidation of these piles then allows the three of hearts to match with the three of clubs that is 3 cards to the left. Thus, the pile topped by the three of hearts can be moved on top of the three of clubs, shortening the row even further. Pictorially, the consolidation steps are:

3C 5D 9C JH 3H 3C 5D 9C 3H <-- after first consolidation 3H 5D 9C <-- after second consolidation

Here is another example:

5H 7C JH TD JC 5H JC JH TD <-- after first consolidation 5H JH TD <-- after second consolidation JH TD <-- after third consolidation

Note that the addition of a single card can enable several consolidation steps. In fact, a single consolidation can start a chain reaction in which many piles of cards, both to the left and right, are consolidated. The goal of the game is to end with as few piles of cards as possible. Theoretically, the game could end with a single pile of 52 cards, although that outcome is extremely unlikely.

Your page must provide a reasonable interface to allow a user to play this solitaire game. The page should start with a randomly shuffled deck, and allow for cards to be dealt in a line (either automatically or at the direction of the player). The player should be able to specify moves that result in piles being moved on top of each other. Illegal moves should be caught by the page, such as moving too many spots or onto a non-matching card, and new cards should only be dealt if there are no moves that can be performed. To make the page user-friendly, it should provide help facilities that describe the rules and give instructions on how to interact with the page. At the end of a game, the user should have the option of playing again (without having to reload the page). Part of the grade for the project will be based on the elegance of the page design and its overall usability.


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 lead 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: Design, due 3/23 (25 pts.)
At this point, you must turn in an on-paper design for your page. You should draw a picture of your page, with comments to describe the interface and the behavior of each of the page elements. You do not need to provide implementation details -- simply describe the behavior of each page element and the interactions that must occur with the user as a game is played. Note that your page will need to display a line of card piles that can grow and shrink in length, and should do a reasonable job of displaying the cards even when the line grows long.

Part 2: Prototype, due 4/15 (75 pts.)
At this point, you must have a working prototype. That is, the game must start with a shuffled deck of cards, deal cards at the end of the line, make moves as specified by the player, recognize when the game is over, and allow the user to play again. However, the prototype need not be robust at this point: you may assume that only legal moves are made by the player. Public-domain card images can be found in www.creighton.edu/~davereed/csc551/Images/Cards.

Part 3: Final Version, due 4/29 (100 pts.)
At this point, the page must fully implement the game. It must meet the requirements listed above, and all illegal moves should be caught and handled by the page. In addition, help facilities should be provided, and a best score feature should be added. When the player begins her first game, she should be prompted for her name. The best score (fewest number of piles at the end) should be stored in a cookie and updated for that player after each game.

For EXTRA CREDIT, you may add additional features to your page. For example, you might allow the player to undo a move, or to receive a hint if they don't see any move to make.