http://www.perlmonks.org?node_id=1056613

bennierounder has asked for the wisdom of the Perl Monks concerning the following question:

Hi guys,

Not been around much lately and I haven't really done much programming for a while. Only a beginner anyway.

I am wanting to build myself a poker bot that can make decisions based on the way I play.

I have an idea of what I will do, but I have never even tried datamining before and do not know how to do it.

I figured by changing my settings to allow dealer chat to be included in the chat window that I could simply grab this info. I'm on ipoker bet365.

I want to read the chat box (using regular expressions to pick the bits I want) and then send the data to a database somehow. The dealer chat contains all the information I need to make a decision. The problem I have is getting the data from the ipoker app.

can someone point me in the right direction please where to look to learn how to do what I need to do.

There are many sites offering this data for purchase, and many programs that get it for me, but I want my own data so I can maintain my bot totally myself. I want it to be mine from start to finish.

I am obviously not asking you guys to do it for me, just to point me in the right direction so I can learn how to do it myself.

Things I need to do;

Set up one or two postgres sql databases on a server so they can be accessed from another machine if needs be.

scan a poker table that I am sat at and record each players individual move (datamine the dealer chat) weather they fold, raise/reraise or call recording the hand number and the table number, chip stacks of players, etc

Put this data into a data structure (open tp sugguestions). A hand number and table number will be needed to be used to keep each set of information together. (Thinking array of data inside a hash somehow maybe)

send this data to the postgres sql databases. maybe sending to a file within a folder on my computer, could be another way, but I think the database would be better.

(I'm guessong CGI module will pay a part somewhere, used it before but going to refresh myself again before I start, been a while).

""""build a program using perl that can reach into the database and then analyse the hand using information in the database (I will teach it good hands and bad hands and learn it how to use the information in the database to make a decision)"""""

The above between """"" = comforable solving this part

Based on my findings I need to update the databse/s then tell my computer to call, raise/reraise or fold. I can do this by pressing one of three keys F1 F2 F3. F1 fold, F2 call, F3 raise/reraise and if it's F3 raise/reraise there is a text box to enter the amount, which I will have to somehow access too. This is where the hand number and table number will be useful, because it will be able to make the right move on the right table.

That's the basic outline of the idea and I am very excited on the project and even if it doesn't win much, at least I've increased my computer knowledge a little more.

I use hostgator for my server (when I need one) so I am hoping their support team will be able to give me some info on getting live with the databases but any help on this would be much appreciated.

I will be more than happy if someone can please point me in the right direction of where to look for this information.

I'm sorry for the long message I'm just about a beginner, but once it's all set up and I have the basic program working (information leaving ipoker, into database, into perl, back to database and then carrying out a command on ipoker) I feel I will be ok at learning Perl how to play poker.

I will name the bot when I think of a name and anyone that helps me will have access to the code should they require it for they're own personal use.

I have a good plan/idea on how this will work and I really can't wait to make a start on it.

Thanks for reading, please reply back.

Regards


Bennierounder

Replies are listed 'Best First'.
Re: Poker Datamine
by talexb (Chancellor) on Oct 02, 2013 at 15:17 UTC

    I'm not sure how the bet365 poker application works, but the one I play via Facebook (Zynga Poker) is a Java application, and it's going to be challenging to scrape the dealer chat from that.

    You'd also like to know how many players there are, and where you are relative to the dealer; that information can be inferred from the dealer chat I have, but the sooner you have that the better. (For example, if you're the first to be asked for a bet, that means the big blind's on your right -- but you still don't know whether there's a full table, or it's heads-up. And that makes a difference to your odds, and therefore to your strategy.)

    Once you have access to that information, it would be possible to give you live odds on your hand, and from there make some recommendations on strategy. I'm not sure I'd call that data-mining.

    Alex / talexb / Toronto

    Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.

      I'm wondering if perl can be used to scrape the interface. I was hoping that the number of players and the chip stacks could be scraped from the boxes displaying player names and chip stacks above the players. The dealer tells you who is dealing it goes a little like this in the chat if you set it up right.

      Dealer: Starting a new hand (#5144656552)
      Dealer: kurafinger54 posts Small Blind 15
      Dealer: badbeat737 posts Big Blind 30
      Dealer: Dealing cards
      Dealer: FELSINEO77 folds
      Dealer: mayAbax folds
      Dealer: SUPERMESTRE folds
      Dealer: lele02 folds
      Dealer: bf012552 raises to 90
      Dealer: mickdrip folds
      Dealer: ennnache folds
      Dealer: kurafinger54 calls 75
      Dealer: badbeat737 folds
      Dealer: Dealing Flop
      Ts Tc 7s
      Dealer: kurafinger54 checks
      Dealer: bf012552 checks
      Dealer: Dealing Turn
      Ts Tc 7s 2s
      Dealer: kurafinger54 checks
      Dealer: bf012552 checks
      Dealer: Dealing River
      Ts Tc 7s 2s Jc
      Dealer: kurafinger54 checks
      Dealer: bf012552 checks
      Dealer: bf012552 shows One Pair
      Dealer: Game #5144656552: bf012552 wins the main pot (210)
      with One Pair - Ts Tc Jc Qd Ad

      I wasn't this game just observed a table and copied the chat of one hand.

      Getting this information into a database is what I need, but I don't know where to look to get the info. I know it can be done because there are sites that have the info by scraping the page. Perl might not be the answer for this kind of task so I may need to look into learning Java, but I would have thought there would've been a way

      I think when the data is in the database, it will be easy to find a method of finding out poitions and what not, as I'll just work out a formula to give what I need, but first I need to know weather or not I can get this info.
      Any books or webpages with the info would be a start, but I cannot find anything at the moment!

      It's probably a little advanced for me at the minute, but one way or another I am going to build my own working poker pot (for cash games and tournamnets), weather it be a good player or not.

        Yes, Perl can be used to process the data. However, I don't know if it can be used to scrape the data. I'd just start with that and collect the data.

        For me, looking at historical data is of limited use -- if I were going to write anything is this area, I'd write a training tool to give me feedback and/or support on what my hunch says. And to me, that means real-time processing -- I'd want to be piping the dealer chat into a system that would give me immediate feedback.

        So, good luck with your project.

        Alex / talexb / Toronto

        Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.

Re: Poker Datamine
by aaron_baugher (Curate) on Oct 02, 2013 at 18:45 UTC

    What's the purpose of the database? Are you hoping to calculate odds based on the past moves of the individuals at the table, or something like that? That could be interesting.

    In any case, that's the easy part, if you can get the data. That'll depend on how it gets to the browser. If it's an HTML element being updated with Javascript/Ajax, you might be able to write your own little Javascript app to run in the browser and watch that element, watching for new lines that show up in it and saving them somehow. But if it's Java or some other kind of self-contained application, that won't work.

    If you just wanted to save the info for future study, I guess you could do a video capture of that part of the screen and run it through OCR software later. But you want to write a bot, which means you need to get the data as it happens so the bot can act on it quickly. Another possibility would be to sniff the network traffic and pull the chat text out of that, assuming they don't encrypt it. Setting up a proxy server and having your browser connect through that might give you another place to grab it.

    I would have guessed that they tried to design those sites/apps specifically to prevent bots from playing. I played for a while in very low-stakes game and determined that I could consistently make a few dollars an hour just by playing safe according to some simple odds, because most of the players are impulsive and bad. Not enough to make a living, and it was dreadfully dull. But if I wrote a bot to play for me, it could make that few dollars 24/7. So if they didn't prevent it, I'd think there would be lots of people doing it.

    Aaron B.
    Available for small or large Perl jobs; see my home node.

      Yes that's exactly what I want to do, the data I posted was an example of how it appears at each stage of the hand. I will be getting it in real time as the hand goes on and as players make decisions, but I need to know how to get the actions straight into a database.

      If you know of some other way I could scrape the data into an sql data base in real time I could just use perl after that.

      Then work out the rest once I get that far!

      Any site or literature you know I could study to learn this technique would be a great help!

      There are many people trying it out and as far as I know bots are not detectable unless you play at pokerstars/full tilt.

      However you can open any table from a seperate ip address and run the program on that if you need to play pokerstars or full tilt.

      This is for Ipoker and unlike pokerstars and full tilt the data is not encypted as far as I know because lots of sites sell this information already. They are obtaining it through scraping the data as I have explained. I just need to know how to do it any literature would be much appreciated.

      I have to go to work now, but I will update this post tomorrow with more information on the Ipoker software i.e what language its built in etc. It is an app on my computer though, so it may be saved in a floder somewhere. I'll look tomorrow gotta go.

        Well, as I said, it depends on how you're getting the data. If you're getting it in the browser with Javascript, then you might be able to save it to a local SQLite database, or connect to a server with Ajax and dump it into a database there. But a browser is limited for security reasons in what it can do on the local system and what servers it can contact other than the one already in the window. Perhaps there are ways around those limits; I don't know.

        On the other hand, if you're getting the data by sniffing your network traffic or sticking some kind of proxy between client and server, then that program could save it to a database. If the poker client is standalone, not browser-based, that seems like the most likely method.

        I don't have any resources to suggest, but I think you may want to try terms other than "scraping." Scraping normally means pulling web pages and mining data out of them one after another. You're not talking about web pages here; you might not be talking about the web at all. To scrape something, as I understand the term, you run a program that stands in for the client and grab what the server returns. That would be the ultimate way to run a bot -- have it connect in place of the official software -- but that's very unlikely to be possible. You need a way to run the poker software and get the chat stream that goes to it. Try doing your searches and adding "traffic sniff(ing|er)" and "proxy" to see if you find anything.

        I don't know how the sites that are selling it are doing it, or what they're calling "scraping." Could be any of the methods I mentioned, or something I haven't thought of. Maybe the sites make the table chat available via RSS, for all I know. I still doubt that a database of action more than a few hours old would be useful, but I could be wrong.

        Aaron B.
        Available for small or large Perl jobs; see my home node.

Re: Poker Datamine
by technojosh (Priest) on Oct 03, 2013 at 18:33 UTC
    In this problem, forget about poker. You are looking, at a conceptual level, to automate interaction with a program. This program just happens to be a poker app.

    You need to decide what you will use to control the poker app. Whatever tool that is (you'd like it to be driven by Perl, based on your post) should have equal capability to "read" as to "interact"

    In my world (web automation), we use things like WWW::Selenium to "drive", to both 'read' what is being displayed by the browser, as well as 'interact' whenever we'd like.

    So: have you figured out what technology the ipoker app runs on? What operating system are you running it on? I haven't played in ipoker (i have played on a skin of carbon poker, on bodog/bovada, as well as PokerStars and FullTilt). While I do not condone bots to play poker, this is a simple problem once you decide how to "drive" the poker app. I just won't show any code for you to do so. Bots are strongly considered cheating, or at least very poor form, in the online poker world. You already know this... and you already know that most reputable poker sites block such bots...if they catch you, they will do all in their power to make sure you don't ever access their sites again.

    good luck.

      Bots are strongly considered cheating, or at least very poor form, in the online poker world. You already know this... and you already know that most reputable poker sites block such bots...if they catch you, they will do all in their power to make sure you don't ever access their sites again.

      I assumed this was the case, but not having played in several years, I didn't want to make such a claim without being sure, so thanks. On the one hand, the sites get their cut regardless of whether the players are human or bots. On the other hand, if the bots consistently beat the humans -- which they probably would, since most amateurs play so emotionally -- the humans will quit playing and the business model will collapse.

      Also, it just doesn't pass the smell test. If you had a bot or the data that would allow you to beat the field without getting caught, you wouldn't sell it. You'd set it up to run 24/7 from as many different computers as you could get accounts on, and rake in the winnings for yourself. Selling a can't-lose scheme is a sure sign that you don't expect it to work for long, if ever.

      Aaron B.
      Available for small or large Perl jobs; see my home node.

Re: Poker Datamine
by vincent_veyron (Sexton) on Oct 03, 2013 at 09:58 UTC

    This thread on a postgresql mailing list has a couple posts that might interest you :

    http://www.postgresql.org/message-id/1310953072634-4597798.post@n5.nabble.com

    marica.fr : gestion des dossiers contentieux, des sinistres d'assurance et des contrats
Re: Poker Datamine
by CountZero (Bishop) on Oct 03, 2013 at 19:34 UTC
    I hope you have read the general terms and conditions of bet365 which contains clauses such as
    You are not permitted to: (...) enter, access or attempt to enter or access or otherwise bypass bet365’s security system or interfere in any way (including but not limited to, robots and similar devices) with the relevant products or the Website or attempt to make any changes to the software and/or any features or components thereof;

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

    My blog: Imperial Deltronics