Video Poker Simulation Acme Software, Inc, has been contracted to write a Video
ID: 3626503 • Letter: V
Question
Video Poker Simulation
Acme Software, Inc, has been contracted to write a Video Poker Simulation game in basic C++ that follows the following rules:
Basic Setting:
The player places an initial bet between one (1) and fifty (50) coins, where each coin is worth $1.00. The player is then dealt five (5) cards and allowed to choose which cards, if any, they wish to keep. The cards that they do not wish to keep are discarded, and replacement cards are dealt so that they again have a total of five (5) cards. The computer then determines what amount they have won, if any.
Card Ranks and Suits:
Cards are ranked, from highest to lowest:
· Ace
· King
· Queen
· Jack
· Ten
· Nine
· Eight
· Seven
· Six
· Five
· Four
· Three
· Two
· Ace
(Ace can count as either low or high. See "Royal Flush"'s scoring, below.)
The card suits are: Hearts, Clubs, Diamonds, and Spades
Hand Ranks:
When you are dealt replacement cards for your discards, your new hand is evaluated. Based on what kind of hand you're holding, you'll receive a certain number of coins.
Hands are listed below, from best (highest scoring), to worst (no score):
· Royal Flush - 2000 coins -- A straight flush, with the Ace high. In other words, a Ten, Jack, Queen, King and Ace, all of the same suit.
· Straight Flush - 250 coins -- A straight flush. In other words, all five cards are consecutive and are the same suit. For example: Three of Clubs, Four of Clubs, Five of Clubs, Six of Clubs and Seven of Clubs.
· Four of a Kind - 125 coins -- Four cards of the same value. (Obviously, each of different suits.)
· Full House - 40 coins -- A three of a kind and a pair at the same time.
· Flush - 25 coins -- All cards in your hand are the same suit.
· Straight - 20 coins -- All five cards are consecutive. For example: Three of Clubs, Four of Spades, Five of Clubs, Six of Diamonds, and Seven of Hearts.
· Three of a Kind - 15 coins -- Three cards of the same value.
· Two Pair - 10 coins -- Two pairs of cards. In other words, two cards in your hand are the same value, and two other cards in your hand are also the same value.
· Pair - 5 coins -- Two cards in your hand are the same value. In this version, they must be Jacks or better!
· None of the Above - 0 coins
Each turn "costs" one dollar, so if you get a pair, no money actually end up added to your total score. If you don't get anything, you actually lose a dollar! If you bet more than one dollar coin, then the returns above are multiplied by the number of coins entered to give the actual yield. This is just how handheld and Vegas video poker games actually work!
Project Requirements:
Your project must meet the following specifications:
1. Text-based display of what is in the player’s hand.
2. Read all cards to be discarded at once
3. Read from the command line as a program parameter the name of a file that contains the state of a previous game so that a player can resume a game at any point. Thus, your program must read and write to a file as well as verify that a file exists.
4. Provided adequate “help” for the player on how to play the game.
5. Score all hands correctly.
6. Know the player’s name and be “friendly”
Also ;
1.Mouse and graphical input
2.Menu-like graphics selection of cards to discard, etc.
3.Sound / music
4. "Dueces Wild" Same as above, but with each of the "Dueces" (a two) being a "Wild Card." Your program then must calculate the highest return that each two will yield the player.
Explanation / Answer
#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;
bool royal(int suit[],int number[]);
bool straightFlush(int suit[],int number[]);
bool fourOfKind(int suit[],int number[]);
bool flush(int suit[],int number[]);
bool straight(int suit[],int number[]);
bool fullHouse(int suit[],int number[]);
bool threeOfKind(int suit[],int number[]);
bool twoPair(int suit[],int number[]);
bool isPair(int suit[],int number[]);
void displayCards(int suit[],int number[]);
int main()
{
srand ( time(NULL) );
int card[4][13];
//4: 0=heart 1=spade 2=club 3=diamond
//13: 0=ace,1=2,2=3,3=4,...9=10,10=jack,11=queen,12=king
int suit[5];
int number[5];
int cards=0;
int bet=51;
int cash=50;
while(cash!=0 && bet>0)
{
for(int i=0;i<4;i++)
{
for(int z=0;z<13;z++)
{
card[i][z]=1;
}
}
while(bet>cash || bet==0)
{
cout<<"You have "<cout<<"(You can also enter any negative number to quit)";
cin>>bet;
}
if(bet>0)
{
bet*=5;
cash-=bet;
cards=0;
while(cards<5)
{
int s,n;
do
{
s=rand()%4;
n=rand()%13;
}
while(card[s][n]!=1);
card[s][n]=0;
suit[cards]=s;
number[cards]=n;
cards++;
}
displayCards(suit,number);
int z=2;
for(int i=0;i<5;i++)
{
while(z<0 || z>1)
{
cout<<" Do you want to get rid of card "<cin>>z;
}
if(z==1)
{
int s,n;
do
{
s=rand()%4;
n=rand()%13;
}
while(card[s][n]!=1);
card[s][n]=0;
suit[i]=s;
number[i]=n;
}
z=-1;
}
displayCards(suit,number);
int temps[5];
int tempn[5];
int min=number[0];
int minloc=0;
for(int i=0;i<5;i++)
{
for(int z=0;z<5;z++)
{
if(min>number[z])
{
min=number[z];
minloc=z;
}
}
tempn[i]=min;
temps[i]=suit[minloc];
number[minloc]=20;
suit[minloc]=20;
min=20;
}
for(int i=0;i<5;i++)
{
suit[i]=temps[i];
number[i]=tempn[i];
}
if(royal(suit,number))
{
cout<<" You just got a Royal Flush!!!"<cout<<"You've won "<<2000*bet/5<<" coins"<cash+=2000*bet/5;
}
else if(straightFlush(suit,number))
{
cout<<" You just got a Stright Flush!!!"<cout<<"You've won "<<250*bet/5<<" coins"<cash+=250*bet/5;
}
else if(fourOfKind(suit,number))
{
cout<<" You just got four of a kind!!!"<cout<<"You've won "<<125*bet/5<<" coins"<cash+=125*bet/5;
}
else if(fullHouse(suit,number))
{
cout<<" You just got a full house!!!"<cout<<"You've won "<<40*bet/5<<" coins"<cash+=40*bet/5;
}
else if(flush(suit,number))
{
cout<<" You just got a Royal Flush!!!"<cout<<"You've won "<<25*bet/5<<" coins"<cash+=25*bet/5;
}
else if(straight(suit,number))
{
cout<<" You just got a straight!!!"<cout<<"You've won "<<20*bet/5<<" coins"<cash+=20*bet/5;
}
else if(threeOfKind(suit,number))
{
cout<<" You just got three of a kind!!!"<cout<<"You've won "<<15*bet/5<<" coins"<cash+=15*bet/5;
}
else if(twoPair(suit,number))
{
cout<<" You just got two pair!!!"<cout<<"You've won "<<10*bet/5<<" coins"<cash+=10*bet/5;
}
else if(isPair(suit,number))
{
cout<<" You just got a pair!!!"<cout<<"You've won "<<5*bet/5<<" coins, breaking even"<cash+=5*bet/5;
}
else
{
cout<<"Sorry you didnt get anything! You've lost "<}
bet=cash+1;
}
}
cout<<" Thanks for playing! ";
}
void displayCards(int suit[],int number[])
{
cout<<"Your hand is:"<for(int i=0;i<5;i++)
{
if(number[i]==0)
cout<<"Ace";
else if(number[i]>0&&number[i]<10)
cout<else if(number[i]==10)
cout<<"Jack";
else if(number[i]==11)
cout<<"Queen";
else
cout<<"King";
cout<<" of ";
if(suit[i]==0)
cout<<"hearts";
else if(suit[i]==1)
cout<<"spades";
else if(suit[i]==2)
cout<<"clubs";
else
cout<<"diamonds";
cout<}
}
bool royal(int suit[],int number[])
{
bool ace=false,king=false;
if(straight(suit,number)&&flush(suit,number))
for(int i=0;i<5;i++)
{
if(number[i]==0)
ace=true;
else if(number[i]==12)
king=true;
}
if(ace && king)
return true;
else
return false;
}
bool straightFlush(int suit[],int number[])
{
if(straight(suit,number) && flush(suit,number))
return true;
else
return false;
}
bool fourOfKind(int suit[],int number[])
{
int location;
for(int i=1; i<5;i++)
{
if(number[0]!=number[i])
location =i;
}
for(int i=1;i<5;i++)
{
if(number[0]!=number[i] && number[location]!=number[i])
return false;
}
int num=0;
int num2=0;
for(int i=0;i<5;i++)
{
if(number[0]-number[i]==0)
num++;
else if(number[location]-number[i]==0)
num2++;
}
if(num==4 || num2==4)
return true;
else
return false;
}
bool flush(int suit[],int number[])
{
for(int i=1;i<5;i++)
{
if(suit[i]!=suit[0])
return false;
}
return true;
}
bool straight(int suit[],int number[])
{
if(number[0]!=0)
{
for(int i=0;i<4;i++)
{
if(number[i]+1!=number[i+1])
return false;
}
return true;
}
else
{
bool in=true;
for(int i=0;i<4;i++)
{
if(number[i]+1!=number[i+1])
in=false;
}
if(in)
return true;
else
{
if(number[0]==0 && number[1]==9 && number[2]==10 && number[3]==11 && number[4]==12)
return true;
else
return false;
}
}
}
bool fullHouse(int suit[],int number[])
{
int location;
for(int i=1; i<5;i++)
{
if(number[0]!=number[i])
location =i;
}
for(int i=1;i<5;i++)
{
if(number[0]!=number[i] && number[location]!=number[i])
return false;
}
int num=0;
int num2=0;
for(int i=0;i<5;i++)
{
if(number[0]-number[i]==0)
num++;
else if(number[location]-number[i]==0)
num2++;
}
if((num==3 && num2==2) || (num==2 && num2==3))
return true;
else
return false;
}
bool threeOfKind(int suit[],int number[])
{
int location, location2;
for(int i=1; i<5;i++)
{
if(number[0]!=number[i])
location =i;
}
for(int i=1;i<5;i++)
{
if(number[0]!=number[i] && number[location]!=number[i])
location2=i;
}
int num=0;
int num2=0;
int num3=0;
for(int i=0;i<5;i++)
{
if(number[0]-number[i]==0)
num++;
else if(number[location]-number[i]==0)
num2++;
else if(number[location2]-number[i]==0)
num3++;
}
if(num==3 || num2==3 || num3==3)
return true;
else
return false;
}
bool twoPair(int suit[],int number[])
{
int location, location2, location3;
for(int i=1; i<5;i++)
{
if(number[0]!=number[i])
location =i;
}
for(int i=1;i<5;i++)
{
if(number[0]!=number[i] && number[location]!=number[i])
location2=i;
}
for(int i=1;i<5;i++)
{
if(number[0]!=number[i] && number[location]!=number[i] && number[location2]!=number[i])
location3=i;
}
int num=0;
int num2=0;
int num3=0;
int num4=0;
for(int i=0;i<5;i++)
{
if(number[0]-number[i]==0)
num++;
else if(number[location]-number[i]==0)
num2++;
else if(number[location2]-number[i]==0)
num3++;
else if(number[location3]-number[i]==0)
num4++;
}
if((num==2 && (num2==2 || num3==2 || num4==2))|| (num2==2 && (num3==2 || num4==2)) || (num3==2 && num4==2))
return true;
else
return false;
}
bool isPair(int suit[],int number[])
{
int location,loc2,loc3;
for(int i=1; i<5;i++)
{
if(number[0]!=number[i])
location =i;
}
for(int i=1; i<5;i++)
{
if(number[0]!=number[i] && number[location]!=number[i])
loc2 =i;
}
for(int i=1; i<5;i++)
{
if(number[0]!=number[i] && number[location]!=number[i]&&number[loc2]!=number[i])
loc3=i;
}
for(int i=1;i<5;i++)
{
if(number[0]!=number[i] && number[location]!=number[i]&&number[loc2]!=number[i] && number[loc3]!=number[i])
return false;
}
return true;
}
Here you go, just make sure all the lines that are supposed to be on the same line are. If this doesnt work then just go to the download link that i provided of it:
http://oron.com/ft1lrv5yg62f/PokerGame.cc.html
Also in noticing this, it will not load a saved game nor save a game. sorry for that, i can change it to do this if it is really needed.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.