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):
- default package -- WMSolitaire
- solitaire -- holds only the model (game) code: Game,
Easthaven (!), and Freecell.
-
gamelib -- the rest of the model classes:
Card, Pile and its subclasses, Deck, etc.
- gui -- holds all the GUI classes, except the main program:
Controller, GuiPile, ... .
- 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
- Packages
gamelib includes the following
classes: Pile and all its subclasses.
- For the classes X cited in item 1 above,
there must be a JUnit XTest.java
that achieves 100% code coverage.
- In addition you are to provide a TestSuite class
in package
tests named AllTests
which will run the TestCase classes.
- Right click on package
tests.
- Select New -> Other -> Java -> JUnit -> TestSuite
- 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:
- 8 tableau piles: all cards are partially visible.
- 4 freecell piles: hold at most 1 card each.
Initially empty.
- 4 homecell piles: holds cards of a given suit in order by
rank from lowest to highest.
Initially empty.
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.
- Freecell pile rules:
- A freecell pile holds at most 1 card.
- Putting Rule: Any card can be put onto an empty pile.
- Taking Rule: Any card can be taken from the top of
a freecell pile.
- Homecell pile rules:
- A homecell pile behaves like a stack without a pop operation.
It can only hold cards of the same suit in increasing order
by rank (from bottom to top). Only the top card
need be visible.
- Putting Rule:
- Only an Ace can be put
onto an empty homecell pile. The suit of the Ace
determines the suit of the homecell pile.
It is permissible to order the piles: clubs, diamonds, hearts, spades.
- A card can be put onto a nonempty
homecell pile provided the card is the same suit
and the next higher rank than the
top card of the homecell pile.
- Taking Rule: A card cannot be taken from a homecell pile.
- Tableau pile rules:
- A tableau pile behaves like a stack, except that all cards are
visible.
- Taking Rule: A card may be taken only from the top of a
tableau pile.
- Putting Rule:
- Any card may be put onto an empty tableau pile.
- A card may be put onto the top of a
nonempty tableau pile
provided the card is the
next lower rank and opposite coloor than the current top
of the target tableau pile.
Suit is irrelevant.
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