2. short int pot_money[7][5][500]={0}; /* [TEAM
NUMBER][STAGE][ROUND] */
short int players_hand_card_1[7]; /* [TEAM NUMBER] */
short int players_hand_card_2[7]; /* [TEAM NUMBER] */
short int river_cards[5],r_count=0; /* [STAGE] */
short int player_p_values[7][5]; /* [TEAM NUMBER][STAGE] */
short int checkPattern[6][5][4][3][7] ={0}; /*
[PVALUE][ACTION][REACTION][STAGE][TEAMNUMBER] */
int round_number[5]; /* [STAGE] */
int p_ratio[6]; /* [PVALUE] */
int reaction_ratio[5]; /* [REACTION] */
bool players_folded[7]; /* [TEAM NUMBER] */
short int number_of_folds; /* Stores the Number of
Folds */
short int play_mode; /* 1 :: OFFENSIVE | 2 ::
DEFENSIVE | 3 :: ULTRA DEFENSIVE */
short int number_of_deals; /* Stores the Number of
Deals */
player players[7];
int deal_number; /* Represents the
nth deal */
bool is_show_down; /* Tells if its Show
Down or not */
bool stagePlayed[6]={0}; /* Bool of Stages Played */
bool playersEliminated[7]; /* [TEAM NUMBER] */
short int num_players_eliminated = 0;
void printPlayerDetails(player p);
void read_file(char *name,char *data);
int getInt(char *data);
int decode_input_file(char *data);
int decode_dealsMoney(char *data);
void getString(char *str,char *data);
int decode_dealFile(char *data,int *stage,int *main_pot);
void read_showDown_handCards(char *data);
void get_current_state_players(char *data,int stage,int self_teamNumber,int dealer);
void set_play_mode(int self_team_number);
int defensive_play(int stage,int *all_cards,int n_total_cards,int self_team_number,int dealer);
bool is_bluffsMore(short int team_number);
int get_minimum_raise(short int stage,short int team_number,short int dealer);
short int get_rank(int self_team_number);
void set_p_ratio();
void set_reaction_ratio();
void set_player_folded();
bool is_FirstTurn(short int dealer, short int self_team_number);
short int checkPattern_p(int action,int reaction, int stage ,int team,int detail);
short int checkPattern_action(int p_value,int action,int reaction, int stage ,int team,int detail);
int catagorize_move(int p_move);
void analyze_data(int self_teamNumber,int dealer);
int offensive(int stage,int *cards,int total,int teamno,int dealer);
int getMove(int stage,int phand,int *team,int teamno,int dealer);
3. int bluff(int rise, int limit);
int lowraise(int bet);
int compare (const void * a, const void * b);
int pcounter(int *cards,int hand,int total);
int highcard(int *hole,int hand);
int pairs(int *cards,int *allpairs,int total);
int twoofakind(int *allpairs,int paircards,int *hole,int hand);
int twopair(int *allpairs,int paircards,int *hole,int hand);
int threeofakind(int *allpairs,int paircards,int *cards,int total,int *hole , int hand);
int straight(int *cards,int total,int *hole,int hand);
int flush(int *cards,int total,int *hole,int hand);
int fullhouse(int *allpairs,int paircards,int *cards,int total,int *hole , int hand );
int fourofakind(int *allpairs,int paircards,int *hole,int hand);
int striaghtflush(int *cards,int total,int *hole,int hand);
int priver(int*cards,int hand,int total);
int pgrader(int probab , int stage);
int ppreflop(int hand1,int hand2);
int pfuture(int *cards,int total);
int futurestraight(int *cards,int total);
int futureflush(int *cards, int total);
int overallp(int*cards,int total,int stage);
void start_deal(char *data,int self_teamNumber,int *players_left);
int anyoppraisehigh(int stage,int round,int firstplayer,int myteamno,int dealer);
void printPlayerDetails(player p)
{
cout << "n Hand 1 = " << p.handCard1;
cout << "n Hand 2 = " << p.handCard2;
cout << "n Team Number = " << p.team;
cout << "n Current Round Bet = " << p.bet;
}
void read_file(char *name,char *data)
{
FILE *file;
file = fopen(name, "rb");
fread(data,1000,1,file);
fclose(file);
}
char *ptr;
char *ptr_startReading;
int getInt(char *data)
{
int temp=0;
while(*ptr < '0' || *ptr > '9' )
ptr++;
while(*ptr >= '0' && *ptr <= '9')
{
temp = temp*10 + (*ptr - '0');
9. cout << "nStage = " <<stage << " t_round = " << t_round;
round_number[stage]=t_round;
fout_river.close();
//getch();
return ;
}
void set_play_mode(int self_team_number)
{
int money_total=0;
for(int xx=1;xx<=6;xx++)
money_total=money_total+players[xx].money_remaining;
int mean= money_total/(6-num_players_eliminated);
cout << "nMean Money = " << mean << "n2/3rd of Mean = " <<(2*mean)/3 << "nRank = "
<< get_rank(self_team_number);
if(players[self_team_number].money_remaining >=500 && ((get_rank(self_team_number)
<=(2*(6-num_players_eliminated))/3) || num_players_eliminated >=3))
play_mode = OFFENSIVE;
else
play_mode = DEFENSIVE;
cout << "nPlay Mode = "<<play_mode;
//getch();
/* SET BRUTEFORE play_mode - Until Rank is Top 3 or until Money doesnt go below 500 or
800 deals */
// Remove the Comments below to Activate Ultra Defensive modee //
/*
play_mode = ULTRA_DEFENSIVE;
if(get_rank(self_team_number) <=3 || players[self_team_number].money_remaining <=
500 || deal_number >= 800)
play_mode = OFFENSIVE;
*/
}
/*
stage = The current Stage
all_cards = All cards including hand card and river Card. (First two Cards as Hand Cards
n_total_cards = Total Number of Cards = River Cards + 2 Hand Cards
self_team_number = The team number who has to return a Reply
dealer = the dealer for the current deal
*/
int defensive_play(int stage,int *all_cards,int n_total_cards,int self_team_number,int dealer)
{
/* An array that stores all the Cards , including Hand Cards (as 1st 2 cards) & and River Cards
to call "overallp" function */
10. /*static int all_cards[7]; */
/*all_cards[0] = players_hand_card_1[self_team_number]; */
/*all_cards[1] = players_hand_card_2[self_team_number]; */
/*for(int xx = 2;xx < 2+n_river_cards;xx++) */
/* all_cards[xx] = river_cards[xx-2]; */
int p_hand = overallp(all_cards, n_total_cards, stage);
if(!(p_hand == VERY_GOOD || p_hand == GOOD)) /* The Case of Fold */
return -10;/*fold*/
return offensive(stage,all_cards,n_total_cards,self_team_number,dealer);
}
/* Returns true or 1 if the player bluffs atleast twice as more else false oe 0 */
bool is_bluffsMore(short int team_number)
{
int rise_counter=1;
int bluff_counter=1;
for(int xx = 1;xx<=6;xx++)
for(int yy = 1;yy<5;yy++)
for(int zz=1;zz<=round_number[yy];zz++)
{
if(players_data_move[xx][yy][zz] == RISE)
rise_counter++;
if(players_data_move[xx][yy][zz] == BLUFF)
bluff_counter++;
}
if(rise_counter*2 <= bluff_counter)
return true;
else
return false;
}
int get_minimum_raise(short int stage,short int team_number,short int dealer)
{
if(stage == 5)
return 0;
int cur_round=round_number[stage];
int cur_player=team_number-1;
int cur_stage = stage;
cout << "nStart Round = " << cur_round;
while(cur_round >= 0)
{
if(cur_player == 0)cur_player=6;
if(cur_player == dealer)cur_round--;
if(cur_round == 0)
{
cur_stage--;
cur_round=round_number[cur_stage];
}
11. cout << "nCur Player = " << cur_player << " cur_stage = " << cur_stage << "
cur_round = " <<cur_round;
cout << "nPot Money = " << pot_money[cur_player][cur_stage][cur_round];
cout << "nRaise = " << (players_data_bet[cur_player][cur_stage][cur_round]-
pot_money[cur_player][cur_stage][cur_round]);
cout << "nRise Amounts = " <<
players_data_bet[cur_player][cur_stage][cur_round];
if(players_data_move[cur_player][cur_stage][cur_round] == RISE)
{
cout << "nFinally Rise = " <<
players_data_bet[cur_player][cur_stage][cur_round]-
pot_money[cur_player][cur_stage][cur_round];
if(players_data_bet[cur_player][cur_stage][cur_round]-
pot_money[cur_player][cur_stage][cur_round] == 0 ||
players_data_bet[cur_player][cur_stage][cur_round]-pot_money[cur_player][cur_stage][cur_round]
== 5)
return 10;
//getch();
return (players_data_bet[cur_player][cur_stage][cur_round]-
pot_money[cur_player][cur_stage][cur_round]);
}
cur_player--;
}
return 0;
}
/* Returns your rank on calling */
short int get_rank(int self_team_number)
{
short int rank=6;
for(int xx = 1;xx<=6;xx++)
{
if(xx == self_team_number)
continue;
if(players[xx].money_remaining <=players[self_team_number].money_remaining)
rank--;
}
return rank;
}
/* Sets the value of all elements in Array p_ratio as 0 */
void set_p_ratio()
{
for (int xx=0;xx<6; xx++)
p_ratio[xx]=0;
}
/* Sets the value of all elements in Array reaction_ratio as 0 */
void set_reaction_ratio()
12. {
for (int xx=0;xx<=4; xx++)
reaction_ratio[xx]=0;
}
/* Sets the value of all elements in Array players_folded as false */
void set_player_folded()
{
for(int xx=1;xx<=6;xx++)
players_folded[xx] = false;
}
/* Returns 1 or "true" , if our first turn, else returns 0 or "false" */
bool is_FirstTurn(short int dealer, short int self_team_number)
{
int s_pos = dealer+1;
while(s_pos != self_team_number && !(s_pos == 7 && self_team_number == 1))
{
if(s_pos == 7)
s_pos = 1;
if(players_folded[s_pos] == false)
return false;
s_pos++;
}
return true;
}
/* Function Returns the p_value */
/* VERY_GOOD 5 */
/* GOOD 4 */
/* AVG 3 */
/* BAD 2 */
/* VERY_BAD 1 */
short int checkPattern_p(int action,int reaction, int stage ,int team,int detail = LOW)
{
/* Action :: What the other opponent Do */
/* Reaction :: What this team does for the given action */
/* Stage :: Stage for which data is required */
/* Team :: Team number for which the data is required */
/* Detail :: How much deatil to check the Patter */
/* HIGH - Check exact match */
/* LOW - Ignore Stage */
/* Set p_ratio array as 0 */
set_p_ratio();
/* Declare the Array to store CheckPattern */
short int max;
13. /* Read the CheckPattern File and save it in the Array */
FILE *file;
file = fopen(CHECKPATTERN_FILE,"rb");
if(file != NULL)
{
fread(checkPattern,sizeof(int)*6*5*4*3*7,1,file);
fclose(file);
}
if (detail == LOW)
{
max = 0;
for(int xx = 1;xx<=5;xx++) /* For What P Value */
{
p_ratio[xx] = checkPattern[xx][action][reaction][stage][team];
if(checkPattern[max][action][reaction][stage][team] <=
checkPattern[xx][action][reaction][stage][team])
max = xx;
}
return max;
}
else
{
max = 0;
for(int xx=1; xx<=5; xx++) /* For What P-Value */
for(int zz = 0; zz < 4;zz++) /* For Any Stage */
{
p_ratio[xx] = checkPattern[xx][action][reaction][zz][team];
if(checkPattern[max][action][reaction][zz][team] <=
checkPattern[xx][action][reaction][zz][team])
max = xx;
}
return max;
}
}
/* Function Returns an Action */
/* RISE :: 3 */
/* FOLD :: 2 */
/* CALL :: 1 */
/* BLUFF :: 4 */
/* It is based on priority */
short int checkPattern_action(int p_value,int action, int stage ,int team,int detail = LOW)
{
/* p_value :: P_Value for which the reaction is reqd */
/* Action :: What the other opponent Do */
/* Reaction :: What this team does for the given action */
/* Stage :: Stage for which data is required */
/* Team :: Team number for which the data is required */
14. /* Detail :: How much deatil to check the Patter */
/* HIGH - Check exact match */
/* LOW - Ignore Stage */
/* Declare the Array to store CheckPattern */
/* Set p_ratio array as 0 */
set_reaction_ratio();
short int max;
/* Read the CheckPattern File and save it in the Array */
FILE *file;
file = fopen(CHECKPATTERN_FILE,"rb");
if(file!=NULL)
{
fread(checkPattern,sizeof(int)*6*5*4*3*7,1,file);
fclose(file);
}
if (detail == LOW)
{
max = 0;
for(int xx = 0;xx<4;xx++) /* For What Reaction */
{
reaction_ratio[xx] = checkPattern[p_value][action][xx][stage][team];
if(checkPattern[p_value][action][max][stage][team] <=
checkPattern[p_value][action][xx][stage][team])
max = xx;
}
return max;
}
else
{
max = 0;
for(int xx=1; xx<=5; xx++) /* For What Reaction */
for(int zz = 1; zz <= 5;zz++) /* For Any Value of P */
{
reaction_ratio[xx] = checkPattern[p_value][action][xx][zz][team];
if(checkPattern[zz][action][max][stage][team] <=
checkPattern[p_value][action][xx][zz][team])
max = xx;
}
return max;
}
}
int catagorize_move(int p_move)
{
15. /* KEY INDEX */
/* RISE :: 3 */
/* FOLD :: 2 */
/* CALL :: 1 */
/* BLUFF :: 4 */
if(p_move == CALL)
return 1;
if(p_move == FOLD)
return 2;
if(p_move == BLUFF)
return 4;
if(p_move == RISE)
return 3;
return 0; /* For error */
}
void analyze_data(int self_team_number,int dealer)
{
/*cout << "n";
for (int xx = 1;xx<=6;xx++)
{
cout <<xx<<" - " << players_hand_card_1[xx];
cout <<" " << players_hand_card_2[xx];
cout << "n";
}*/
r_count=0;
string file_name = "team" ;
string temp_file;
string t_str;
ifstream fin;
ifstream file1;
ifstream file2;
/* Order for Check Pattern :: PValue - Action - Reaction - Stage -Team Number */
//int cumulative_round_count=0;
int stage =1,max_stage;
int move;
int counter;
number_of_folds=0;
/* Get all the Data from the Help Files into the two arrays declared above */
/* Read the CheckPattern File */
cout << "nCheck Pattern Read Start";
FILE *file;
file = fopen(CHECKPATTERN_FILE,"rb");
if(file != NULL)
16. {
fread(checkPattern,sizeof(int)*6*5*4*3*7,1,file);
fclose(file);
}
//cout << "nCHECKPATTERN = " << checkPattern[2][2][2][2][2];
cout << "n Check Pattern read complete";
/* Read all the river Cards from the Help Files */
fin.open(RIVER_CARDS,ios::in);
fin >> t_str;
cout << "nRiver Card Read Start";
while(!fin.eof())
{
river_cards[r_count++]=atoi(t_str.c_str());
fin >>t_str;
}
fin.close();
cout << "nRiver Card read completenRIVER CARDS :: ";
for(int mm=0;mm<r_count;mm++)
cout << river_cards[mm] << " ";
/* This File contains the number of rounds played at each stage in the current Deal */
fin.open("Round_Counts.txt",ios::in);
/* Set player_folded array to False */
set_player_folded();
number_of_folds=0;
/* Read all the Round Counts to an Array */
fin >> t_str;
//round_number[stage++]=atoi(t_str.c_str());
while (!fin.eof())
{
round_number[stage++]=atoi(t_str.c_str());
fin >>t_str;
}
fin.close();
cout << "n Read Round Numbers complete, stage = " << stage << "n ROUND NUMBERS :: ";
for(int mm=1;mm<stage;mm++)
cout << round_number[mm] << " ";
max_stage = stage;
//cout << "nSTAGE = " << stage;
/* Read all the opponent moves and Bets from Help Files */
/*for(int xx = 1,yy=0;xx<=6;xx++)
{
stage=0;
//cumulative_round_count = 0;
counter = round_number[stage];
temp_file = (char)(xx + 48);
file1.open((string)(file_name + "_move.txt"),ios::in);
file2.open((string)(file_name + "_bet.txt"),ios::in);
17. yy = 0;
while(!file1.eof())
{
file1 >> players_data_move[xx][round_number[stage]-counter][yy];
if(players_data_move[xx][round_number[stage]-counter][yy] == FOLD)
{
players_folded[xx]= true;
number_of_folds++;
}
file2 >> players_data_bet[xx][round_number[stage]-counter][yy];
counter--;
if(counter == 0)
{
yy=0;
//cumulative_round_count = cumulative_round_count + round_number[stage];
stage++;
counter = round_number[stage];
}
yy++;
}
file1.close();
file2 >> players_hand_card_1[xx];
file2 >> players_hand_card_2[xx];
file2.close();
stage++;
}
*/
for(int xx = 1;xx<=6;xx++)
{for(int yy = 1;yy<5;yy++)
{for(int zz=1;zz<=round_number[yy];zz++)
{if(players_data_move[xx][yy][zz] == FOLD)
{
players_folded[xx]=true;
number_of_folds++;
}}}}
cout << "nAnalyze Fold Data Complete";
for(int xx=1;xx<=6;xx++)
cout << xx<<":"<<players_folded[xx] << " ";
players_hand_card_1[self_team_number] = players[self_team_number].handCard1;
players_hand_card_2[self_team_number] = players[self_team_number].handCard2;
//getch();
//cout << "nWILL IT GO THERE ? :O ";
if(is_show_down == false)/* If the Stage is not ShowDown , we dont have to analyze the
Data. Just store them in Arrays */
return ;
stage = 5;
//cout << "nCOMES HERE!!!! :D ";
/* Calculate the P-Values of each player at every round */
// int preflop_river_cards[5];//Can use this array for sending to the p_value Function //
int all_cards[7];
18. for(int yy = 2;yy < 2+r_count;yy++)
all_cards[yy] = river_cards[yy-2];
cout << "nCalculating All P Values Started";
for(int xx = 1; xx<=6 ; xx++)
{
all_cards[0] = players_hand_card_1[xx];
all_cards[1] = players_hand_card_2[xx];
/* Preflop */
//if(max_stage >= 1)
player_p_values[xx][1] = overallp(all_cards,2,1);
//cout << "n Calculated First pValue";
/* Flop */
//if(max_stage >= 2)
if(stagePlayed[2] == true)
player_p_values[xx][2] = overallp(all_cards,5,2);
//cout << "n Calculated Second pValue";
/* Fourth Street */
//if(max_stage >= 3)
if(stagePlayed[3] == true)
player_p_values[xx][3] = overallp(all_cards,6,3);
//cout << "n Calculated Third pValue";
/* Fifth Street */
//if(max_stage >= 4)
if(stagePlayed[4] == true)
player_p_values[xx][4] = overallp(all_cards,7,4);
//cout << "n Calculated Fourth pValue";
}
/* All data has now been stored in the required arrays */
cout << "nAll PValues Calculated";
for(int xx=1;xx<=6;xx++)
{
cout << "nPlayer - " << xx << "n";
for(int yy=1;yy<=4;yy++)
cout << player_p_values[xx][yy] << " ";
}
//getch();
/* Start analyzing from the Dealer */
int current_round = 0;
int number_of_rise = 0;
int number_of_call = 0;
int number_of_fold = 0;
/* Loop to Analyze the Data Stored in all Array */
int loop_counter = 0; /* Counter for position in current Round */
19. int loop_stage = 0; /* Counter for Current Stage */
int loop_start = dealer+3; /* Counter for Player Number */
int loop_pot_money = 10; /* Stores the Money in Pot for the Current Stage */
int player_bet;
int player_move;
bool isBluff; /* 1-Bluff 0-Not Bluff */
int player_action = (int)'A'; /* What other player did, based on priority */
while(loop_stage != 5)
{
if(loop_start >= 7)
loop_start = loop_start-6;
if(loop_start == dealer+1)
loop_counter++;
if(loop_counter == round_number[loop_stage]) /* Stage Over */
{
loop_stage++;
loop_counter=0;
loop_pot_money = 0;
player_action = (int)'A';
}
player_bet = players_data_bet[loop_start][loop_stage][loop_counter] -
loop_pot_money;
pot_money[loop_start][loop_stage][loop_counter] = loop_pot_money;
if(player_bet <=0)
player_bet = 0;
loop_pot_money = loop_pot_money + player_bet;
player_move = players_data_move[loop_start][loop_stage][loop_counter];
if(player_move > player_action && player_action != FOLDED)
player_action = player_move;
if(player_bet != 0 && (player_p_values[loop_start][loop_stage] == BAD ||
player_p_values[loop_start][loop_stage] == VERY_BAD || player_p_values[loop_start][loop_stage]
== AVG))
{
isBluff = true;
player_move = BLUFF;
}
else
isBluff = false;
checkPattern[player_p_values[loop_start][loop_stage]][catagorize_move(player_action)][ca
tagorize_move(player_move)][loop_stage][loop_start]++;
if(player_move == BLUFF)
checkPattern[player_p_values[loop_start][loop_stage]][catagorize_move(player_action)][RI
SE][loop_stage][loop_start]++;
loop_start++;
}
/* Write The CheckPattern back to File */
cout << "nWRITE CHECKPATTERN FILE STARTED!";
file = fopen(CHECKPATTERN_FILE,"wb");
20. fwrite(checkPattern,sizeof(int)*6*5*4*3*7,1,file);
fclose(file);
cout << "nWRITE COMPLETE";
remove("bluff.txt");
//getch();
}
/* this fnctn shud be called when need to play offensive and it will return the amount of bet */
int offensive(int stage,int *cards,int total,int teamno,int dealer)
{
/* initialize random seed: */
/* initialization for rand function */
srand ( time(NULL) );
int phand,rise = get_minimum_raise(stage,teamno,dealer);/* rise = minimum available raise
*/
phand = overallp(cards,total,stage);
cout << "nP Hand = " << phand;
//getch();
int temp = is_FirstTurn(dealer,teamno);/* checking for first turn */
//cout << "n First Turn True/False = " << temp;
if(temp == 0)/* opponent raised or called */
{
/* is p vgud */
if(phand == 5)
{
int check = anyoppraisehigh(stage,round_number[stage],dealer +
1,teamno,dealer);/* check if opp raised high */
if(check == 1)
{
/* check stage */
if(stage == 1)
{
int choice = rand() % 4 + 1;
if((choice == 1)||(choice == 2)||(choice == 3))
return 0;/* call */
else
{
/* high raise fnctn */
int bet = bluff(rise,4);/* 4 for high raise fnctn */
return bet;
}
}
else if(stage == 2)
{
int choice = rand() % 4 + 1;
if((choice == 1)||(choice ==2))
{
21. /* high raise fnctn */
int bet = bluff(rise,4);
return bet;
}
else
return 0;
}
else if(stage == 3)
{
int choice = rand() % 4 + 1;
if(choice ==1)
return 0;
else
{
int bet = bluff(rise,4);/*high raise fnctn*/
return bet;
}
}
else/*last stage */
{
/* high raise fntn */
int bet = bluff(rise,4);
return bet;
}
}
else/* low raise or call */
{
/* stage check */
if(stage == 4)
{
/* high raise fnctn */
int bet = bluff(rise,4);
return bet;
}
else if(round_number[stage] == 1)/*new card opened */
{
int choice = rand() % 2 + 1;
if(choice == 1)
return 0;/* call */
else
{
int bet = bluff(rise,4);
return bet;
}
/* high raise fntn */
}
else/*no new card */
{
FILE *pt;
int bluffcounter = 4;
22. pt = fopen("bluff.txt","rb");
if(pt != NULL)/* prev raise */
{
fscanf(pt,"%d",&bluffcounter);
fclose(pt);
if(bluffcounter <4)
{
int bet = bluff(rise,4);
return bet;
}
}
else
{
int choice = rand() % 2 +1;
if(choice == 1)
return 0;/* call */
else
{
/* high raise fntn */
int bet = bluff(rise,4);
return bet;
}
}
}
}
}
/* p is gud */
if(phand == 4)
{
//cout << "n Case of Pgood";
int value=1;
int check = anyoppraisehigh(stage,round_number[stage],dealer +
1,teamno,dealer);/* check if opp raised high */
//cout << "nDid Any opponent Raise High? " << check;
if(check == 1)
{
int temp = teamno-1;
int cur_round = round_number[stage];
do
{
if(temp == 0)
temp = 6;
if(temp == dealer)
cur_round--;
if(cur_round <=0)
{value = 0;break;}
if(players_data_move[temp][stage][cur_round] == RISE)
{
23. int rise = players_data_bet[temp][stage][cur_round]
- pot_money[temp][stage][cur_round];
if(rise > 50)
{
int faltu;
faltu = is_bluffsMore(temp);
if(faltu==0)
value = faltu;
}
}
temp--;
}while(temp != teamno);
if(value == 0)
{
int pla = 6 - number_of_folds;/* gets no of players playing
on the table */
if(pla <= 3)/* check pattern fntn */
{
int zz=dealer+1;
int ppos=0;
int still_in_play[3]={0};
do
{
if(zz==7)
zz=1;
if(players_folded[zz] == false)
still_in_play[ppos++]=zz;
zz++;
}while(zz != dealer && !(zz==7 && dealer==1));
if(ppos==2)
{still_in_play[ppos++]=0;}
return
getMove(stage,phand,still_in_play,teamno,dealer);
}
else
{
int count = 0;
int temp=teamno-1;
int still_in_play[3]={0};
int zz=0;
int cur_round = round_number[stage];
do
{
int value;
if(temp==0)
temp = 6;
if(temp == dealer)
24. cur_round--;
if(cur_round <=0)
break;
if((players_data_move[temp][stage][cur_round] ==
CALL)&&(players_data_bet[temp][stage][cur_round] - pot_money[temp][stage][cur_round] > 50))
value = is_bluffsMore(temp);
if(value == 0)
{
count++;
still_in_play[zz++]=temp;
}
temp--;
}while(temp!=teamno);
still_in_play[zz++]=teamno;
if(zz==3)
{still_in_play[zz++]=0;}
pla = count; /* no of players who raises high and
doesn;t bluff */
if(pla <= 2)
return
getMove(stage,phand,still_in_play,teamno,dealer);
else /* check pattern */
{
int choice = rand() % 2 + 1;
if(choice == 1)
return 0;
else
return -10;/* fold */
}
}
}
else/* means opponent bluffs a lot */
{
int players = 6 - number_of_folds;/* no of players playing at
the table */
if(players <= 3)
{
int zz=dealer+1;
int ppos=0;
int still_in_play[3]={0};
do
{
if(zz==7)
zz=1;
if(players_folded[zz] == false)
still_in_play[ppos++]=zz;
zz++;
}while(zz != dealer && !(zz==7 && dealer==1));
if(ppos==2)
25. {still_in_play[ppos++]=0;}
return
getMove(stage,phand,still_in_play,teamno,dealer);
/* check pattern */
}
else
{
return 0;/*call*/
}
}
}
else /* low call or call*/
{
int players = 6 - number_of_folds;/* no of players laying at the table
*/
//cout << "nReached the case of chek = 0, players = "<<players;
if(players <= 3) /*-----------editing left-----------*/
{
int zz=dealer+1;
int ppos=0;
int still_in_play[3]={0};
do
{
if(zz==7)
zz=1;
if(players_folded[zz] == false)
still_in_play[ppos++]=zz;
zz++;
}while(zz != dealer && !(zz==7 && dealer==1));
if(ppos==2)
{still_in_play[ppos++]=0;}
return getMove(stage,phand,still_in_play,teamno,dealer);
/* check pattern */
}
else
{
cout << "nPlayers Greater than 3";
int lowcheck=0,count=0;
int temp = teamno-1;
if(temp == 0 )
temp = 6;
int still_in_play[7]={0};
int zz =0;
int cur_round = round_number[stage];
cout << "ncur_round = " << cur_round;
do
{
if(temp == 0)