|
|
Basic BlackJack Game in C++Required skills: C++ Programming
Blackjack!
EECS 280 – Winter 2010 Due: March 30th, 11:59pm Introduction This project will give you experience implementing abstract data types, using interfaces (abstract base classes), and using interface/implementation inheritance. Blackjack (Simplified) Blackjack, also sometimes called 21, is a relatively simple game played with a standard deck of 52 playing cards. There are two principals, a dealer and a player. The player starts with a bankroll, and the game progresses in rounds called hands. At the start of each hand, the player decides how much to wager on this hand. It can be any amount between some minimum allowable wager and the player's total bankroll, inclusive. After the wager, the dealer deals a total of four cards: the first face‐up to the player, the second face‐up to himself, the third face‐up to the player, the fourth face‐down to himself. The player then examines his/her cards, forming a total. Each card numbered 2‐10 is worth its “spot” value (the number on the card); each “face” card (jack, king, queen) is worth 10. An ace is worth either 1 or 11‐‐whichever is more advantageous to the player. If the total includes an ace counted as 11, the total is called "soft", otherwise it is called "hard". Play progresses first with the player, then the dealer. The player's goal is to build a hand that totals as close to 21 as possible without going over. If the total is over 21, this is called a "bust", and a player who busts loses the hand without forcing the dealer to play. As long as the player believes another card will help, the player "hits" by asking the dealer for another card. Each of these additional cards is dealt faceup. This process ends either when the player decides to "stand" (ask for no more cards) or the player busts. Note that a player can stand with two cards; one need not hit at all in a hand. If the player is dealt an ace plus any ten or face card, the player's hand is called a "natural 21", and the player's wager is paid off with 3 to 2 odds, without examining the dealer's cards. In other words, if the player had wagered 10, the player would win 15 if dealt a natural 21. If the player neither busts nor is dealt a natural 21, play then progresses to the dealer. The dealer must hit until he either reaches a total greater than or equal to 17 (hard or soft), or busts. If the dealer busts, the player wins. Otherwise, the two totals are compared. If the dealer's total is higher, the player's bankroll decreases by the amount of his/her wager. If the player's total is higher, her bankroll increases by the amount of her wager. If the totals are equal, the bankroll is unchanged; this is called a "push". The only case where the hands are equal that is not a push is when the player and dealer are each dealt natural 21s. In that case, the player is still paid 3:2. Note that this is a very simplified form of the game: we do not split pairs, allow double‐down bets, or take insurance. Likewise, a natural 21 for the dealer does not end the hand preemptively. Programming Assignment You will provide one or more implementations of four separate abstractions for this project: a deck of cards, a blackjack hand, a blackjack player, and a game driver. All files referenced in this specification are located at: /afs/umich.edu/class/eecs280/proj4 You may copy them to your private directory space, but may not modify them in any way. This will help ensure that your submitted project compiles correctly. For this project, the penalty for code that does not compile will be severe, regardless of the reason. The Deck ADT Your first task is to implement the following ADT representing a deck of cards: class DeckEmpty { // An exception type }; const int DeckSize = 52; class Deck { // A standard deck of 52 playing cards---no jokers Card deck[DeckSize]; // The deck of cards int next; // The next card to deal public: Deck(); // EFFECTS: constructs a "newly opened" deck of cards. first the // spades from 2-A, then the hearts, then the clubs, then the // diamonds. The first card dealt should be the 2 of Spades. void reset(); // EFFECTS: resets the deck to the state of a "newly opened" deck // of cards: void shuffle(int n); // REQUIRES: n is between 0 and 52, inclusive. // MODIFIES: this // EFFECTS: cut the deck into two segments: the first n cards, // called the "left", and the rest called the "right". Note that // either right or left might be empty. Then, rearrange the deck // to be the first card of the right, then the first card of the // left, the 2nd of right, the 2nd of left, and so on. Once one // side is exhausted, fill in the remainder of the deck with the // cards remaining in the othe rside. Finally, make the first // card in this shuffled deck the next card to deal. For example, // shuffle(26) on a newly-reset() deck results in: 2-clubs, // 2-spades, 3-clubs, 3-spades ... A-diamonds, A-hearts. // // Note: if shuffle is called on a deck that has already had some // cards dealt, those cards should first be restored to the deck // in the order in which they were dealt, preserving the most // recent post-shuffled/post-reset state. Card deal(); // MODIFIES: this // EFFECTS: returns the next card to be dealt. If no cards // remain, throws an instance of DeckEmpty. int cardsLeft(); // EFFECTS: returns the number of cards in the deck that have not // been dealt since the last reset/shuffle. }; The Deck ADT is specified in deck.h. The Deck ADT depends on the following Card type: enum Suit { SPADES, HEARTS, CLUBS, DIAMONDS }; extern const char *SuitNames[DIAMONDS+1]; enum Spot { TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING, ACE }; extern const char *SpotNames[ACE+1]; struct Card { Spot spot; Suit suit; }; which is declared in card.h, implemented by card.cpp, and included by deck.h. The file card.cpp defines SpotNames and SuitNames for you, so that SuitNames[HEARTS] evaluates to "Hearts", and so on. You are to put your implementation of this ADT in a file named "deck.cpp". You must use exactly this name. The Hand Interface Your second task is to implement the following ADT representing a blackjack hand: struct HandValue { int count; // Value of hand bool soft; // true if hand value is a soft count }; class Hand { // OVERVIEW: A blackjack hand of zero or more cards // Note: this really is the only private state you need! HandValue curValue; public: Hand(); // EFFECTS: establishes an empty blackjack hand. void discardAll(); // MODIFIES: this // EFFECTS: discards any cards presently held, restoring the state // of the hand to that of an empty blackjack hand. void addCard(Card c); // MODIFIES: this // EFFECTS: adds the card "c" to those presently held. The // count field is the highest blackjack total possible without // going over 21. The soft field should be true if and only if at // least one ACE is present, and its value is counted as 11 rather // than 1. If the hand is over 21, any value over 21 may be // returned. HandValue handValue() const; // EFFECTS: returns the present value of the blackjack hand. // // Note: the const qualifier at the end of handValue means that // you are not allowed to change any member variables inside // handValue. It is required because Players only get const Hands // passed to them, and therefore can only call methods guaranteed // not to change the hand. }; The Hand ADT is specified in hand.h The Hand ADT depends on the Card type, and includes card.h. You are to put your implementation of this ADT in a file named "hand.cpp". You must use exactly this name. The Player Interface Your third task is to implement three different blackjack players. The interface for a Player is: class Player { // A virtual base class, providing the player interface public: virtual int bet(unsigned int bankroll, unsigned int minimum) = 0; // REQUIRES: bankroll >= minimum // EFFECTS: returns the player's bet, between minimum and bankroll // inclusive virtual bool draw(Card dealer, // Dealer's "up card" const Hand &player) = 0; // Player's current hand // EFFECTS: returns true if the player wishes to be dealt another // card, false otherwise. virtual void expose(Card c) = 0; // EFFECTS: allows the player to "see" the newly-exposed card c. // For example, each card that is dealt "face up" is expose()d. // Likewise, if the dealer must show his/her "hole card", it is // also expose()’d. Note: not all cards dealt are expose()’d---if // the player goes over 21 or is dealt a natural 21, the dealer // does not expose his/her hole card. virtual void shuffled() = 0; // EFFECTS: tells the player that the deck has been re-shuffled. }; The Player ADT is specified in player.h The Player ADT depends on the Hand type, and includes hand.h. You must implement three different derived classes from this interface. The first derived class is the Simple player, who plays a simplified version of basic strategy for blackjack. The simple player always places the minimum allowable wager, and decides to hit or stand based on the following rules and whether or not the player has a “hard count” or “soft count”: The first set of rules apply if the player has a "hard count" (i.e. his/her best total counts an Ace (if any) for 1, not 11). • If the player's hand totals 11 or less, he always hits. • If the player's hand totals 12, he stands if the dealer shows 4, 5, or 6; otherwise he hits. • If the player's hand totals between 13 and 16 inclusive, he stands if the dealer shows a 2 through a 6 inclusive; otherwise he hits. • If the player's hand totals 17 or greater, he always stands. The second set of rules applies if the player has a "soft count" (i.e. his/her best total includes one Ace worth 11). Note that a hand would never count two Aces as 11 each – that's a bust of 22. • If the player's hand totals 17 or less, he always hits. • If the player's hand totals 18, he stands if the dealer shows a 2, 7, or 8, otherwise he hits. • If the player's hand totals 19 or greater, he always stands. The Simple player does nothing for expose and shuffled events. The second derived class is the Counting player. This player counts cards in addition to playing the basic strategy. The intuition behind card counting is that when the deck has more face cards (worth 10 each) than low‐numbered cards, the deck is favorable to the player. The converse is also true. The Counting player keeps a running "count" of the cards he's seen from the deck. Each time he sees (via the expose() method) a 10, Jack, Queen, King, or Ace, he subtracts one from the count. Each time he sees a 2, 3, 4, 5, or 6, he adds one to the count. When he sees that the deck is shuffled(), the count is reset to zero. Whenever the count is +2 or greater, the Counting player bets double the minimum, otherwise he bets the minimum. The Counting player should not re‐implement methods of the Simple player unnecessarily. The final derived class you are to implement is the Competitor. The Competitor can play any strategy you choose. The Competitor cannot play the same strategy as the Simple or Counting players‐‐‐there must be some difference, however minor. The quality of the Competitor's play will not count toward your grade, however, you should try to get it to perform better than the Counting player. All three of these Players must be implemented in a file named "player.cpp". You must also declare a static global instance of each of the three Players you implement in your player.cpp file. Finally, you should implement the following "access" functions that return pointers to each of these three global instances in your player.cpp file. extern Player *get_Simple(); extern Player *get_Counting(); extern Player *get_Competitor(); Note: we've structured the Player as an Abstract Base Class in player.h so that you have complete design freedom for the Competitor and its state. The Driver program Finally, you are to implement a driver program that can be used to simulate this version of blackjack given your implementation of the ADTs described above. You are to put your implementation of this driver program in a file named "driver.cpp". The driver program, when run, takes three arguments: driver [simple|counting|competitor] The first argument is an integer denoting the player's starting bankroll. The second argument is the maximum number of hands to play in the simulation. The final argument is one of the three strings "simple", "counting", or "competitor", denoting which of the three players to use in the simulation. The driver first shuffles the deck. To shuffle the deck, you choose seven cuts between 13 and 39 inclusive at random, shuffling the deck with each of these cuts. We have supplied a header, rand.h, and an implementation, rand.cpp, that define a function that provides these random cuts. Each time the deck is shuffled, first announce it: cout test.out diff test.out sample.txt If the diff program reports any differences at all, you have a bug. Handing in and grading Use the submit280 program to submit the following files for project 4: deck.cpp your Deck implementation player.cpp your three Players driver.cpp your simulation driver hand.cpp your Hand implementation deck.overview overview of your deck test cases deck.case.1.cpp first deck test case deck.case.2.cpp second deck test case ... deck.case.N.cpp Nth deck test case player.overview overview of your Counting Player test cases player.case.1.cpp first player test case player.case.2.cpp second player test case ... player.case.N.cpp Nth player test case IMPORTANT NOTE: You must submit ALL of your files with a SINGLE invocation of submit280. DO NOT SUBMIT YOUR FILES INDIVIDUALLY. To do this, you simply list all the filenames you are going to submit separated by spaces in a list that follows the project number in submit280. For example, submit280 4 file1.cpp file2.cpp file3.cpp file4.cpp would submit the four files, file1.cpp file2.cpp file3.cpp file4.cpp. There are three components to your grade in this project: • Correctness of deck, player, driver, and hand • Testing of deck and player • The style of your deck, player, driver, and hand implementations Collaboration In addition to the usual prohibition against sharing any code (as described in the syllabus) you may not share test cases, behavior lists, or output with anyone else. All must be entirely your own work. Any sharing will be considered a violation of the Honor Code.
Related projects:Psudo snake game in C
rrays, strings, basic sorting, basic searching, basic random, pretty basic scanfs, printfs, fscanfs, fprintfs, etc, and very basic input and output of data to txt files using strings. Also, great stress has been put on the use of functions in this course, so the use of good functions is important. This program has to be as simple as possible to make it believable that it was written by me, since this is my first programming class ever.
Button Game in c by googleindia2005
This gives the Graphical interface that is developed in c .This is a game in c language
Additional files submitted: Button1.exe Bubble Breaker (Very Simple) game in C# Console
plication that allows the player to use the mouse, you are not supposed to develop such an application. Instead, developing a console application that asks the user the indexes of the tile s/he wants to clear and completing the other steps satisfies the requirements of the project. Project must be done in C#, and contains features of C# such as Colors must be Enum, switch-case can be used, foreach must be used, List can be used. Bubble Breaker (Very Simple) game in C# Console
that allows the player to use the mouse, you are not supposed to develop such an application. Instead, developing a console application that asks the user the indexes of the tile s/he wants to clear and completing the other steps satisfies the requirements of the project. Project must be done in C#, and contains features of C# such as Colors must be Enum, switch-case can be used, foreach must be used, List<T> can be used. Kings in the Corner (Card Game in C++) Featured Projects, identified by a lab
Script tag */-->
Additional files submitted: (Files are only available for logged in users) Assignment+Description.docx Basic Linux programming in C
I need someone to help me with a basic project that will use fundamental Linux file operations. Program will be coded in C and will run in Linux environment. Details to be provided in PM happy bidding! Simple game in C++ by JoeBloggs26
oped with Dev C++. It is a very simple task for you and will not be released commercially as it is for private use. It is probably only a few hours work in all. If you send me a private message I will send you some more information on what is required. I'm just seeing if there is anyone up for the challenge first. Please get in touch asap as I have a very tight deadline to meet and need this completed within the next few days Thanks for your time Need a Problem Solved in C along With Proper Algorithm
Hi I need a basic program written in C which will solve the following problem.You need to also provide the algorithm. I have attached the software requirements below in pdf format. There must be comments used wherever possible so that it can be understood.If there are some problems in understanding,you need to explain it. [I know C so explaining won't be a big worry] blackjack game in java
pears a few buttons like hit, stay or deal. I need this work to be sone as soon as possible need a simple blackjack game and the code to be as more simple as possible. A few classes like card, hand, player, deck,... etc. I just need to do what a real blackjack game does. The hole work must include GUI. Running the program should appears a few buttons like hit, stay or deal. I need this work to be sone as soon as possible Basic Interactive Game With C# C Sharp.
Using C#
Create a simple 2d interactive game of a ROOM that includes: - Chairs, Tables, Window, Bed, Pc. - Create a MENU that contains: "rotate", "scale" and "reset" - The user who is playing the game can "rotate" and "scale" the objects. - Include a RESET button which puts objects back to the way they were. This is not really a game, just an interaction with objects in a room. BlackJack in C
project. The flowcharts must match your code * Include a "User Instructions" document that explains to a new user how to use your program. Be sure your document is professional looking, with proper grammar and spelling Hints: * You will need to use an array to hold the deck. An array of 52 will work fine. * Since we are using characters, we will need to use a getchar() after each scanf to get rid of the newline. BlackJack game written in C#/C++
clude a "User Instructions" document that explains to a new user how to use your program. Be sure your document is professional looking, with proper grammar and spelling Submit your source file(s), User Instructions document and data files (if you use them) You will need to use an array to hold the deck. An array of 52 will work fine. Please use a getchar() after each scanf to get rid of the newline. **Needed by July 16th** basic airline reservation system - in C
ou may include menus that you feel are relevant to navigate around the system. Eventually there should be an end to the system. Use quit to exit the system. You may use structures, arrays, loops, and decision structures in your program. you may include any extra feature eg. sorting the boarding passes by name, which you may feel relevant and that adds value to the system Bids should be very low. Project is very basic one. Game to be remade in C# + More features
I'd like this game: http://thelocalbillboard.com/CreativeBox/game.php to be remade in C# and multiplayer (Up to 4 players!) support added to it. I'd also like the game GUI on the game to be changed so it's nicer. When placing blocks, there should be a grid so blocks automatically fit in the grid. This project shouldn't cost too much! c# game in visual studio
small game in visual studio using c# contact me for details thanks Basic file system in C++
ed to be implemented - File and File system. Detailed description is attached.
Additional files submitted: (Files are only available for logged in users) Project+description.pdf Developing a very small game in C++ (Console application)
/td>
Additional files submitted: (Files are only available for logged in users) assign.docx Tutorial.docx Need help coding AI bot for Defcon PC game in C++ using API
ilable for logged in users) defcon_ai_api_v157.zip introversion_ai_bot_v0.9.zip defcon_ai_api_-_constants_and_tables_v1.pdf defcon_ai_api_-_function_list_v1.pdf defcon_ai_api_-_quickstart_and_documentation_v1.pdf Zoo Simulator Game using OOP in C++ by NexusEcom
Have good object oriented programming skills in C++/Java?? Looking for person who can write a zoo simulator game. Couple of hundred lines of code maybe(?). Program to run from command prompt, no graphics or anything complicated. Should have paypal account.
Checkers in C and GTK
A simple multiplayer Checkers game (draughts) in C and GTK+. 1 and 2 players mode. Games can be saved and loaded. Redo and Undo capabilities, score table with the last 5 best matches. Status bar showing elapsed time.Table showing remaining chip.
Currently viewed: "Basic BlackJack Game in C++
"
|