Víctor A. Hernández Castro (801-15-3500) CCOM4029 - High Level Languages
This project is an interactive version of the Rummy card game. Provided some basic UI code and some random files, the student should construct the game from scratch and structure it using his/her knowledge on Design Patterns and Java programming.
See repository here.
The only references used to construct this project were:
I didn't receive any help from other people nor third parties.
I didn't help anyone else in the group, as of the time of writing.
- Clone this repository
cd
into this repository- Compile the source files with
javac rummy/Main.java
andjavac rummy/core/Game.java
- To run:
- if you want to play against the computer, use
java rummy.Main
- if you want the computer to play against itself, use
java rummy.core.Game
- if you want to play against the computer, use
As a player, the only interactions allowed are to click on any of the four provided buttons or to select cards in the hand (displayed as a sorted list):
- Draw from Deck - draws from the Deck (if it's not empty)
- Draw from Stack - draws from the Stack (if it's not empty)
- Lay on Table - lays the selected cards on the table (if they form a Set) or lays the selected card (if it fits on a Set already on the table)
- Discard - puts away the selected card in the Stack and terminates the player's turn
- Changing the text on all the buttons to more reasonable call-to-action text
- Changing the image displayed in the Deck (the cards' back)
- Disabling the other player's buttons when it's not their turn
- Disabling the "Draw from Deck" button when the Deck is empty
- Disabling the "Draw from Stack" button when the Stack is empty
- Disabling the "Draw from Deck" button when player has already drawn a card
- Disabling the "Draw from Stack" button when player has already drawn a card
- Disabling the "Lay on Table" button when player still hasn't drawn a card
- Disabling the "Discard" button when player still hasn't drawn a card
- Automatically closing the window when the game is over
- Terminating the program when closing the
JFrame
's window
- Each player is dealt 9 cards from the stock pile (i.e. Deck)
- The next card from the Deck is turned face-up and placed in the discard pile (i.e. Stack).
- In each turn, a player:
- Draws from the Deck or Stack
- Does some optional actions:
- Lay a Set on the table
- Lay a Run on the table
- Lay cards that fit in Sets or Runs already on the table
- Discards to the Stack
- (
Though, if a player is able to lay all remaining cards on the table at the end of a turn, the discard is optional)?
- (
- The game is over when either:
- One player is out of cards
- In which case, said player is crowned winner
- The cards from the stock pile are exhausted
- If the cards from the Deck are exhausted, all players count the points remaining in their hands, and the lowest value hand wins (ties are possible!)
- One player is out of cards
- Aces are worth 1 point
- Face cards are worth 10 points
- All other cards are worth their face value (i.e. Seven of Spades is worth 7 points)
- Write a stack class, named
MyStack
, which:- has a
push()
method - has a
pop()
method - has a
top()
peek()
method - has an
isEmpty()
method - should be implemented from scratch
- should use generics
- can't have a superclass that isn't a primitive type
-
can't have any data elements that aren't of primitive type
- has a
- Write the
Hand
class, which:- implements the
HandInterface
provided - may derive from other Java classes, like those in the
Collection
framework - should maintain the cards in sorted order
-
should provide aplay()
function to implement a Computer Opponent
- implements the
- Write the
Deck
class, which:- implements the
DeckInterface
provided - may derive from other Java classes, like those in the
Collection
framework - should provide a constructor which creates a 52-card deck of shuffled cards
- implements the
- Write the
Pile
Stack
? class, which:- implements the
PileInterface
StackInterface
?provided -
Pile
Stack
? should derive from yourMyStack
class
- implements the
-
You may NOT change the provided interfaces (but you can add methods to the classes themselves) - By default, the provided code can be run directly from the
Table.java
file, whosemain
method should be extracted into a separate file calledProj2.java
Main.java
- You should wrap the whole project in a package named
proj2
rummy
- The last line should be either
Player 1 Wins!
,Player 2 Wins!
orIt's a tie!
- The Computer Opponent AI can make random choices (like decide whether to draw from the stock pile or the discard pile), but it must at the very least
look for Sets in the handdraw and discard each turn...- if you implement it so that it can look for Sets, you will receive EXTRA CREDIT
- if you implement it so that it can look for Runs, you will receive EXTRA CREDIT
- if you implement it so that it makes other smarter play routines, you will receive EXTRA CREDIT
- The project is in
Java 13 SEJava 16 SE - To create the file containing your logs, use the command
java rummy.Main > output.txt
(after compiling, of course) - You will be provided with some code for the UI, the interactive game controls and the
Card
class, along with itsCardInterface
- The program
takes two kinds of command line arguments (which is already processed in the provided code):the-h
flag enables logging of actions (the default is no logging)the-0
,-1
, and-2
flags indicate the number of interactive players in the game (the default is-0
, indicating both players are automated)
Each one of the points in the specifications are worth 10 points for a total of 90 points; the final 10 points are for collaboration and adhering to coding standards, based on the comments of your team members and a rubric from the department
- By the intermediate deadline, you should turn in a description of the classes you intend to create, along with the specification of their attributes and methods. You may change these choices later, but you must submit the initial design regardless.
- This project is an OPEN assignment (i.e. write your own code, and you're allowed to help others as long as you complete it by yourself)
- You can't copy anyone else's code, have someone else write your code for you nor submit someone else's code as your own
- Any help you receive must be documented, including discussion with other people, books, papers, and web resources (all documented in the
README.md
file):- if you received no help, say so
- if you helped someone else, say so
- The card display in the UI is minimalist. There are card images available in the folder
lscards
cards
; use them to spruce up the appearance of your game (+5pts) - Modify the
Table
so that the game begins with the first card being on the Stack (+5pts) - The base project only requires Sets to be discovered and laid on the table. Extend the program to include Runs using an interface named
RunInterface.java
and its classRun.java
(+5pts) -
If you created theRunInterface
, make itSetInterface
's super interface to deal with both the sets and the runs (+5pts) -
Add some heuristics to improve performance in automated play (discussing each rule you add and why you expect it to improve performance in yourREADME.md
file) (+2pts per rule added, for a max of 4 rules) - The implement an additional flag when running the program indicating the number of interactive players in the game (i.e.
-0
,-1
or-2
), where the default is 2 interactive players (+10pts) - Write a two-page paper briefly summarizing the research challenges of intelligent game play and discussing how AI research might be used to iprove your Rummy program. Your paper should be gramatically correct, include appropriate bibliographic references, and be submitted in
pdf
format (+10pts)
*.java
files (includingProj2.java
Main.java
andCard.java
)output.txt
README.md
(including instructions for how to run and interact your GUI)- Any items required for extra credit options