Archive for September, 2016

RIP Three Kingdoms Online

Today is the day that Three kingdoms online is no more.

Three kingdom online was a little brother to me.I loved to play with you until he grows up a become a teen and started to get greedy.

corruption

Most people run away from him when this happen but I didn’t, I’ve just told him it’s not going to happen but we can still play together.

There a lot of good games that came after TKO, some even came after and closed before TKO (I’m looking at you Lord of Ultima)

If you have any games in the MMORTS genre that you want to suggest or anything related Romance of the Three kingdoms feel free to do so. I read every mail (jack at onlinesgamestips.com) and I might decide to write a piece on your game.

Check my initial reaction post to TKO closure or my 4 parts series on how I’ve build a bot to reduce my play time.

end

throne

We’ve talked about how to automate your game in part 1, how to build a bot with python with the sushi go tutorial in part 2 and the problem I’ve encountered in part 1 and 2 that I’ve fixed. Today, It’s a summary of what I’ve done (task and feature) to automate the game and make it more fun.

Side note, doing all this made the game much more fun to play since most of the boring stuff was automated or semi-automated.

The 12 automated tasks that made the game fun again… almost.

1-Upgrade all the tech (weapon, armor & valor)

I’ve already explained it in part 2. The reason I did this is because it was a pain to go in each city each 3 building and upgrading this should be automatic.

2- Upgrade resources fields

This is the main reason I’ve wanted to make a bot is to automate building new cities. I made a dumb cycle that check each resource field starting by the food field and going through all the resources.

This give funny situation where wood and iron are barely developed and farm and stone already have a lv 10. But the basic were enough to be useful.

3-Upgrade building

This one cover every building except warehouse and granary because these 2 are not accessible via the menu next to your ruler face.

4-Market place

I’ve already talked about this one in part 3. Go check my second problem.

5-Check if your in game

I’ve already talked about this one in part 3. Go check my first problem.

6- create a build list and use it to upgrade and send resources (Do point 1 to 4 all at once)

I’ve already talked about this one in part 3. Go check my third problem. Basically I’ve save the build in a file and when the bot is looking to upgrade building or resource, the build file tell him where to start. What is missing is a way to remember where he was the last time so he doesn’t always start at the same place, next game I guess.

7- City loop: loop all your cities with the point 6

Once you got a way to upgrade building, resources and tech for each city I’ve implemented a loop that do those 3 task for all your account city. Saving you precious time.

8-Attacking Captain with heroes

This is a great way to get experience so I made a loop that click on the captain until the captcha show up. When the captcha show up I usually enter it and the bot start again for the next ten heroes.

9-Amassing training point

Like previous point but with troop to get training point

10-Attacking a elite guard

This one is a bit harder, since it need to loop the map, everything else after is just checking if there an elite guard and attacking him like we do for the training point. The risk here is that we lose real troops when we do that, So its more semi-automated.

11-finding 15f

this one was on of the last I’ve done. I was tired of clicking on the map to find the 15f, so I made a task to click on the map and check the the type or terrain. It’s save the value in a shelve and add it to the map bookmark.

12-level up heroes

TKO is so  well design game UI wise (puke), it takes so many clicks to level up a hero that if you have many heroes it can take awhile. So the goal was to automate leveling the heroes on the heroes screen.

What I wanted to do next

I wanted to manage plundering, take care of the special event. From there I could probably run by it self. My ultimate goal would have been to manage war with it, that would require a way to read actual value on the screen. I could be done but by reading pixel by pixel or by having a proxy that gets the date from TKO when it send to it server and process information from it.

I hope you liked that series of post on how I’ve automated my playing experience. If you like it, drop me a email and I might do a bot for other games too.

We’ve talked about how to automate your game in part 1 and how to build a bot with python in part 2. Now we are going to implement specific task I’ve wanted the bot to do and the difficulty I’ve encountered implementing them.

The principle and idea we talk about here can be apply to other games or even website or apps but the code itself is specific to Three kingdom online (RIP).

Problem #1: the bot don’t know if the game have focus or not.

 

Lost

Solution #1: take a specific section of the game that never change and validate that it’s always present.

Other possible solution: check the window in focus, check if there an external input.

My problem was that sometime I left the bot running and another site would popup or I wanted to close it but it’s keep clicking everywhere even if the game is not there. My solution was to check the logo in the top left corner and validate if it’s there each time we make a big step.

TKO-main

Problem #2: We need to input value from the keyboard

Example: Sending resources from your city to another city, plundering or sending troop to a location.

Solution: Use the pyWin and make keyboard input.

One of the first problem I had is that I wanted all my sub to send resources to my main or a city in development. But to do that you need to type the amount of resources to send (note that, there a way to add them via click) and enter the destination (must have an input if it’s not one of your city)

Problem #3: need different configuration between account

617-Benders

Example: build order, market destination, city found

Solution: load the configuration from a file.

Alternative: save and load value in a db (mysql, sqllite)

There are other issues I’ve encountered, a ui change, popup that not where it should be and other stuffs like that. But these were the mains that were really painful. Hopefully it will give you some ideas if you get the same problem.

This problem is quite recurrent and was going to be an issue if I had the time to build a bot that manage multiple account. Having a different build between account, city or having different destination depending on the city is great example. How I solve it it’s by creating a class that have the initial value and save in a file. When the bot run, it will loads that file and can modify it if needed,  this allow to remember where it was, when the last time he did a certain task. I’ve didn’t go that far but that the principle. Next video show how it use different setting.

You can’t really see it but in the previous video I’ve use the shelve, the 3 10000 for each resources come from the shelve. I’ve haven’t used them to their full potential, they could be use it to save what we send and what to send next time.

There are other issues I’ve encountered but these were the mains that were really painful. Hopefully it will give you some ideas if you get the same problem. Next article will be about all I’ve managed to do with the bot and what was missing.

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 paint.net (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 Paint.net 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.

After the merge of 2014, my server has lost and my main was brutally destroyed, I basically dropped from the game with a RIP message 2009-2014.

dong zhuo city

When I saw the sea of attacking coming at my other cities I decided, ‘No’ I can’t give up without a fight. I save most of my cities and kill around 30 lobbyist, thousand of demo. I was offered to join a sub league or be annihilated. I thought about it and chose the league.

Evil Laugh

After a few months in, I’ve decided to put my account to good use and learn a bit. I’ve decided to see how I could make my account automated at least reduce the amount of work to do. I’ve thought about doing it for other game too, but I usually get bored before doing it.

Finding the tech

1-Grease monkey

I’ve talked about the three kingdom online grease monkey script in the past  but the script wasn’t working anymore and was not maintain. I’ve try to understand what going on and modify it but it’s end up not doing what I wanted.

2-Autofill extension for firefox

I’ve found that great extension in firefox called autofill where you can save a form and it’s value. You can recall the value when you want. I used it for the market place but could have been used for the deployment screen too.

Here a quick video how I’ve used it:

3-Selenium IDE Extension

Selenium record what you’re doing and then try to reproduce it exactly. I’ve played a bit with that one but the way TKO was set up sometime event or call where missing or not needed, making selenium not going to the next screen and then it’s tried to do what it was supposed to do in the next screen but in the current screen. What the mess, I’ve drop it after a few try, but could probably work with some tweaking.

4-Autohokey

AutoHotkey (AHK) is a free, open-source macro-creation and automation software for Windows that allows users to automate repetitive tasks.

This one seem to be use a lot for bot, basically you write a simple script and inside tell it where to click. It has some power, I’ve used it to do the governor work. See it in action for one loop, but the real script was running it 10 time in a loop to max the potential popularity each day.

You can download it here and if you want my autohotkey file let me know.

5-Python

After a bit of research I’ve found a tutorial of a guy using a python script to play sushi go round. Click on sushi to get the article.

This is when my bot was born, I’ve used the principles in the tutorial and applied it to TKO instead.

 

Disclaimer: there are other thing I could check, like using fiddler to get the request and try to spoof them, use a mix of a python proxy to do that with a combination of the bot I ended doing. It’s not the most efficient way but looking at what happening on the screen and reacting to it is the best way to avoid being flag has a bot, because in the end the bot is doing the same thing you’ll be doing.

I’ve you used a bot or some tool to help you play let me know I’ll love to hear what you’ve done.