2
$\begingroup$

I was curious about how people make AI to play games. Does anyone know of the AI used to play these games? What allows the AI to see/click the screen in real-time? Even just direction on what libraries for such tasks would be helpful. I can't imagine game developers make an API for creating bots in their games like browsers use with selenium.

$\endgroup$
2
$\begingroup$

Bot development is more about 'hacking' than AI in a way that in the very first place you need to read and (over) write game data which you are not supposed to (and thereby potentially violating the Terms and Conditions - so be aware of that). The AI part is fairly simple for most hack/bot applications that I can think of.

Read data

To read game data you can for example:

  • use an assembly code debugger like Ollydbg to locate relevant data in the memory, e.g. amount of gold
  • Observe graphical objects being rendered, e.g. a unit being drawn
  • Intercept network packages containing all kinds of game information, e.g. a unit appearing on your screen

Write data

In a similar way there are multiple ways to write data:

  • overwrite game data in memory
  • Use the Windows API SendInput() function to emulate keyboard inputs
  • Use the Windows API SendMessage() function to send messages to the game
  • Manipulate network traffic

These lists are not comprehensive but to give you an idea of how it is being done.

AI-wise an A* algorithm for example can be deployed to do path finding.

If you are interested in the topic I suggest to read 'Game Hacking' by Nick Cano. The book provides a good introduction.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Sorry, but direct manipulation of a RAM address to increase a value isn't about bot development. Thanks to macro languages like AutoIt, it's possible to create scripts which can control game characters. Especially for the game of Runescape many Autoit scripts are available for automatic mining which are using the normal GUI interface for executing commands. The difference is, that the input isn't provided by a human player but by the computer program. $\endgroup$ – Manuel Rodriguez Nov 11 '19 at 9:30
  • $\begingroup$ Directly interacting with the GUI is highly prone to errors and I would not recommend that. Just in the same way I would not do it for other programs. For example: if you develop a program to do a simple calculation like multiplication. Of course you could use an auto clicker to record your mouse movements starting the windows calculator application and typing in the numbers that you would like to multiply. But it usually not what programming is considered. For obvious and good reasons. $\endgroup$ – Sammy Nov 11 '19 at 10:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.