Homework Assignments

Homework Points Assigned Due
1 30 9/2 9/13
2 30 9/14 9/27
3 40 9/28 10/11
V3.1 Restaurant Simulation (Team Project) 30 10/12 10/25
Factory Simulation Design 40 10/26 11/8
Factory Simulation Release 1 40 11/9 11/22
Factory Simulation Release 2 40 11/23 12/4

Assignment Late Policy

There is a 15% deduction for one day late submission; 30% deduction for 2 days late; 45% deduction for 3 days late. After 3 days, zero points are awarded for a late assignment submission.

Student Code of Conduct

The official USC code of student conduct clearly discusses what is acceptable and not acceptable for submission of homework. It also states the penalties associated with various violations.

I would like to make it clear, that it is NOT ACCEPTABLE to submit any code, FROM ANY SOURCE - whether a friend, or whether found online, as part of your own homework or lab submission. There is a code analysis tool that I've used for more than a year in CSCI 402 called MOSS. I won't run it after each homework, but I will be running it against all submitted code eventually. So, if you think you got away with something early in the semester, don't be fooled.

Since you have this significant warning, there will be NO EXCUSES ACCEPTED. If you are found cheating, you WILL receive an F for the course.

Design Document Template

Assignment Details

Homework 1 - Playing Blackjack

For this first assignment, you are to only have one player. You are playing against the 'House'. Here is how you win (or lose):

You are to let the user pick how many decks of cards are to be used in the game. They can select from 2, 4, or 6 decks of cards. You must generate the proper number (and type) of cards based on what the player selects. This only happens at the start of the game.

You are to ask a player how much money they wish to start with. This is to simulate buying chips.

You must establish limits for betting. Every game has limits. You might even allow the user to select this.

Values of the Cards

In blackjack, the cards are valued as follows:

The suits of the cards do not have any meaning in the game. The value of a hand is simply the sum of the point counts of each card in the hand. For example, a hand containing (5,7,9) has the value of 21. The Ace can be counted as either 1 or 11. You need not specify which value the Ace has. It's assumed to always have the value that makes the best hand. An example will illustrate: Suppose that you have the beginning hand (Ace, 6). This hand can be either 7 or 17. If you stop there, it will be 17. Let's assume that you draw another card to the hand and now have (Ace, 6, 3). Your total hand is now 20, counting the Ace as 11. Let's backtrack and assume that you had instead drawn a third card which was an 8. The hand is now (Ace, 6, 8) which totals 15. Notice that now the Ace must be counted as only 1 to avoid going over 21.

A hand that contains an Ace is called a "soft" total if the Ace can be counted as either 1 or 11 without the total going over 21. For example (Ace, 6) is a soft 17. The description stems from the fact that the player can always draw another card to a soft total with no danger of "busting" by going over 21. The hand (Ace,6,10) on the other hand is a "hard" 17, since now the Ace must be counted as only 1, again because counting it as 11 would make the hand go over 21.

Dealing

The player is dealt 2 cards AFTER they place a bet. Since this is a single-player game, you can consider both cards face up - meaning the player can see both cards.

The player then can continue to select one additional card at a time, until they decide to stop, or they get more than 21.

Player Choices when Playing

Surrender
We start with one of the least common decisions, but it is appropriate to begin with surrender, because this decision must be made before any other choice about playing your hand. Not every game offers surrender, and those that do fall into two categories which bear expanation: Early vs Late.

Surrender offers you as a player the choice to fold your hand, at the cost of half of the original bet. You must make that decision prior to taking any other action on the hand. For example, once you draw a third card, or split, or double down, surrender is no longer an option.

(This is not necessary for homework 1) The two varieties of surrender, early and late, differ only in the way a dealer blackjack is handled. In an early surrender game, a player may choose to surrender before the dealer checks his cards for a blackjack, offering a cheap way out even if the dealer turns out to have a blackjack. Because this offers a healthy advantage to the player, this version (early surrender) is rarely offered. The much more common variation is late surrender, where the dealer checks for blackjack first, and then only if he does not have blackjack will he allow players to surrender their hands.

Surrender is an excellent rule for players who use it wisely. Unfortunately, many players surrender far too many hands. If you play in a game with surrender, use our Blackjack Basic Strategy Engine to determine when surrender is the appropriate play. To understand how bad a hand must be to properly be surrendered, consider the following: To lose less with surrender, you must be only 25% likely to win the hand (ignoring pushes). That is, if you lose 75% of the time, and win only 25% of the time, your net loss is about 50% of your bets, equal to the amount you'll lose guaranteed by surrendering. So, learn to use the surrender option, but make sure you know when it is appropriate.

It's worth mentioning again that the vast majority of surrender is LATE surrender, after the dealer checks for BJ. Make sure you choose the right option over on the Strategy Engine. And if you do find a game that offers early surrender, drop me a note. Good opportunities like that are rare.

Hitting/Standing
The most common decision a player must make during the game is whether to draw another card to the hand ("hit"), or stop at the current total ("stand"). The method you use to indicate your decisions to the dealer depend on which kind of game you are playing.

If you "hit" and go over 21, or "bust", the dealer will collect your bet, and remove your cards from the table immediately.

Doubling Down
Among the more profitable player options available is the choice to "double down". This can only be done with a two card hand, before another card has been drawn. Doubling down allows you to double your bet and receive one, and only one, additional card to the hand. A good example of a doubling opportunity is when you hold a total of 11, say a (6,5) against a dealer's upcard of 5. In this case, you have a good chance of winning the hand by drawing one additional card, so you might as well increase your bet in this advantageous situation. If you are playing in a face-down game, just toss the two cards face-up on the table in front of your bet. In either type of game, add an additional bet to the betting circle. Place the additional bet adjacent to the original bet, not on top of it. The dealer will deal one additional card to the hand. In the face-down game, he'll probably tuck it face-down under your bet, to be revealed later.

Players are allowed to double down for any amount up to the original bet amount, so you could double down "for less" if you wanted. Just remember that you do give up something for being allowed to increase your bet: the ability to draw more than one additional card. If the correct play is to double down, you should always double for the full amount if possible.

Splitting Pairs
When you are dealt a matching pair of cards (remember, ignore the suits), you have the ability to split the hand into two separate hands, and play them independently. Let's say you are dealt a pair of eights for a total of sixteen. Sixteen is the worst possible player hand, since it is unlikely to win as is, but is very likely to bust if you draw to it. Here's a great chance to improve a bad situation.

Some Object-Oriented Requirements

You are to have at least 4 classes in this assignment: Card, Deck, Game and your application class. You may want to have other classes.

Grading

Submission

All assignments are to be submitted electronically - including your design documents. To submit your work, you must be logged into aludra.usc.edu - in your Unix account. We use the submit program to do the actual submission. The command line you must enter to submit your work is:
     submit -user csci105 -tag hw1 MYFILEA MYFILEB MYFILEC

Where MYFILEA/MYFILEB/MYFILEC is the list of file names that you are submitting. DO NOT submit your compiled code, just your source code and design documents. Also, submit a file called COMPILE. This is the instructions for the TA/LA on how to compile and run your problems

Homework 2 - Even More Blackjack

Now you are to have a Dealer and up to 5 players. Each player makes their own decisions as to how to play their hand. You are to prompt each Player for their name and give them a choice for how many chips they wish to start with.

We will use the version of Blackjack where the Dealer stands on 17, or higher. The dealer continues to take cards until they get 17, or more, or bust. One of the dealer's cards is to be face down - no Player can see it until all Players have played their hand.

You must also incorporate early and late surrender for this homework.

If you didn't create a Player class for homework 1, you must have one for homework 2.

To keep track of cards, you are also to have a Hand class. A 'hand' is the set of cards that a Player is playing. Note that in Blackjack, a single Player can have more then one hand - if they split. Your Player class must have be able to handle multiple hands.

Grading

Submission

All assignments are to be submitted electronically - including your design documents. To submit your work, you must be logged into aludra.usc.edu - in your Unix account. We use the submit program to do the actual submission. The command line you must enter to submit your work is:
     submit -user csci105 -tag hw2 MYFILEA MYFILEB MYFILEC

Where MYFILEA/MYFILEB/MYFILEC is the list of file names that you are submitting. DO NOT submit your compiled code, just your source code and design documents. Also, submit a file called COMPILE. This is the instructions for the TA/LA on how to compile and run your problems

Homework 3 - GUI Version of Homework 2

Turn your entire homework 2 into a nice GUI-based program. You are to use menus for the various options available to a player - start a game, register a player, exit, etc.

You are expected to have multiple JPanel subclasses, with the application (game) class as the integrator - as described in class.

Link to Card Images
To download image archive to aludra type on aludra : wget http://www-scf.usc.edu/~csci105/cards/allcards.tar.gz
To unzip : gunzip allcards.tar.gz
To untar : tar -xvvf allcards.tar

Grading

Submission

All assignments are to be submitted electronically - including your design documents. To submit your work, you must be logged into aludra.usc.edu - in your Unix account. We use the submit program to do the actual submission. The command line you must enter to submit your work is:
     submit -user csci105 -tag hw3 MYFILEA MYFILEB MYFILEC

Where MYFILEA/MYFILEB/MYFILEC is the list of file names that you are submitting. DO NOT submit your compiled code, just your source code and design documents. Also, submit a file called COMPILE. This is the instructions for the TA/LA on how to compile and run your problems

V3.1 Restaurant Simulation (Team Project)

The actual assignment is here. The description there does not include the fact that you are required to have "unit" tests for your JPanel subclasses. You do not have to use JUnit - in fact JUnit does not work for UI type code. However, each student is required to have JPanel subclasses for their part of the UI. If the current design of the Restaurant does not have JPanel subclasses, you MUST change it. You must each have your own "application" class that allows the TA to properly grade your UI. This also means you must have a test document in the wiki describing HOW to test your UI test application. This is in addition to the tag code for the entire system. The TAs will be looking for your individual panels in the tag code.

Grading

NOTE: Any student with less than 9 points for their branch code will receive ZERO points for the 15 team points. This is NOT negotiable.

Submission

There is no separate submission for this project. Each student in each group is to have a Subversion branch for the code they have developed. Each team is to have a tag copy of their system that will be the code tested by TAs/graders. Any documentation specific for your testing is to be easily viewable to the TAs. The "system" documentation should also be easily viewable by them.