Video Game Bots?

38,585

Solution 1

To 'bot' a game, you need to be able to do two things programmatically: detect what's going on in the game, and provide input to the game.

Detecting what's going on in the game tends to be the harder of the two. A few methods for doing this are:

  • Screen-Scraping This technique captures the image on the screen and parses it, looking for things like enemies, player status, power-ups, game messages, time clocks, etc. This tends to be a particularly difficult method. OCR techniques can be used to process text, but if the text is written on top of the game world (instead of on a UI element with a solid background), the ever-changing backdrop can make it difficult to get accurate and consistent results. Finding non-text objects on the screen can be even more difficult, especially in 3D worlds, because of the many different positions and orientations that a single object may possibly exist in.
  • Audio Cues In some games, actions and events are accompanied by unique sound effects. It is possible to detect these events by monitoring the audio output of the game and matching it against a recording of the associated sound effect. Some games allow the player to provide their own sound effects for events, which allows the use of sound effects that are designed to be easy to listen for and filter out.
  • Memory Monitoring If the internal workings of the game are well understood, then you can monitor the state of a game by inspecting the game's memory space. Some cheat tools for console systems (such as the Game Genie) use this method. By detecting what memory the game updates, it is possible to detect what the game is doing. Some games randomize the memory locations they use each time they are launched in an attempt to foil this vulnerability.
  • Packet Analysis With appropriate drivers, you can intercept the game's data packets as they are sent to or retrieved from your network card (for games played online). Analysis of these packets can reveal what your game client is communicating to the server, which usually revolves around player/enemy actions.
  • Game Scripting Some games have a built-in scripting interface. If available, this is usually the easiest method because it is something the game software is designed to do (the previous methods would all typically count as "hacks"). Some scripts must be run in-game (through a console or through an add-on system) and some can be run by external programs that communicate through the game via a published API.

Generating input events back into the game is typically the easier task. Some methods include:

  • Memory "Poking" Similar to the memory monitoring section above, memory poking is the act of writing data directly into the game's memory space. This is the method used by the Game Genie for applying its cheat codes. Given the complexity of modern games, this is a very difficult task and can potentially crash the entire game.
  • Input Emulation "Fake" keyboard or mouse signals can be generated in lieu of direct human interaction. This can be done in software using tools such as AutoIt. Hardware hacks can also be used, such as devices that connect to the computer's USB or PS/2 port and appear to the system to be a keyboard, but instead generate fake keypress events based on signals received from the computer (for instance, over a serial port). These methods can be harder for games to detect.
  • Game Scripting As mentioned above, some games provide built-in methods for controlling it programmatically, and taking advantage of those tools is usually the easiest (but perhaps not the most powerful) technique.

Note that running a 'bot' in a game is usually a violation of the game's Terms Of Use and can get you suspended, banned, or worse. In some jurisdictions, this may carry criminal penalties. This is another plus for using a game's built-in scripting capabilities; if it's designed to be a part of the game software, then the game publisher is most likely not going to prohibit you from using it.

Solution 2

Once I wrote a simple MMORPG bot by myself. I used AutoHotkey.

  • It provides lots of methods to simulate user input -- one will work. It's tedious to program a working one in C++ by oneself (Or look into AutoHotkey's source).
  • It can directly search the screen for pixel patterns, even game screens (DirectX)

So what I did was to search the screen for the name of an enemy (Stored as a picture with the game's font) and the script clicks a few pixel below it to attack. It also tracks the health bar and pots if it is too low.

Very trival. But I know of an WoW bot that is also made using AutoHotkey. And I see lots of other people had the same idea (Mine was not for WoW, but probably illegal, too).

More advanced techniques do not capture the screen but directly read the game's memory. You have to do a lot of reverse engineering to make this work. And it stops working when the game is updated.

Solution 3

How does an individual person go about their day to day?

This is sort of the problem that AIs in games solve.

What do you want your entity to do? Code your entity to do that. If you want your monster to chase the player's avatar, the monster just needs to face the avatar and then move toward it. When that monster gets within a suitable distance, it can choose to bite the player avatar, and this choice can be as simple as AmICloseEnough(monster, player); or more complex or even random.

Bots in an FPS are tricky to get right because it's easy to make them perfect but not so easy to make them fun. E.g. they always know exactly where the player is (gPlayer.GetPosition()) so it's easy to shoot the player in the head every time. It takes a bit of "art" to make the bot move like a human would.

Share:
38,585
cam
Author by

cam

Updated on April 04, 2020

Comments

  • cam
    cam about 4 years

    Something I've always wondered, especially since it inspired me to start programming when I was a kid, was how video game bots work? I'm sure there are a lot of different methods, but what about automation for MMORPGs? Or even FPS-type bots?

    I'm talking about player-made automation bots.

    • Austin Fitzpatrick
      Austin Fitzpatrick about 14 years
      There's a big difference between the two types. I don't have any experience in either, but I'm pretty sure the MMORPG ones are simulating user input (actually clicking on parts of the screen or simulating keypresses) where the FPS ones that come with the game are written by the game's programmers and probably have access to more information (like where the walls are so they don't have to screen scrape to figure out if they're bumping into a wall)
    • mjv
      mjv about 14 years
      Warning! This very question appears to be posted by a bot! They are spying on us to see if we understand them. ;-) Joke apart, this question is rather broad and shallow, not unlike some stuff we get from bots...
  • cam
    cam about 14 years
    I'm wondering about the techniques to obtain the actual coordinates of your player's body, etc. I don't understand how I would "connect" my program to another program if it doesn't provide anything for me to "connect" to.
  • ChrisF
    ChrisF about 14 years
    @cam - in the case of first or third person games (console or PC) the AI is built into the game code so it has access to all the game information it needs. I'm not sure about MMORPGs, but I would suspect that the AI code is in the game server engine.
  • dash-tom-bang
    dash-tom-bang about 14 years
    Inspecting or otherwise interfering with another program's operation is not how entities in video games are driven. Generally there is one program that does all of the logic on its own internal data structures. Granted, the program may consist of many threads and processes, but to each of them the data that they need is internal.
  • Billy ONeal
    Billy ONeal about 14 years
    I don't know why this got a downvote. +1.
  • Earlz
    Earlz about 14 years
    I didn't downvote it, but thought it was too unclear to upvote.
  • dash-tom-bang
    dash-tom-bang about 14 years
    Sorry if it was unclear- I'm not sure how to make it more clear though; your entity needs a goal, then the code needs to figure out how to achieve that goal. Given the question (at the time) there's not really a better answer than that. (I can take downvotes but it sucks when they come after the question has been edited and the downvote is because the answer was for the previous version of the question.)
  • dash-tom-bang
    dash-tom-bang about 14 years
    This answer is also perfectly fine for the question as posed originally. Why downvote it?
  • Incredulous Monk
    Incredulous Monk about 14 years
    @dash-tom-bang: agreed. +1 to bring it back to zero.