#include <ctime>

#include <iostream>

using namespace std ;

class poker

{

public :

int cards, cards_used [ 52 ] , face, suit, card_rank [ 2 ] , pot, real1, human_fold ( ) ;

int bet_amount, ai, ai2, raise_amount, limit, dan, human_bet, j, i ;

char choice, bet_choice, wait, bet_choice2, choice2 ;

void get_cards ( ) , show_cards ( ) ,card_process ( ) , computer_ai ( ) , fold ( ) , raise ( ) , find_out ( ) ;

void human_bet_process ( ) , dealcards ( ) ;

int showothercards ( ) , showcards ( ) ;

} ;

int my_money = 20000 ;

/*

------------------------------------------------------------------------------

--------------------------------------------------------------------------------

*/

void game ( )

{

poker game ;

game. dealcards ( ) ;

game. computer_ai ( ) ;

}

int main ( )

{

cout << "remember, y for yes and n for no

" ;

system ( "pause" ) ;

system ( "cls" ) ;

game ( ) ;

}

void poker :: dealcards ( )

{

//seed the random generator

srand ( time ( NULL ) ) ;

for ( int loop = 0 ; loop < 1 ; loop ++ )

{ //loop begining

cards = rand ( ) % 52 ; // randomize 52 cards

cards = rand ( ) % 52 ;

cards = rand ( ) % 52 ;

cards = rand ( ) % 52 ;

cards = rand ( ) % 52 ;

while ( cards_used [ cards ] == 1 )

{ //inner loop begining

while ( i > j )

{

cards = rand ( ) % 52 ;

cards = rand ( ) % 52 ;

cards = rand ( ) % 52 ; //randomising the cards even more

cards = rand ( ) % 52 ;

}

//inner loop end

}

face = cards % 13 ;

suit = cards / 13 ;

//outer loop end

}

//give player 1 his card

switch ( face )

{

case 0 :

card_rank [ 1 ] = 1 ;

break ;

case 1 :

card_rank [ 1 ] = 2 ;

break ;

case 2 :

card_rank [ 1 ] = 3 ;

break ;

case 3 :

card_rank [ 1 ] = 4 ;

break ;

case 4 :

card_rank [ 1 ] = 5 ;

break ;

case 5 :

card_rank [ 1 ] = 6 ;

break ;

case 6 :

card_rank [ 1 ] = 7 ;

break ;

case 7 :

card_rank [ 1 ] = 8 ;

break ;

case 8 :

card_rank [ 1 ] = 9 ;

break ;

case 9 :

card_rank [ 1 ] = 10 ;

break ;

case 10 :

card_rank [ 1 ] = 11 ;

break ;

case 11 :

card_rank [ 1 ] = 12 ;

break ;

case 12 :

card_rank [ 1 ] = 13 ;

break ;

}

//------------------------------------------------------------------------------------------------

//player 2 cards

cards = rand ( ) % 52 ; // randomize 52 cards

while ( cards_used [ cards ] == 1 )

{

cards = rand ( ) % 52 ; //changing the cards

}

face = cards % 13 ;

suit = cards / 13 ;

switch ( face )

{

case 0 :

card_rank [ 2 ] = 2 ;

cout << "2

" ;

break ;

case 1 :

card_rank [ 2 ] = 3 ;

cout << "3

" ;

break ;

case 2 :

card_rank [ 2 ] = 4 ;

cout << "4

" ;

break ;

case 3 :

card_rank [ 2 ] = 5 ;

cout << "5

" ;

break ;

case 4 :

card_rank [ 2 ] = 6 ;

cout << "6

" ;

break ;

case 5 :

card_rank [ 2 ] = 7 ;

cout << "7

" ;

break ;

case 6 :

card_rank [ 2 ] = 8 ;

cout << "8

" ;

break ;

case 7 :

card_rank [ 2 ] = 9 ;

cout << "9

" ;

break ;

case 8 :

card_rank [ 2 ] = 10 ;

cout << "10

" ;

break ;

case 9 :

card_rank [ 2 ] = 11 ;

cout << "J

" ;

break ;

case 10 :

card_rank [ 2 ] = 12 ;

cout << "Q

" ;

break ;

case 11 :

card_rank [ 2 ] = 13 ;

cout << "K

" ;

break ;

case 12 :

cout << "A

" ;

card_rank [ 2 ] = 14 ;

break ;

}

real1 = card_rank [ 2 ] ;

}

//this is the longest func,the ai

void poker :: computer_ai ( )

{

ai = rand ( ) % 12 ;

ai2 = rand ( ) % 12 ;

//------------------------------------------------

switch ( card_rank [ 1 ] )

{

//if it sees a 2

case 1 :

if ( ai == 1 )

{

limit = 3000 ;

if ( ai2 == 1 )

{

limit = 3000 ;

raise_amount = 500 ;

poker :: raise ( ) ;

}

else if ( ai2 == 2 )

{

limit = 3000 ;

raise_amount = 450 ;

poker :: raise ( ) ;

}

}

if ( ai == 6 )

{

limit = 50000 ;

raise_amount = 4000 ;

poker :: raise ( ) ;

}

else

{

limit = 3000 ;

raise_amount = 510 ;

poker :: raise ( ) ;

}

break ;

/*------------------------------------------------------------------------------

--------------------------------------------------------------------------------

*/

//if it sees a 3

case 2 :

if ( ai == 1 )

{

limit = 3100 ;

if ( ai2 == 1 )

{

limit = 3100 ;

raise_amount = 400 ;

poker :: raise ( ) ;

}

else if ( ai2 == 2 )

{

limit = 4100 ;

raise_amount = 2000 ;

poker :: raise ( ) ;

}

}

if ( ai == 2 )

{

if ( ai2 == 1 )

{

limit = 3100 ;

raise_amount = 775 ;

poker :: raise ( ) ;

}

else if ( ai2 == 2 )

{

limit = 4200 ;

raise_amount = 2000 ;

poker :: raise ( ) ;

}

}

else if ( ai == 10 )

{

poker :: fold ( ) ;

}

if ( ai == 6 )

{

limit = 50000 ;

raise_amount = 4000 ;

poker :: raise ( ) ;

}

else

{

limit = 4100 ;

raise_amount = 2100 ;

poker :: raise ( ) ;

}

//more can come here

break ;

/*------------------------------------------------------------------------------

--------------------------------------------------------------------------------

*/

//if it sees a 3

case 3 :

if ( ai == 1 )

{

if ( ai2 == 1 )

{

raise_amount = 1600 ;

limit = 5000 ;

poker :: raise ( ) ;

}

if ( ai2 == 2 )

{

raise_amount = 1500 ;

limit = 4000 ;

poker :: raise ( ) ;

}

}

else if ( ai > 1 && ai < 5 )

{

if ( ai2 == 1 )

{

limit = 2100 ;

raise_amount = 500 ;

poker :: raise ( ) ;

}

else if ( ai2 == 2 )

{

limit = 2100 ;

raise_amount = 700 ;

poker :: raise ( ) ;

}

}

else if ( ai > 5 && ai < 8 )

{

if ( ai2 == 1 )

{

limit = 2100 ;

raise_amount = 700 ;

poker :: raise ( ) ;

}

else if ( ai2 == 2 )

{

limit = 2100 ;

raise_amount = 850 ;

poker :: raise ( ) ;

}

}

else if ( ai == 10 )

{

poker :: fold ( ) ;

}

if ( ai == 6 )

{

limit = 50000 ;

raise_amount = 4000 ;

poker :: raise ( ) ;

}

else

{

limit = 2100 ;

raise_amount = 900 ;

poker :: raise ( ) ;

}

break ;

/*------------------------------------------------------------------------------

--------------------------------------------------------------------------------

*/

//if it sees a 4

case 4 :

if ( ai == 1 )

{

if ( ai2 == 1 )

{

limit = 3000 ;

raise_amount = 1500 ;

poker :: raise ( ) ;

}

if ( ai2 == 2 )

{

limit = 3000 ;

raise_amount = 1200 ;

poker :: raise ( ) ;

}

else

{

raise_amount = 700 ;

limit = 3000 ;

poker :: raise ( ) ;

}

}

else if ( ai > 1 && ai < 5 )

{

if ( ai2 == 1 )

{

limit = 2100 ;

raise_amount = 500 ;

poker :: raise ( ) ;

}

else if ( ai2 == 2 )

{

limit = 2100 ;

raise_amount = 700 ;

poker :: raise ( ) ;

}

else

{

raise_amount = 1000 ;

limit = 4000 ;

poker :: raise ( ) ;

}

}

else if ( ai > 5 && ai < 8 )

{

if ( ai2 == 1 )

{

limit = 2100 ;

raise_amount = 700 ;

poker :: raise ( ) ;

}

else if ( ai2 == 2 )

{

limit = 2000 ;

raise_amount = 850 ;

poker :: raise ( ) ;

}

else if ( ai2 > 2 && ai2 < 7 )

{

raise_amount = 500 ;

limit = 2000 ;

poker :: raise ( ) ;

}

else

{

raise_amount = 800 ;

limit = 5000 ;

poker :: raise ( ) ;

}

}

else if ( ai == 6 )

{

limit = 1000000 ;

raise_amount = 3000 ;

poker :: raise ( ) ;

}

else if ( ai == 10 )

{

poker :: fold ( ) ;

}

else

{

limit = 2100 ;

raise_amount = 900 ;

poker :: raise ( ) ;

}

break ;

/*------------------------------------------------------------------------------

--------------------------------------------------------------------------------

*/

//if it sees a 5

case 5 :

if ( ai == 1 )

{

if ( ai2 == 1 )

{

limit = 3000 ;

raise_amount = 1500 ;

poker :: raise ( ) ;

}

if ( ai2 == 2 )

{

limit = 3000 ;

raise_amount = 1200 ;

poker :: raise ( ) ;

}

}

else if ( ai > 1 && ai < 5 )

{

if ( ai2 = 1 )

{

limit = 2100 ;

raise_amount = 500 ;

poker :: raise ( ) ;

}

else if ( ai2 == 2 )

{

limit = 2100 ;

raise_amount = 700 ;

poker :: raise ( ) ;

}

}

else if ( ai > 5 && ai < 8 )

{

if ( ai2 == 1 )

{

limit = 2100 ;

raise_amount = 700 ;

poker :: raise ( ) ;

}

else if ( ai2 == 2 )

{

limit = 2000 ;

raise_amount = 850 ;

poker :: raise ( ) ;

}

else

{

raise_amount = 500 ;

limit = 3000 ;

poker :: raise ( ) ;

}

}

else if ( ai == 6 )

{

limit = 50000 ;

raise_amount = 4000 ;

poker :: raise ( ) ;

}

else if ( ai == 10 )

{

poker :: fold ( ) ;

}

else

{

limit = 3000 ;

raise_amount = 200 ;

poker :: raise ( ) ;

}

break ;

/*------------------------------------------------------------------------------

--------------------------------------------------------------------------------

*/

//if it sees a 6

case 6 :

if ( ai ! = 6 )

{

if ( ai2 == 1 )

{

limit = 5000 ;

raise_amount = 1000 ;

poker :: raise ( ) ;

}

else if ( ai2 == 2 )

{

limit = 3000 ;

raise_amount = 500 ;

poker :: raise ( ) ;

}

}

if ( ai <= 4 )

{

limit = 3000 ;

if ( ai2 = 1 )

{

limit = 2000 ;

raise_amount = 830 ;

poker :: raise ( ) ;

}

else if ( ai2 == 2 )

{

limit = 3000 ;

raise_amount = 500 ;

poker :: raise ( ) ;

}

}

else if ( ai == 10 )

{

poker :: fold ( ) ;

}

else

{

limit = 3000 ;

raise_amount = 700 ;

poker :: raise ( ) ;

}

break ;

/*------------------------------------------------------------------------------

--------------------------------------------------------------------------------*/

case 7 :

if ( ai == 1 )

{

poker :: fold ( ) ;

}

else if ( ai > 1 && ai < 6 )

{

if ( ai2 == 1 )

{

limit = 2000 ;

raise_amount = 500 ;

poker :: raise ( ) ;

}

else if ( ai2 == 2 )

{

limit = 3000 ;

raise_amount = 700 ;

poker :: raise ( ) ;

}

}

if ( ai == 10 )

{

poker :: fold ( ) ;

}

else if ( ai == 11 )

{

poker :: fold ( ) ;

}

else if ( ai == 6 )

{

limit = 2000 ;

raise_amount = 430 ;

poker :: raise ( ) ;

}

else

{

raise_amount = 1000 ;

limit = 5000 ;

poker :: raise ( ) ;

}

break ;

case 8 :

if ( ai == 6 )

{

limit = 50000 ;

raise_amount = 2000 ;

poker :: raise ( ) ;

}

else if ( ai < 6 && ai > 0 )

{

if ( ai2 == 1 )

{

raise_amount = 3000 ;

limit = 10000 ;

poker :: raise ( ) ;

}

else if ( ai2 == 2 )

{

limit = 2000 ;

raise_amount = 500 ;

poker :: raise ( ) ;

}

else

{

raise_amount = 700 ;

limit = 4000 ;

poker :: raise ( ) ;

}

}

else if ( ai > 6 && ai < 9 )

{

if ( ai2 == 1 )

{

raise_amount == 1000 ;

limit = 3000 ;

poker :: raise ( ) ;

}

else if ( ai2 == 2 )

{

limit = 2300 ;

raise_amount == 650 ;

poker :: raise ( ) ;

}

}

else

{

poker :: fold ( ) ;

}

break ;

//if it sees a nine

case 9 :

if ( ai > 0 && ai < 6 )

{

poker :: fold ( ) ;

}

else if ( ai == 6 )

{

limit = 50000 ;

raise_amount = 3000 ;

poker :: raise ( ) ;

}

else if ( ai > 7 && ai < 10 )

{

if ( ai2 == 1 )

{

limit = 6000 ;

raise_amount = 1000 ;

poker :: raise ( ) ;

}

else if ( ai2 == 2 )

{

limit = 4000 ;

raise_amount == 700 ;

poker :: raise ( ) ;

}

}

if ( ai > 10 && ai < 12 )

{

poker :: fold ( ) ;

}

if ( ai == 12 )

{

limit = 2000 ;

raise_amount == 600 ;

poker :: raise ( ) ;

}

else

{

raise_amount = 1000 ;

limit = 3000 ;

poker :: raise ( ) ;

}

break ;

//if it sees a Q

case 10 :

if ( ai == 5 )

{

limit = 6000 ;

raise_amount = 1000 ;

poker :: raise ( ) ;

}

if ( ai == 6 )

{

limit = 50000 ;

raise_amount = 2000 ;

poker :: raise ( ) ;

}

if ( ai < 5 && ai > 0 )

{

limit = 4000 ;

raise_amount = 500 ;

poker :: raise ( ) ;

}

else

{

raise_amount = 1000 ;

limit = 5000 ;

poker :: raise ( ) ;

}

break ;

//---------------------------------

//king

case 11 :

if ( ai == 5 )

{

limit = 6000 ;

raise_amount = 1000 ;

poker :: raise ( ) ;

}

else if ( ai < 5 )

{

poker :: fold ( ) ;

}

else if ( ai > 5 && ai ! = 6 )

{

limit = 3000 ;

raise_amount = 600 ;

poker :: raise ( ) ;

}

if ( ai == 6 )

{

limit = 50000 ;

raise_amount = 2000 ;

poker :: raise ( ) ;

}

break ;

//----------------------------------

case 12 :

if ( ai == 5 )

{

limit = 6000 ;

raise_amount = 100 ;

poker :: raise ( ) ;

}

if ( ai == 6 )

{

limit = 5000 ;

raise_amount = 200 ;

poker :: raise ( ) ;

}

else

{

limit = 3000 ;

raise_amount = 500 ;

poker :: raise ( ) ;

}

break ;

case 13 :

if ( ai ! = 6 )

{

poker :: fold ( ) ;

}

else

{

if ( ai2 == 1 )

{

raise_amount = 200 ;

limit = 600 ;

poker :: raise ( ) ;

}

else if ( ai = 10 )

{

poker :: fold ( ) ;

}

if ( ai == 6 )

{

limit = 5000 ;

raise_amount = 760 ;

poker :: raise ( ) ;

}

else if ( ai2 == 2 )

{

limit = 3000 ;

raise_amount = 500 ;

poker :: raise ( ) ;

}

else

{

limit = 2000 ;

raise_amount = 500 ;

poker :: raise ( ) ;

}

break ;

}

}

cout << "an error in the ai, card: " << card_rank [ 1 ] << " ai num1: " << ai << " and ai2: " << ai2 ;

system ( "pause" ) ;

}

/*

end of the ai, yes, it does exist

now, the easy part, the game process

I think I might cry at the fact no one will ever see that to its fullest extent, :(

*screams* :()

*sleeps*

;|/|

> | |

;|\|

ok, it was 12:30 in the morning when I did that

but now that is about 13 hours from that I will get back to it

*/

//if the computer raises it goes to this finction

void poker :: raise ( )

{ //1

card_rank [ 1 ] = card_rank [ 1 ] + 1 ;

if ( limit >= raise_amount )

{ //the 1st if (if it can raise that much, in case of a glitch in the ai)

//it notifies you that the computer raised

cout << "



the computer raised " << raise_amount << "

" ;

//does the math

pot = pot + raise_amount ;

//do you want to meet that?

cout << "

would you like to meet the bet of " << raise_amount << " " ;;

cin >> bet_choice ;

//if yes

if ( bet_choice == 'y' )

{ //2nd if begin (did you meet that)

my_money = my_money - raise_amount ;

pot = pot + raise_amount ;

cout << "

would you like to place a bet? " ;

cin >> bet_choice2 ;

}

//if no, you fold

else

{

poker :: fold ( ) ;

}

//if you wanted to bet (see line 921)

if ( bet_choice2 == 'y' )

{

poker :: human_bet_process ( ) ;

}

//if you didnt want to (see line 921)

else

{

find_out ( ) ;

}

}

//if it was over the limit

else

{

cout << "error in the ai (went over cap)" ;

system ( "pause" ) ;

} //final if end

} //function end

//well, are you going to win?

void poker :: find_out ( )

{

//show both cards

cout << "player 1: " ;

poker :: showcards ( ) ;

cout << "player 2: " ;

poker :: showothercards ( ) ;

//if you won

if ( card_rank [ 1 ] > real1 )

{

//the processes

my_money = my_money + pot ;

cout << "player 1 won

you now have " << my_money << "

" ;

pot = 0 ;

system ( "pause" ) ;

system ( "cls" ) ;

game ( ) ;

}

// if it was a tie

else if ( card_rank [ 1 ] == real1 )

{

cout << "

tie

" ;

my_money = my_money + pot / 2 ;

pot = 0 ;

system ( "pause" ) ;

system ( "cls" ) ;

pot = 0 ;

game ( ) ;

}

//if you lost

else

{

cout << "you lost

" ;

system ( "pause" ) ;

system ( "cls" ) ;

pot = 0 ;

game ( ) ;

}

}

//if you folded (option in void raise())

int poker :: human_fold ( )

{

cout << "you have folded

" ;

cout << "you had " ;

poker :: showcards ( ) ;

cout << "

play another? " ;

cin >> choice ;

if ( choice == 'y' )

{

pot = 0 ;

system ( "cls" ) ;

main ( ) ;

}

else

{

return 1 ;

}

}

//this finction process your bet (see void raise())

void poker :: human_bet_process ( )

{

try

{

cout << "how much?: " ;

cin >> human_bet ;

pot = pot + human_bet ;

my_money = my_money - human_bet ;

if ( limit >= human_bet )

{

pot = pot + human_bet ;

poker :: find_out ( ) ;

}

else

{

poker :: fold ( ) ;

}

}

catch ( ... )

{

cout << "an error in human fold has occored" ;

cin >> wait ;

}

}

//if the pc folded

void poker :: fold ( )

{

try

{

cout << "

you have " ;

poker :: showcards ( ) ;

cout << "

the computer has folded, you have won

" ;

my_money = my_money + pot ;

system ( "pause" ) ;

system ( "cls" ) ;

pot = 0 ;

game ( ) ;

}

catch ( ... )

{

cout << "an error has occored in fold" ;

cin >> wait ;

}

}

int poker :: showcards ( )

{

if ( card_rank [ 1 ] == 11 )

cout << "J

" ;

//----------------

else if ( card_rank [ 1 ] == 12 )

cout << "Q

" ;

//----------------

else if ( card_rank [ 1 ] == 13 )

cout << "K

" ;

//----------------

else if ( card_rank [ 1 ] == 14 )

cout << "A

" ;

//----------------

else

cout << card_rank [ 1 ] << "

" ;

}

int poker :: showothercards ( )

{

if ( real1 == 11 )

{

cout << "J

" ;

return 0 ;

}

//----------------

else if ( real1 == 12 )

{

cout << "Q

" ;

return 0 ;

}

//----------------

else if ( real1 == 13 )

{

cout << "Q

" ;

return 0 ;

}

//----------------

else if ( real1 == 14 )

{

cout << "A

" ;

return 0 ;

}

//----------------

else

cout << real1 << "

" ;