Farm Manager - Tribal Wars 2 Farmbot (old version from 2018)

The bot discussed in this topic was created in 2018.

It was replaced by a new farmbot in 2020: Farm Manager - Tribal Wars 2 Farmbot

Old content

This bot farms barbarian villages in Tribal Wars 2.
It reads your battle reports and sends troops to your farms again.

Features

Easy to Configure

  • Reads battle reports to identify your farm villages.
  • Uses the ‘Attack Again’ function in the battle report to attack each target village with your preferred composition of the army.
  • Uses the chrome web browser to support in-game configuration (e.g. reports filter).

Efficient

  • Automatically activates correct villages to attack from the same villages again.
  • Improves efficiency of units distribution: Skips combination of attacking and defending village for which an attack has already been sent in the current cycle.

Safe

  • Supports random breaks between farming cycles.
  • Stops the farming when the configured time limit is met to avoid perpetual activity on your account.

How to Use Farm Manager to Automate Farming in Tribal Wars 2

To start the bot for the first time, follow these steps:

  • Make sure you have .NET Framework 4.7.2 installed on your system. You can download it from Download .NET Framework 4.7.2 | Free official downloads
  • Download the BotEngine App from https://botengine.blob.core.windows.net/blob-library/by-name/BotEngine.v2019-01-05.exe
  • Start the BotEngine.v2019-01-05.exe. This will open a new window, which also contains a button labeled 📂🌐 Load bot from web.
  • Click the 📂🌐 Load bot from web button.
  • In the text box on the Load Bot from Web page, enter this text: https://github.com/Viir/bots/blob/acdb52480f3d05fc94d0438a255a5cfae4cb8406/implement/bot/tribal-wars-2/tribal-wars-2-farmbot.cs Then confirm by pressing the Load Bot button.
  • The process of loading the bot might take a few seconds, then the App displays this text:

✓ Successfully loaded the bot with ID A5BE9B0A8AE7D57085D6B15D14541A892274AA8B

  • Click the Start bot operation button.
  • Enter your Bot Operation Key and click the Retry button. In case you don’t have a key yet, you can get a key at https://manage.botengine.org
  • After a few seconds, the Bot Operation App enters the Bot Operation page.
  • The first time you start the bot, it will download a web browser component which does not come with the original download. This can take some time, depending on your internet connection. Progress is displayed on the progress bar.
  • When the browser download is finished, the bot opens a web browser window which is a kind of chrome (has a blueish version of the google chrome logo).
  • When the bot has opened the browser window, pause the bot by pressing the Pause Operation button in the Bot Operation App.
  • In the browser window opened by the bot, navigate to the tribal wars 2 website and log in to your world so that you see the in-game controls.
  • Ensure that the zoom level in chrome is set to 100% (default). You can reset the zoom level to 100% by pressing the keys CTRL + 0 in the browser window.
  • In the game, configure the report list filter settings, for example, to not display reports with casualties.
  • Continue the bot by pressing the Continue Operation button.
  • From here on, the bot will operate automatically. You will see it open reports and send attacks. It also switches villages to attack again from the same village.

When finished, the bot will output some stats to inform about the number of reports looked at and attacks sent, etc.:

10:54:27.662 [870] : I am done with this session. I wait for one minute before terminating the script....
10:54:27.650 [869] : In this session, I have looked at 103 reports and sent 71 attacks from 3 villages.
10:54:27.628 [868] : In the current cycle, I have looked at 103 reports and sent 71 attacks from 3 villages.
10:54:27.615 [867] : The last 31 reports I have seen contained combinations of attacking and defending village coordinates for which I have already sent attacks in this cycle. Because of this, I do not expect to find any more new farm coordinates in the next reports. I end this cycle.

The default configuration of the bot just runs one farming cycle. The bot can be configured to perform multiple farming cycles, with breaks in between.

5 Likes

Bot Configuration Improvements

After you have seen the bot working and complete a farming cycle, you might be interested in:

1 Like

Hey Viir, looks like you have discovered a new bot! Thank you for sharing this with us!
I added a link to this bot to the bot catalog: https://forum.botlab.org/t/bot-04088bda-tribal-wars-2-farmbot-v2018-08-22/1407

When you send me the log of from the bot, I can take a look at this problem. You find the log in the textbox under Bot Log when running the bot. You can select all the text and copy it to the clipboard using CTRL+C or the context menu (rightclick).

doesnt load the bot

thats what it says

Blockquote

Loading bot from ‘bots/tribal-wars-2/tribal-wars-2-farmbot.cs at e560e8174401f0b9fb8fe1f9cedffb2994a3ee72 · Viir/bots · GitHub’ …
Trying to load archive from ‘https://github.com/Viir/bots/archive/e560e8174401f0b9fb8fe1f9cedffb2994a3ee72.zip
Failed to load archive: System.Net.Http.HttpRequestException: Fehler beim Senden der Anforderung. —> System.Net.WebException: Die Anfrage wurde abgebrochen: Es konnte kein geschützter SSL/TLS-Kanal erstellt werden…
bei System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
bei System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)
— Ende der internen Ausnahmestapelüberwachung —
bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
bei BotSharp.Web.Web.d__4.MoveNext()

:x: Failed to load the bot.

Blockquote

Thank you. I am not sure yet what could be the cause, I need some more information. The log you have looks like when it is in the process of loading the browser:

https://imgur.com/a/gQQbTaV
Do you see the loading bar shown in the screenshot above?
When you open the directory with the app in windows explorer, do you see a directory called .local-chromium in there? Are there any files in there?

Hi Peter, das schaut aus wie ein Problem mit Internetverbindungen. Du kannst dieses Problem umgehen indem du die Datei von https://botengine.blob.core.windows.net/blob-library/by-name/tribal-wars-2-farmbot.v2018-08-22.cs auf dein system speicherst und dann über den Kopf 📂 Load Bot From Local File in die App lädst.

Noch eine weitere Frage zu diesem Problem: Welche Windows Version verwendest du? Nutzt du Windows 7?

That is interesting. :+1: Maybe this is related to the browser loading problem. Do you see any progress happening with the browser loading bar?

From what I am reading so far on the internet, this might be affected by an operating system setting. Which windows do you use? Do you use windows 7?

So today I tested this on Windows 7 and did some more reading. I found that on Windows 7, the implementation to connect to the webbrowser does not work with the current version.

@otremba, I made a new version for Windows 7, you can download it from https://botengine.blob.core.windows.net/blob-library/by-name/BotEngine.v2018-08-25-win7.exe

Does this work for you?

2 Likes

I sent you a PM for the configuration of multiple farming cycles.

Improving Efficiency - Support Quicker Completion Of The Farming Cycle

Today I added a new feature to reduce the time the bot needs to complete a farming cycle.

Often, you will have many more reports than farming villages, because you get a new report per farm every time you send troops for farming. This means that the bot should not attack again for each report, but only once for each combination of coordinates in a farming cycle.
Since the first version, the bot already supported this: It reads the coordinates of attacking and defending village, and decides to skip this report if it has already sent troops for these coordinates in the current farming cycle. In the log, you then see a message like this:

An attack from 478|518 to 497|536 has already been sent in this cycle. I skip this report and continue with the next one.

With the bot operating, the number of battle reports can quickly grow into thousands. To avoid having the bot spend all the time on reading past reports for the same villages, I updated the bot to detect if it has reached the end of the reports which contain new coordinates.
It now applies heuristics to decide whether to expect new coordinates for attacking or farming villages in the next reports. It then ends the current farming cycle when it looks like no new coordinates are to be discovered.
Then you will see a message in the log like this:

The last 31 reports I have seen contained combinations of attacking and defending village coordinates for which I have already sent attacks in this cycle. Because of this, I do not expect to find any more new farm coordinates in the next reports. I end this cycle.


For the developers among us, you can see the corresponding code changes at

Can this be set to auto run? When i ran it. It did the attacks then shut down window. Is this supposed to happen?

  • When the bot has opened the browser window, pause the bot by pressing the Pause Operation button in the Bot Operation App.

the web page does not open

Hey, you have to set yourself how many cycles to do! Change the “1” in this line
const int numberOfFarmCyclesToRepeatMin = 1;
to how many cycles you want!

3 Likes

Ahh i see thanks. Is there also a way you can set a delay between them also ? So it sends farms out every 1hr for example. Man i need to get back into python learning again. Thanks again mate

For the break duration change the 60 * 30 in this line
const int breakBetweenCycleDurationMinSeconds = 60 * 30;
now its set to 30mins to make it 1hr change to 60 * 60

1 Like

Hi thanks for your help. i just got home and had a look. now i see what you mean. will they be a feature that detects that its sent max amount ie 50 attacks and pause ?

You need to open the web page manually (at least the first time), in the browser window which has been opened by the bot. To open the web page, you can type tribal wars 2 server address in the address bar of the browser or you can use a bookmark.

If the browser window does not open:

  • I need the Bot Log to investigate the problem.
  • Also, what version of Windows are you using?

To decide this, I need to know a few things, for example:

  • What happens on the screen when you reach this max amount?
  • Why would pause be better than other alternatives of progressing?