Complex Bots -- Anyone done that here?

PhilVegasOne

Newbie
Joined
Nov 28, 2012
Messages
48
Reaction score
6
I'm looking to meet people who have actually done a complex bot, something to play a game or work an interface via windows. If you have done this successfully or unsuccessfully, please PM me.
 
Years ago I wrote bots for games like World of Warcraft, none of that AutoIT stuff .. but proper injected and complex bots :)

Typically you create them in two parts .. the first part is a tiny C++ DLL that is injected to the running process (e.g. the game) via the CreateRemoteThread() API call. Once the DLL is loaded within the target process you start a "remote control" thread where it sits and listens for instructions over a pipe, socket or shared memory segment. This technique allows you to do very sophisticated things like making direct calls on the game/program objects, or hooking functions to filter through your code before being passed to the original function.

The second part can be written in (almost) anything you like, generally I use C# .. you just connect to the DLL via whatever IPC method you've chosen and send it instructions/commands. In some cases programmes with poor anti-cheat mechanisms can just be memory-edited directly to influence the control-flow of the game/software. C# is also great to run your state-machines or simplistic AI-like features like Behaviour Trees, I was using a sophisticated navigation system to route around enemies and obstacles.

Now I'm using similar techniques in internet-marketing .. creating simple AI-like features for bots that simulate "real" users on social networks. What are you planning?
 
For Dll injection, don't you need to know/understand the code of the original process running to make any function calls?

Years ago I wrote bots for games like World of Warcraft, none of that AutoIT stuff .. but proper injected and complex bots :)

Typically you create them in two parts .. the first part is a tiny C++ DLL that is injected to the running process (e.g. the game) via the CreateRemoteThread() API call. Once the DLL is loaded within the target process you start a "remote control" thread where it sits and listens for instructions over a pipe, socket or shared memory segment. This technique allows you to do very sophisticated things like making direct calls on the game/program objects, or hooking functions to filter through your code before being passed to the original function.

The second part can be written in (almost) anything you like, generally I use C# .. you just connect to the DLL via whatever IPC method you've chosen and send it instructions/commands. In some cases programmes with poor anti-cheat mechanisms can just be memory-edited directly to influence the control-flow of the game/software. C# is also great to run your state-machines or simplistic AI-like features like Behaviour Trees, I was using a sophisticated navigation system to route around enemies and obstacles.

Now I'm using similar techniques in internet-marketing .. creating simple AI-like features for bots that simulate "real" users on social networks. What are you planning?
 
For Dll injection, don't you need to know/understand the code of the original process running to make any function calls?

Exactly, you'd need to reverse-engineer the parts you want to interfere with and then you can make vtable calls on the C++ objects that are part of the original program. Basically your code will have a "dummy" header file describing the objects you've reversed, you pointer-deref to that object in the main programme and you can call those functions just like any other C++ object.
 
I know that it has to access either vtables or function pointers.. But usually the bots in IM aren't done using Dll injection and not reverse engineering the code. Typical IM bots emulate mouse, key event or http request to do it because most of the tasks involved here is web based. Simple way to achieve this is either using C# watin to emulate clicks on the browser or to compose the http request(capture the original request and form it).

Exactly, you'd need to reverse-engineer the parts you want to interfere with and then you can make vtable calls on the C++ objects that are part of the original program. Basically your code will have a "dummy" header file describing the objects you've reversed, you pointer-deref to that object in the main programme and you can call those functions just like any other C++ object.
 
Yes what I'm looking at is building a bot for playing on poker sites. I was actually involved in a previous project which had a functional bot but that one fell through.
 
oh boy, a poker bot. I remember those days and the massive headaches associated
 
Poker sites have huge protection against bots... So ive heard.
 
Your problem is not simple.


There are 2 separate phases in creating an intelligent bot:




a) Interface with the heart of the system


This can be done through API or manipulating the navigator (or sometimes manipulating a compiled component such as an activeX).


I doubt a poker game would provide an API...


IMHO this part is the most complex because html interfaces are a total anarchy. Interfacing with a compiled component is even worse. Some interfaces are easy to manipulate, some others are a nightmare. Chances are the visitor interface changes all the time. In some other cases, the developpers have programmed antibot protections (I encountered this case while scraping proxies: the html was scrambled with extra code preventing it to be easily copied). You may also need to develop 'human simulation' to be able to play (for example: delay some commands, have consistent IPs...)


In your example, it means for example that you need to find the values of the cards of the various players, and find a way to ask for cards, place a bet or else


b) When this has been done, you need to program the logic


For games, it involves statistical calculations and can be very complex: sometimes several months or even several years of work (think chess game programming). In many cases, it requires artificial intelligence.


This part is a lot easier because you control the environment and you can develop whatever programming trick you need.




Most commercial bots I've seen are simply script recorders. I have never been able to use any of them for complex tasks.


It will be hard to find a suitable programmer. Programmers are not trained for these kind of tasks. I have tried with several students or programmers on market places (odesk...) and I have abandonned quickly, even for simple tasks.


In summary: If you have a big budget, you will be able to implement your project. Else, be prepared to suffer while learning.
 
Well said mistodin (+rep)

The "plumbing" of making a bot to interact with a Poker site is the easier part of the challenge. From my (limited) knowledge of gambling sites a lot of them use Flash, and a few use ActiveX embeds to the browser. Firstly you needs to get the basics like what cards you've been dealt, bets on the table etc. essentially you need to "read" the state of the game.

This is not as straight-forward as scraping data from a web page because the game state is inside the Flash/ActiveX and updated using client-server communication. I generally resort to the network-layer to get this sort of data, it makes it less likely to change because they would have to upgrade both the client and server software in tandem to change the communications protocol. It's probably over SSL so you need to know how to intercept (man-in-the-middle), this is easy to do on your own computer.

So assuming you've got the "plumbing" sorted, and you can now interact with the game the hardest part becomes "what do you do?".

Creating a successful Poker-playing algorithm will be the hardest part, Poker is a "partially observable stochastic game" meaning you don't know what cards the other players have, and they contribute to the changes in the game-state meaning whatever you do will need to adapt. There are lots of academic papers on "partially observable stochastic games" and some even call out Poker as their case-in-point. The best way to proceed would be to read through a bunch of their papers and cherry-pick ideas, algorithms and approaches from each (400+ papers on Google Scholar).

The good part is that the Poker-algorithm is portable to any game-site running Poker, all you need to do is update your "plumbing" to talk to a new site and away you go.
 
Last edited:
Update: if you Google for 'open-source poker bot' you'll find loads of examples :)

(edit) Lots of great information here:
Code:
hxxp://stackoverflow.com/questions/2717599/defeating-a-poker-bot
 
Last edited:
Your problem is not simple.


There are 2 separate phases in creating an intelligent bot:




a) Interface with the heart of the system


This can be done through API or manipulating the navigator (or sometimes manipulating a compiled component such as an activeX).


I doubt a poker game would provide an API...


IMHO this part is the most complex because html interfaces are a total anarchy. Interfacing with a compiled component is even worse. Some interfaces are easy to manipulate, some others are a nightmare. Chances are the visitor interface changes all the time. In some other cases, the developpers have programmed antibot protections (I encountered this case while scraping proxies: the html was scrambled with extra code preventing it to be easily copied). You may also need to develop 'human simulation' to be able to play (for example: delay some commands, have consistent IPs...)


In your example, it means for example that you need to find the values of the cards of the various players, and find a way to ask for cards, place a bet or else

No the html web interface sites aren't worth money. Like I stated before I was involved in a running pokerbot. Most of the sites worth being on use a PC client interface.

Openholdem is an excellent system to start with unfortunately it only works on Holdem.

In your example, it means for example that you need to find the values of the cards of the various players, and find a way to ask for cards, place a bet or else


b) When this has been done, you need to program the logic


For games, it involves statistical calculations and can be very complex: sometimes several months or even several years of work (think chess game programming). In many cases, it requires artificial intelligence.


This part is a lot easier because you control the environment and you can develop whatever programming trick you need.




Most commercial bots I've seen are simply script recorders. I have never been able to use any of them for complex tasks.


It will be hard to find a suitable programmer. Programmers are not trained for these kind of tasks. I have tried with several students or programmers on market places (odesk...) and I have abandonned quickly, even for simple tasks.


In summary: If you have a big budget, you will be able to implement your project. Else, be prepared to suffer while learning.


Although this statement might be true if you are trying to build a NLH cash game bot, there are plenty of weaknesses and games to be exploited where in the logic is simple or moderatly complex.

If look at super turbo, ICM bots perform quite well. Shortstacking in PLO is a gold mine. The problem is most scholars are not poker players and think about building a AI bot to beat everyone when in reality it is only necessary that the bot is able to realize a EV (Expected Value) against most players at a certain limit and have coding to avoid the opponents it cannot beat.

Our previous bot was quite simple in logic and performs well enough against thousands of opponents in narrow ranges of games. And then of course only plays those games.
 
Poker sites have huge protection against bots... So ive heard.

This is not true at all.. Only pokerstars has strong bot protection. And then even there its not exceptional except the captcha. But theres no reason to build bots for stars. Money spends just as well off any pokersite.
 
Are there any in-depth tutorials or websites about creating bots with dll injects?
 
Well anyone interested in discussing this project on a serious basis?

I have logic and even parts or a whole working bot that is profitable. As a poker player I was easily in the 100k+ a year range and I have plenty of pokersite connections to get accounts without ID etc.

If you are hit me up. Or we can discuss this project more in depth on this thread.
 
PhilVegasOne, if you're still interested drop me a PM. I love getting around anti-bot measures and automating what isn't supposed to be :)
Even CAPTCHAs can be bypassed relatively cheaply using online services or you can just use a good OCR algorithm if the CAPTCHA isn't strong enough to prevent it.
As for implementation, using Dll Injects might be the way to go, or simply operating the UI and extracting information from that might be better. The latter is easier, depending on how complex it is, and will usually be more robust to underlying code changes in future versions.
 
Ikstob, were you part of the Innerspace community? I was pretty heavily involved there in bot development. Managed the computer networks for some of the gold farming companies using IS and some custom stuff I wrote.
 
Back
Top