Tuesday, January 10, 2017

Bots!

The advancement of artificial intelligence has fostered many tools designed to both mimic human behavior and make mundane tasks easier. One area which has seen an explosion of innovation in online interaction is the development of “bots”. Put simply, bots are applications designed to respond within another program to automatically achieve some result. They come in a variety of styles. There are telegram bots, game bots, and telegram bots, to name a few. Each bot performs unique functions. For example, telegram bots autonomously answer inline queries in HTML5-based games (Martin, 2016, October 17).

Using the software available through a company called The Botfather, users are able to automatically follow a game’s lifecycle through the following process:
1.The user requests a game through the /play prompt
2.A sendgame function is remotely sent in response by the API setting the buttons
3.The user taps the play solo button, and the game bot responds by sending the game’s URL and sets parameters
4.When the player scores in the game a setScore function is established in the cache

The tool in the above example allows players to remotely handle many games and gather resources, points, and other rewards. The performance of bots is based on a machine-state flow process. Bots are designed to “read” the screen (pixels, text, packets or memory) to discover the state, and then respond per the programming (Mai, 2009). This is where the key distinction between bots and macros lies. A macro has been defined on Tech Target in terms of programming as (Griffen & Lowery, 2015):

“…in Microsoft Word and other programs, a macro is a saved sequence of commands or keyboard strokes that can be stored and then recalled with a single command or keyboard stroke.”

In other words, a macro performs when it is instructed to do so by a human. It is merely a shortcut command designed as a time-saver. A bot takes the concept to the next step; performing autonomously. In games and other online applications, it uses artificial intelligence to read a state and respond. Still, users tend to use the terms interchangeably. In C++ programming, developers have devised a method for automating a basic process such as a send key.

Effectively, developing a macro (or bot as many programmers will call it) allows the user to send a virtual key, defined in winuser.h as VK_XXX and a flag noting whether the key is up or down to express whether the virtual key is expressed. The ALT-TAB sequence could be set up in this manner (Bachaalany, 2004):

//press down Alt-Tab
Keybd_event (VK_MENU, 0, 0, 0);
Keybd_event (VK_TAB, 0, 0, 0);
::Sleep (1000);
//stop pressing Alt-Tab
Keybd_event
(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
Keybd_event
(VK_TAB, 0, KEYEVENTF_KEYUP, 0);

As shown above, the event requires four lines of code. The mac o simplifies the process through simply calling a library: #include “Sendkeys.h”

References

Bachaalany, E. (2004). How to do ‘send’ keys in C++. Retrieved January 3, 2017 from https://www.codeproject.com/kb/cpp/sendkeys_cpp_article.aspx

Griffen, T. & Lowery, P. (2005). Definit-ion: Macro. Techtarget. Retrieved January 4, 2017 from http://whatis.techtarget.com/definition/macro

Mai, S. (2009). 10 tips for writing game bots. [Bog post]. Krypted. Retrieved January 2, 2017 from http://krypted.com/sites/5-rules-for-writing-bots-in-games/

Martin, A. (2016, October 17). How to create a game bot and publish your html5 games on Telegram. [Blog post]. Retrieved January 2, 2017 from https://blog.ludei.com/how-to-create-a-game-bot-and-publish-your-html5-games-on-telegram/

No comments:

Post a Comment