Yesterday, I’ve wrote a piece on how I’ve tried to automate my TKO account with various extension, tools and even code. Today, I’ll explain how I went from the basic foundation laid out by the sushi go round bot tutorial to build my TKO bot. Everything here can be use to build your own bot for your game.

Reasons I love futurama - Ascent of bot (with the spring being Bender's invention)

“Sushi go round” bot basic

From the tutorial I’ve referenced in my last post, I explained how the author used python to make is bot and what inspired me from his post to make mine.

Note what will follow requires a basic understanding of programming. If you want more info on that let me know or check out the free python beginner book: Dive Into Python

[Dive Into Python]

The basic principle of the bot in the tutorial is to get the image on the screen and analyze them, from there the bot react from what he analyzed.

This is the most important thing I’ve got from that tutorial. Using the python imaging library & numpy to get the image and use what he (the bot) captured on the screen to make a decisions.

Other point to get started is to use (or another image program with ruler) to get positioning in the image of the item that needed to be analysed. PyWin is another important librairy to take care of the reaction of the bot by providing him some way to interact with the screen with the mouse pointer and some keyboard input.

The first step to create your bot

Your first step to create your bot is getting a screen grab of the game to know what is the boundary of your game are. Once you got the screen grab with the game on it, you open the image in an editor like and check the position of where the game start on the screen (in pixel from the upper left corner of the screen ) to where the section of the screen you game end (the lower right corner). With these coordinate, you will be able to concentrate only on the section of your game and if it move you just have to get them again it’s shouldn’t impact your coordinate in game since they will be relative.

Second step: entering the game and/or decide your starting state.

Once you got where your game is in the screen, you need to have a starting state for your bot. It can be the start screen of the game and have a little routine to get in it like sushi go round or start from a state you are often in like in the resource screen of your main city. You’ll probably need to have a routine to go back there so you can easily make your bot shift between task. That kind of backtracking is useful in complex game like Tko but unnecessary for game simple has sushi go round.

Third step: Creating the first task for your bot.

In sushi go round the tutorial show how to find what sushi are being ordered by the customer and prepare them from the ingredient. For Tko there is more option, there so much that can be done, you can make your bot build your city, maybe just collect your daily reward, perhaps upgrade armor or just find those damn 15 farm field on the map. I’ve started by making a task to upgrade weapon, armor and speed (valor camp). These three task have a similar layout and since the same image is used for each upgrade everything needed to be coded only once. The three building can be found at the same place too,  through the menu next to your ruler portraits even if you don’t put them in the same place in every city.

From here you should be able to do almost anything you want. If you’re having a hard time, go revisit the basic that can be found in the sushi go round example and check out some good python free course or book. The next part will be more in deep of the problem I’ve encountered. I’ll show you I went a little further in the bot, by including keyboard input, by using a configuration in a file depending on the user I’m running the bot with or how to save the value you found like where are the 15f.

If you want to files let me know in the comment, l’ll send them to you.