First of all im not very experienced coder. I have done different little coding tasks for all my life and i know the basics. This is just project to have fun with.
Im building my own bot and im going to create script language that the program can read and understand (more of this later). This is for easier implementation of different strategies and playing styles and also makes my next step a little easier. First i want to build my own "client" that simulates hands just like in online poker rooms and for each player i can use different scripted gameplay, make them play against each other and find out mistakes and weaknesses. The "client" would write hand history files so Holdem Manager can read it. This simulation would be easiest, fastest and safest way for stage one testing. Now i need help with this "client", there is different ways of doing this but i think my way is not the best and would need some pointers.
I build this "client" with
C++ and i build my deck with a simple string array and store all the cards in it like:
cards[0] = {"Ah"} and so on..
Now this is just the deck where i find the cards that is delt to players and to the table. I have boolean array for delt cards and every time i deal a new card it checks if the card is allready used. Now this works fine until i need to figure out what all players have at showdown. I could have integer array for suits (0 = heart, 1 = diamonds and so on..) but this is where i need help. In what way should i build the deck, deal cards and see what everyone have so it wont get too complicated. I can post parts of my code here if needed.
If i get help and make progress i will post here all my steps and ask for more help. I think this thread would work as a tutorial for other beginners too.
This is the code so far (using c++):
Code:
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main()
{
// CARD DECK
std::string cards[52] = {"Ah","Kh","Qh","Jh","Th","9h","8h","7h","6h","5h","4h","3h","2h",
"Ad","Kd","Qd","Jd","Td","9d","8d","7d","6d","5d","4d","3d","2d",
"Ac","Kc","Qc","Jc","Tc","9c","8c","7c","6c","5c","4c","3c","2c",
"As","Ks","Qs","Js","Ts","9s","8s","7s","6s","5s","4s","3s","2s"};
// USED CARDS (0 = unused, 1 = used)
int used_cards[52] = {0};
std::string player1cards[2];
std::string player2cards[2];
std::string player3cards[2];
std::string player4cards[2];
std::string player5cards[2];
std::string player6cards[2];
std::string boardcards[5];
srand((unsigned)time(0));
cout << endl;
/////////////////////////////////
// MOVE BUTTON AND POST BLINDS //
/////////////////////////////////
// DEALING HOLE CARDS TO PLAYERS
int counter1 = 0;
while (counter1 < 6)
{
cout << "Player" << counter1 + 1 << ": ";
int counter2 = 0;
while (counter2 < 2)
{
int random_card = (rand()%52);
while (used_cards[random_card] == 1)
{
random_card = (rand()%52);
}
if (counter1 == 0)
{
player1cards[counter2] = cards[random_card];
cout << player1cards[counter2] << " ";
}
else if (counter1 == 1)
{
player2cards[counter2] = cards[random_card];
cout << player2cards[counter2] << " ";
}
else if (counter1 == 2)
{
player3cards[counter2] = cards[random_card];
cout << player3cards[counter2] << " ";
}
else if (counter1 == 3)
{
player4cards[counter2] = cards[random_card];
cout << player4cards[counter2] << " ";
}
else if (counter1 == 4)
{
player5cards[counter2] = cards[random_card];
cout << player5cards[counter2] << " ";
}
else if (counter1 == 5)
{
player6cards[counter2] = cards[random_card];
cout << player6cards[counter2] << " ";
}
used_cards[random_card] = 1;
counter2++;
}
cout << endl;
counter1++;
}
/////////////////////
// PREFLOP ACTIONS //
/////////////////////
// DEALING FLOP
cout << endl;
cout << "Board: ";
int counter3 = 0;
while (counter3 < 3)
{
int random_card = (rand()%52);
while (used_cards[random_card] == 1)
{
random_card = (rand()%52);
}
boardcards[counter3] = cards[random_card];
cout << boardcards[counter3] << " ";
used_cards[random_card] = 1;
counter3++;
}
//////////////////
// FLOP ACTIONS //
//////////////////
// DEALING TURN
int random_card = (rand()%52);
while (used_cards[random_card] == 1)
{
random_card = (rand()%52);
}
boardcards[3] = cards[random_card];
cout << boardcards[3] << " ";
used_cards[random_card] = 1;
//////////////////
// TURN ACTIONS //
//////////////////
// DEALING RIVER
random_card = (rand()%52);
while (used_cards[random_card] == 1)
{
random_card = (rand()%52);
}
boardcards[4] = cards[random_card];
cout << boardcards[4] << " ";
used_cards[random_card] = 1;
///////////////////
// RIVER ACTIONS //
///////////////////
///////////////////
// RANKING HANDS //
///////////////////
/////////////////
// PAY WINNERS //
/////////////////
// DEBUGGING
cout << endl;
// CALCULATE USED CARDS
int cards_used = 0;
int counter4 = 0;
while (counter4 < 52)
{
if (used_cards[counter4] == 1)
cards_used++;
counter4++;
}
cout << endl;
cout << "Used cards (0 = unused, 1 = used): " << cards_used << endl;
// PRINTING ALL USED AND UNUSED CARDS
int counter5 = 0;
while (counter5 < 52)
{
cout << "Card " << counter5 + 1 << ": " << used_cards[counter5] << " (" << cards[counter5] << ")" << endl;
counter5++;
}
return 0;
}