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.
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:
Here is another example:
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.