CMSC 202 Project 2
Assigned Monday February 25
Design Due 9:00AM Monday March 3
Program Due 9:00AM Monday March 10
Updates 27 Feb 2008 Step (f) of the shuffling algorithm has been changed from "Repeat from step (c) until N is less than 2" to "Repeat from step (c) until N is less than 1"
25 Feb 2008 See below
Weight 7%

Objectives


Project Description
As an employee of the F & M Game Company you have been assigned to the programming team which is responsible for designing and implementing an on-line version of "Monte Carlo Solitaire". Monte Carlo Solitaire is played with a standard deck of 52 playing cards (4 suits and 13 ranks). Initially 25 cards are laid out in 5 rows with 5 cards in each row. These cards are called the "tableau". The player removes pairs of touching cards (horizontally, vertically, or diagonally). When no more pairs can be removed, the tableau is "consolidated". The cards that remain in the tableau are moved left then up to fill in the spaces left by the cards which were removed. New cards are dealt from the deck to once again complete the 5 x 5 tableau or until there are no more cards. The player wins the game by removing all the cards from the tableau.

You can play a competitor's version of Monte Carlo Solitaire here. Our version of the game is of course far superior since it includes more functionality such as help and hints. Also note that the rules for our competitor's game are slightly different than ours. You can also see a screenshot of our GUI.

Game FAQ
  1. How is the game number chosen and how is it used?
    The game number is chosen by the GUI. The first game played is #12345. The game number is used to initialize the random number generator used to shuffle the cards.
  2. What does the "Hint" button do?
    When the "Hint" is pushed, a pair of cards that may be removed are highlighted (their borders turn red). If no pair of cards can be removed, a beep is sounded.
  3. What does the "Help" button do?
    The "Help" button displays a pop-up window that briefly explains the rules of the game.
  4. What does the "New Deal" button do?
    The "New Deal" button abandons the current game and starts a new game.
  5. What does the "Replay" button do?
    The "Replay" button restarts the current game from the beginning.
  6. How do I win the game?
    By removing all the cards from the tableau, hence earning a score of 52.
  7. What's the tableau?
    The cards which are face up in a rectangular arrangement (usually 5 x 5).
  8. How do I remove cards from the tableau?
    Clicking on a card highlights that card by changing its border to red. If the next card clicked is touching the first card and is of the same rank, the cards are removed. If the second card is not touching the first card or is not of the same rank, a beep is sounded. Suits are not relevant when choosing cards to remove.
  9. When are two cards touching?
    Two cards are touching if they are next to each other either horizontally, vertically, or diagonally. Cards at the top and bottom of a column, or the ends of a row, or the opposite corners of the a diagonal are NOT considered touching. I.e. the columns, rows, and diagonal do not wrap.
    Note that this is different than the competitor's implementation in some ways.
  10. What do I do when I can't remove any more cards?
    Push the "Consolidate" button. This button always moves all cards in the tableau left and up towards the top of the tableau. If there are any cards left in the deck then this button also deals cards from the deck to refill the bottom of the tableau.
  11. What if there aren't enough cards in the deck to fill the bottom of the tableau when I push the "Consolidate" button?.
    If there are too few cards in the deck to complete the tableau, the remaining cards are dealt to complete as much of the tableau as possible.
  12. How does my score change?
    One point is awarded for each card removed from the tableau.

Project Policy
This project is considered an OPEN project. Please review the open project policy on the course website.
Class Descriptions
Our application consists of many classes. Some of the classes have already been written by other team members. Some of the classes will be written by you. Some classes must support a specific API and still others may be designed and implemented as you see fit.
Project2 Class
Project2.java, which contains the GUI framework and the project's main, are being written by someone else. The GUI code in Project2.java calls methods from the Game class that you will design and implement. When complete, you will be given the Project2.java file and other GUI framework files on which it depends to complete your program. When available, copy Project2.java and all other .java files from Mr. Frey's public directory. To integrate these files into your projects, see the Importing Files into Eclipse resource page. Do not submit Project2.java.
Suit Class
Suit.java has been written and can be copied from Mr. Frey's public directory. This class defines Suit objects used to identify a card. For example, Suit.HEARTS is used to represent the suit hearts. This class is provided so that there is no possible discrepancy among all classes that refer to a card's suit. The four suits in a standard 52-card deck are Suit.HEARTS, Suit.SPADES, Suit.DIAMONDS, and Suit.CLUBS. Do not submit Suit.java. Documentation for Suit.java is provided in the file itself and in the Suit API document
Rank Class
Rank.java has been written and may be copied from Mr. Frey's public directory. This class defines Rank objects used to identify a card. For example, Rank.TWO is used to represent a card with a rank of two. This class is provided so that there is no possible discrepancy among all classes that refer to a card's rank. The ranks of the cards in a standard 52-card deck are Rank.ACE, Rank.TWO, Rank.THREE, ... Rank.JACK, Rank.QUEEN, and Rank.KING. Do not submit Rank.java. Documentation for Rank.java is provided in the file itself and in the Rank API document
Game Class
Game.java must be written by you. This class contains data and methods used by the Project2 class. A description of the Game class API is provided in Javadoc format. Your class must follow this API, or Project2.java will not compile.
Coordinates Class
Coordinates.java must be written by you. This class encapsulates the row and column coordinates of a card in the 5 x 5 tableau. This class is also used by Project2.java. A description of the Coordinates class API is provided in Javadoc format.
Other Classes
Design and implement any other class(es) that you feel is(are) necessary to complete a good object-oriented implementation of this project. Yes, there should be some other class(es).
Project Requirements and Specifications
  1. Mr. Frey's public directory for this project is /afs/umbc.edu/users/f/r/frey/pub/202/Proj2/.
  2. A directory named cards that contains card images to be used for this project can be found in Mr. Frey's public directory. Copy this directory into your Eclipse project so that the cards directory is at the same level as the src directory. The cards directory is also available in tar and zip formats.
  3. You must write main in the Coordinates class, the Game class, and any class you design and implement as a means of unit testing. As discussed in class, each main should instantiate an object and invoke all public methods defined for the class, printing the results to System.out.
  4. The screenshot of our GUI shows the tableau for game #12345. Your application should duplicate this tableau when the first game is played.
  5. The algorithm below which shuffles an array of integers must be adapted and implemented to shuffle the cards to start a new game of solitaire. This algorithm is known as the Fisher-Yates algorithm, was first designed for computers by Richard Durstenfeld, and popularized by Donald Knuth.
    1. A[0], A[1]... A[n-1] is an array of integers
    2. Let N = n-1
    3. Pick a random index, k, between 0 and N (inclusive).
    4. Swap the values of A[k] and A[N].
    5. Decrease N by one.
    6. Repeat from step (c) until N is less than 1.
    To choose a random index (step c), use the nextInt method of the Random class found in the Java library.
  6. Per the course standards, all class comments must contain the class invariant and all method comments must include pre- and post-conditions.
  7. Update 25 Feb 2008

  8. Please make all .java files part of "package proj2"
  9. In order to duplicate game #12345 as required above, it is necessary that the deck of cards be initialized appropriately before shuffling. Initialize the deck of cards in the order Ac, 2c, 3c, ..., Qc, Kc, Ad, 2d, ..., Qd, Kd, Ah, 2h, ..., Qh, Kh, As, 2s, ..., Qs, Ks.


Hints and Tips

Project Design Assignment
For this project design assignment, copy the file p2design.txt from Mr. Frey's public directory, then edit the file to answer the questions. Submit p2design.txt in the usual way: submit cs202 Proj2 p2design.txt Remember - the design is due before the project. See the design due date at the top of this page. Late designs will not be accepted.
Grading
See the course website for a description of how your project will be graded.
Project Submission
  1. submit Game.java, Coordinates.java and the .java files for any class(es) you design and implement. Be sure to submit p2design.txt by the design due date.
  2. DO NOT submit any .java files you copy from Mr. Frey's public directory. These files should not be changed by you and so need not be submitted. If you submit these files they will be removed from your submittal directory.
  3. submitls cs202 Proj2 to verify that your files are in your submittal directory
The order in which the files are submitted doesn't matter. You need not submit all files at the same time. You may resubmit your files as often as you like, but only the last submittal will be graded and will be used to determine if your project is late. For more information, see the projects page on the course website.

You can check to see what files you have submitted by typing

submitls cs202 Proj2 More complete documentation for submit and related commands can be found here.

Remember -- if you make any change to your program, no matter how insignificant it may seem, you should recompile and retest your program before submitting it. Even the smallest typo can cause compiler errors and a reduction in your grade.

Avoid unpleasant surprises!

Sorry! We could not find what you were looking for

Try going back to the main page here

 
4
4
0
0
0
0