Karen Her, email@example.com
Kristen Gee, firstname.lastname@example.org
University of Pennsylvania
You will be recreating the game of 'Racko,' which is a game that involves rearranging
your hand of cards in order to have an increasing sequence. Each card just has a number.
We will be making a user versus computer version of the game. The user's moves are decided by the user's input, while the computer's moves will be decided by you. You will be using a combination of linked lists and arrays for doing this assignment.
To make this interactive and fun, we have written a user interface. We also have the computer play using a relatively medium level strategy. When your assignment is completely done, you should be able to actually play the game.
The final interface looks like
The user (the student) can click to choose a card from either the discard pile or the deck and then click to choose the card in their hand that they want to replace.
There are 2 versions of this assignment.
- A Python version - no UI, focus on creating the game and programming a computer strategy. Suitable for CS1
- A Java version - UI provided, computer strategy provided. Requires usage of classes to complete the assignment. Suitable for CS2
Rules of Racko
Racko is a game whose primary component is a deck of cards numbered 1 through 60.
The order in which the game is played out is as follows
- To start the game, shuffle the deck, both the user and the computer pick a card from the deck. Let the computer pick first. The person who gets to play first is the person who has the higher number.
- The cards then get shuffled again and both the user and the computer gets dealt 10 cards. As a player receives each card, they must place it in the highest available slot in his rack, starting at slot 10, without rearranging any of them. The goal of each game is to create a sequence of numbers in ascending order, starting at slot 1.
- The top card of the deck is turned over to start the discard pile. A player takes a turn by taking the top card from either the deck or the discard pile, then discarding one from their rack and inserting the new card in its place. If the player draws a card from the deck, they may immediately discard it; if they takes the top discard, though, they must put it into their rack.
- The first player to get their 10 cards in ascending order wins the game.
The Python version of the above assignment has no graphical user interface. The emphasis in the Python version is to learn how to manipulate lists. Also, in order to write a strategy, students have to learn to think computationally; their strategy has to broken down into some sequence of list operations.
for an example handout (in pdf)
handout as a word doc.
- Download this zip file to get the template code that we want you to complete.
The only file that you will need to edit is Racko.java.
The file that contains the main function that needs to be run is RackoGame.java.
Racko.java has the complete structure of the program that will allow you to play a game of Racko against the computer. Your goal is to fill in the methods that are currently completely empty.
These areas of the code can be easily found by searching for the words 'fill this'.
You do not have to change any of the code that is already supplied to you.
If you are working on the extra credit part of the assignment, you will be required to change the computer strategy. In this case, you have to write your own version of the computer's move method.
list of functions to get a word document that describes each of the functions that you need to fill.
We do provide a significant amount of code that makes the user interface for you. You are not required to change that code.
Build a version of the simple card game Racko. Create the ability to play against the computer.
|A neat application of linked list and arrays to simulate a card game.
Helps students understand the concept of abstraction by thinking of a deck of cards as simply an ordered collection of numbers.
|The Python version is appropriate for CS1. It involves lots of list manipulation. The Java version relies on the ability to use a pre defined class and is more of a CS2 assignment.
|This is an intermediate assignment and generally students are given 1 week to 10 days to do it.
|The biggest strength of the assignment is that it shows an application of two data structures to produce a game that the students can play against the computer. If the students do the version which requires them to come with their own strategy for the computer's move, it shows them how concepts seen in courses like discrete math/probability can be used in their programming assignments.
|The version that requires the student to come up with computer strategy has the usual weakness of strategies being tough to evaluate. Also students always want to know if their strategy is good enough. The version where the computer strategy is already provided suffers from the weakness of the inquisitive student spending too much time trying to understand exactly what the provided code does.
|If done in Java, the assignment uses both Linked Lists and Arrays. If the Python version is used, the assignment only needs understanding of lists.
|The assignment can be done using either Python or Java. Students can also build their own user interface if they have seen Swing (or any other graphics toolkit).