Poker-AI.org Poker AI and Botting Discussion Forum 2013-08-31T11:09:00+00:00 http://poker-ai.org/phpbb/feed.php?f=26&t=2563 2013-08-31T11:09:00+00:00 2013-08-31T11:09:00+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2563&p=4774#p4774 <![CDATA[Re: Building my first Bot (please help)]]> Statistics: Posted by TheCrow — Sat Aug 31, 2013 11:09 am


]]>
2013-08-30T21:15:49+00:00 2013-08-30T21:15:49+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2563&p=4769#p4769 <![CDATA[Re: Building my first Bot (please help)]]> spears wrote:

I don't hold with the idea of a scripting language myself, but you really insist, you might consider taking inspiration from open holdem, or just using it outright.


I am using OpenHoldem, but the only scripts that i use are the ones that calls my dll functions.
All the AI code it's written with C++ and C#, and it's working pretty good.
Also evaluators are externals, databases, etc...

Statistics: Posted by shadehs — Fri Aug 30, 2013 9:15 pm


]]>
2013-08-30T21:01:25+00:00 2013-08-30T21:01:25+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2563&p=4768#p4768 <![CDATA[Re: Building my first Bot (please help)]]> Statistics: Posted by TheCrow — Fri Aug 30, 2013 9:01 pm


]]>
2013-08-30T20:49:15+00:00 2013-08-30T20:49:15+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2563&p=4766#p4766 <![CDATA[Re: Building my first Bot (please help)]]>
I don't hold with the idea of a scripting language myself, but you really insist, you might consider taking inspiration from open holdem, or just using it outright.

Statistics: Posted by spears — Fri Aug 30, 2013 8:49 pm


]]>
2013-08-30T20:32:57+00:00 2013-08-30T20:32:57+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2563&p=4765#p4765 <![CDATA[Re: Building my first Bot (please help)]]> spears wrote:

There are lots of good evaluators already available.


true

http://www.codingthewheel.com/archives/ ... r-roundup/

I have spent about a week writing my own evaluator, this was before I knew poker-ai. I was happy about every little improvement in speed, but in the end it was still 1000 times slower than Pokerstove. There are ideas, like LUTs, that you usually dont think of, when you just start writing an algorithm, that makes sense intuivelly.

The speed of the evaluator might not be that crucial for your cleint, you will only need it once per hand to see who won, but you will need a fast one for your bot anyway.

Statistics: Posted by HontoNiBaka — Fri Aug 30, 2013 8:32 pm


]]>
2013-08-30T20:25:39+00:00 2013-08-30T20:25:39+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2563&p=4764#p4764 <![CDATA[Re: Building my first Bot (please help)]]> Statistics: Posted by spears — Fri Aug 30, 2013 8:25 pm


]]>
2013-08-30T20:04:59+00:00 2013-08-30T20:04:59+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2563&p=4763#p4763 <![CDATA[Re: Building my first Bot (please help)]]>
I need the strings anyway for log files and i have started my hand evaluation code already and its tricky but i think i can do it. Straights are pain in the ass at the moment. Reason i post this here is to get help to optimize my code and people to throw red flags if im doing something wrong.

Here is the functions for defining cards from strings:
Code:
int cardstrenght(std::string card)
{
   int strenght;
   if ((card == "Ah") || (card == "Ad") || (card == "Ac") || (card == "As"))
      strenght = 14;
   if ((card == "Kh") || (card == "Kd") || (card == "Kc") || (card == "Ks"))
      strenght = 13;
   if ((card == "Qh") || (card == "Qd") || (card == "Qc") || (card == "Qs"))
      strenght = 12;
   if ((card == "Jh") || (card == "Jd") || (card == "Jc") || (card == "Js"))
      strenght = 11;
   if ((card == "Th") || (card == "Td") || (card == "Tc") || (card == "Ts"))
      strenght = 10;
   if ((card == "9h") || (card == "9d") || (card == "9c") || (card == "9s"))
      strenght = 9;
   if ((card == "8h") || (card == "8d") || (card == "8c") || (card == "8s"))
      strenght = 8;
   if ((card == "7h") || (card == "7d") || (card == "7c") || (card == "7s"))
      strenght = 7;
   if ((card == "6h") || (card == "6d") || (card == "6c") || (card == "6s"))
      strenght = 6;
   if ((card == "5h") || (card == "5d") || (card == "5c") || (card == "5s"))
      strenght = 5;
   if ((card == "4h") || (card == "4d") || (card == "4c") || (card == "4s"))
      strenght = 4;
   if ((card == "3h") || (card == "3d") || (card == "3c") || (card == "3s"))
      strenght = 3;
   if ((card == "2h") || (card == "2d") || (card == "2c") || (card == "2s"))
      strenght = 2;
   return strenght;
}

int cardsuit(std::string card)
{
   int suit;
   if ((card == "Ah") || (card == "Kh") || (card == "Qh") || (card == "Jh") || (card == "Th") || (card == "9h") || (card == "8h") || (card == "7h") || (card == "6h") || (card == "5h") || (card == "4h") || (card == "3h") || (card == "2h"))
      suit = 1;
   if ((card == "Ad") || (card == "Kd") || (card == "Qd") || (card == "Jd") || (card == "Td") || (card == "9d") || (card == "8d") || (card == "7d") || (card == "6d") || (card == "5d") || (card == "4d") || (card == "3d") || (card == "2d"))
      suit = 2;
   if ((card == "Ac") || (card == "Kc") || (card == "Qc") || (card == "Jc") || (card == "Tc") || (card == "9c") || (card == "8c") || (card == "7c") || (card == "6c") || (card == "5c") || (card == "4c") || (card == "3c") || (card == "2c"))
      suit = 3;
   if ((card == "As") || (card == "Ks") || (card == "Qs") || (card == "Js") || (card == "Ts") || (card == "9s") || (card == "8s") || (card == "7s") || (card == "6s") || (card == "5s") || (card == "4s") || (card == "3s") || (card == "2s"))
      suit = 4;
   return suit;
}

Statistics: Posted by TheCrow — Fri Aug 30, 2013 8:04 pm


]]>
2013-08-30T18:17:32+00:00 2013-08-30T18:17:32+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2563&p=4760#p4760 <![CDATA[Re: Building my first Bot (please help)]]>
Of course this isnt a big issue, but if you want to test millions of hands in bot vs bot matches to get a good samplesize, it might help a little.

Statistics: Posted by HontoNiBaka — Fri Aug 30, 2013 6:17 pm


]]>
2013-08-27T18:47:30+00:00 2013-08-27T18:47:30+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2563&p=4728#p4728 <![CDATA[Re: Building my first Bot (please help)]]> shadehs wrote:

Maybe you should consider to open a GitHub repository and post the code there, and only the documentation and your thought here.

Thats a new for me. Have to take a look.

Statistics: Posted by TheCrow — Tue Aug 27, 2013 6:47 pm


]]>
2013-08-27T15:06:52+00:00 2013-08-27T15:06:52+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2563&p=4725#p4725 <![CDATA[Re: Building my first Bot (please help)]]> Statistics: Posted by shadehs — Tue Aug 27, 2013 3:06 pm


]]>
2013-08-26T21:54:35+00:00 2013-08-26T21:54:35+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2563&p=4719#p4719 <![CDATA[Re: Building my first Bot (please help)]]>
Here is the code:
* in first topic *

Statistics: Posted by TheCrow — Mon Aug 26, 2013 9:54 pm


]]>
2013-08-26T22:44:27+00:00 2013-08-26T21:29:54+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2563&p=4718#p4718 <![CDATA[Re: Building my first Bot (please help)]]>
Here is the code:
* in first topic *

Statistics: Posted by TheCrow — Mon Aug 26, 2013 9:29 pm


]]>
2013-08-26T22:43:51+00:00 2013-08-26T14:56:46+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2563&p=4709#p4709 <![CDATA[Building my first Bot (please help)]]>
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;
}

Statistics: Posted by TheCrow — Mon Aug 26, 2013 2:56 pm


]]>