1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
|
#include <iostream>
#include "card.h"
int main()
{
srand(time(NULL));
//starting pools
double aiPool = 1000000;
double p2Pool = 1000;
double pot;
int randPool[2] = { 0, rand() % 23 + 3 };
card deckOfCards[52];
for (int i = 0; i < 13; i++)
{
deckOfCards[i].value = i + 2;
deckOfCards[i].suit = 'S';
deckOfCards[i].suitValue = 4;
}
for (int i = 0; i < 13; i++)
{
deckOfCards[i + 13].value = i + 2;
deckOfCards[i + 13].suit = 'H';
deckOfCards[i + 13].suitValue = 3;
}
for (int i = 0; i < 13; i++)
{
deckOfCards[i + 26].value = i + 2;
deckOfCards[i + 26].suit = 'C';
deckOfCards[i + 26].suitValue = 2;
}
for (int i = 0; i < 13; i++)
{
deckOfCards[i + 39].value = i + 2;
deckOfCards[i + 39].suit = 'D';
deckOfCards[i + 39].suitValue = 1;
}
shuffle(deckOfCards, 52);
card aiHand[2];
card player2Hand[2];
int topCard = 0;
int aiSize = 0;
int p2Size = 0;
for (int i = 0; i < 2; i++)
{
aiHand[i] = deckOfCards[topCard];
topCard++;
aiSize++;
player2Hand[i] = deckOfCards[topCard];
topCard++;
p2Size++;
}
cout << "AI's Hand" << endl;
for (int i = 0; i < aiSize; i++)
{
cout << "[XX]";
}
cout << endl << endl << "Your Hand" << endl;
for (int i = 0; i < p2Size; i++)
{
cout << player2Hand[i].displayCard();
}
cout << endl << endl;
card flop[3];
card turn[1];
card river[1];
int flopSize = 0;
int turnSize = 0;
int riverSize = 0;
//betting arrays & variables
string betting[3] = { "bet", "check", "fold" };
string playerInput;
string playerInput2;
string playerInput3;
string playerInput4;
string flopInput;
string turnInput;
string riverInput;
double betAmount;
double aiBetAmount;
//To implement:
//If player bets more than AI, let AI fold.
//Player fold option.
//To stop:
//AI betting same number over and over again.
//Repeated phrase: "Bet, Call, or Fold?"
cout << "Bet, Check, or Fold?" << endl;
getline(cin, playerInput);
//check
if (playerInput == betting[1] || playerInput == "Check")
{
betAmount = 0;
}
//bet
if (playerInput == betting[0] || playerInput == "Bet")
{
cout << "Please enter amount: " << endl;
cin >> betAmount;
}
//AI has double
if (aiHand[0].value == aiHand[1].value)
{
double j = ((double)(rand() % 27 + 24)) / (double)1000;
aiBetAmount = j * p2Pool;
cout << endl << "AI bets: " << aiBetAmount << endl << endl;
}
//AI has 2 of same suit
else if (aiHand[0].suitValue == aiHand[1].suitValue)
{
double j = ((double)(rand() % 9 + 16)) / (double)1000;
aiBetAmount = j * p2Pool;
cout << endl << "AI bets: " << aiBetAmount << endl << endl;
}
//AI has double that are same suit
else if (aiHand[0].value == aiHand[1].value && aiHand[0].suitValue == aiHand[1].suitValue)
{
double j = ((double)(rand() % 18 + 64)) / (double)1000;
aiBetAmount = j * p2Pool;
cout << endl << "AI bets: " << aiBetAmount << endl << endl;
}
//AI makes bluffs occasionally
else
{
int i = rand() % 2;
aiBetAmount = randPool[i];
cout << endl << "AI bets: " << aiBetAmount << endl << endl;
}
//If AI bets more than player, prompt player to at least match bet.
while (aiBetAmount > betAmount)
{
cout << "Bet, Call, or Fold?" << endl;
getline(cin, playerInput);
if (playerInput == betting[0] || playerInput == "Bet")
{
cout << "Please enter amount: " << endl;
cin >> betAmount;
cin.ignore(1000, '\n');
}
if (playerInput == "Call" || playerInput == "call")
{
betAmount = aiBetAmount;
cout << "You call AI's bet of: " << aiBetAmount << endl;
}
}
//If player bets more than AI, AI always calls.
while (aiBetAmount < betAmount)
{
aiBetAmount = betAmount;
cout << "AI calls your bet of: " << betAmount << endl;
}
cout << "You bet: " << betAmount << endl << endl;
pot = betAmount + aiBetAmount;
aiPool -= (pot / 2);
p2Pool -= (pot / 2);
cout << "The Pot: " << pot << endl << endl;
cout << "AI's Pool: " << aiPool << endl;
cout << "Your Pool: " << p2Pool << endl;
|