Project 4

Due: Wed, Oct 30, 8 AM
Submit Projects: proj4 
Required Files: proj4.jar (*.java */*.java)  
Support Files: WMSolitaire.java
Game No: 876 

The demo of Easthaven went well. Your task is to now deliver a GUI version of Freecell using Model-View-Controller (MVC). This is a production version! In developing Freecell, you must not break Easthaven. Your final submission is to include both games.

This project should split the code base into the following packages (use Refactoring menu):

  1. default package -- WMSolitaire
  2. solitaire -- holds only the model (game) code: Game, Easthaven (!), and Freecell.
  3. gamelib -- the rest of the model classes: Card, Pile and its subclasses, Deck, etc.
  4. gui -- holds all the GUI classes, except the main program: Controller, GuiPile, ... .
  5. tests -- holds all the JUnit test classes. See below for test coverage.


Usage

The game is invoked from the command line using:

java  WMSolitaire
where WMSolitaire will propmt you for a game and an optional seed (game number).


Package Tests

  1. Packages gamelib includes the following classes: Pile and all its subclasses.
  2. For the classes X cited in item 1 above, there must be a JUnit XTest.java that achieves 100% code coverage.
  3. In addition you are to provide a TestSuite class in package tests named AllTests which will run the TestCase classes.
    1. Right click on package tests.
    2. Select New -> Other -> Java -> JUnit -> TestSuite
    3. Be sure to check Generate Main.

NB: Before submitting, right-click on AllTests.java, select regenerate. Be sure to run AllTests to ensure that your unit tests still work.


Freecell

The game requires a standard deck of 52 unique cards. Both suits and ranks are important. Ace is low only.

You must deal the cards so that you get the same deals I do, although you may modify your Deck.java however otherwise you want. Here is a deal of the cards with the top tableau card on the left.

There are three groups of piles. The cards in all piles are face-up. These piles are:

A game begins with all cards being dealt randomly to the 8 tableau piles from left to right, bottom to top. The leftmost 4 tableau piles should have 7 cards; the rightmost 4 piles should have 6 cards.

The objective of the game is to move all the cards from the tableau piles to the homecell piles, using the freecell piles as scratch space.

Game Rules

Moving a card from one pile to another is viewed as a single, atomic action. However, for the purposes of stating the rules, it is viewed as taking a card from pile A, subject to the taking rule for A, and putting the card onto pile B, subject to the putting rule for B. Note that in the game of Freecell, piles behave like stacks, so taking is a pop and putting is a push.

The game terminates when either all cards have been successfully moved to the homecell piles (a win) or the player quits (a loss).

Super Moves

You are required to implement super moves, which are just group moves with a maximum number restriction. A Freecell super move uses the empty tableau columns and freecellsto ensure that you can move the maximum number of cards possible. To determine how many cards can be moved the following formula is used:

(1 + number of empty freecells) * 2 ^ (number of empty tableau piles)
where the ^ represents exponentiation.


Robert Noonan
Oct 15, 2009