Farm Manager - Tribal Wars 2 Farmbot

Is there a way, when it finishes a break and refresh the browser the bot would check if there is a new compatible preset it can use? I like to add new preset, while the bot is running but then I would have to completely restart the bot so it can recognize the new preset.

Also being able to tell that a preset was disabled & reenabled again… I usually disable preset on the fly for villages I don’t want it to farm so I can use the troops to attack something. But when I want it too farm again, I was wondering if I can just enable that preset again and it will continue farming from that village instead of running the entire bot all over again each time.

1 Like

I have been noticing some problems when I use the bot with an increasing amount of villages.
I`ll try explaining the problem (maybe its a problem only imo): since the fact that the bot is iterating over all the villages, checking if they all have 50 attacks out, before ending the farm cycle. When you have a huge ammount of villages, you start having to iterate millions of time on all the villages and using light cav. everytime some attacks came back in the meanwhile. Till now the behaviour of the bot seems pretty dope, the problem is that instead of attacking again the closest villages, in order to attack different barbarian, it starts attacking barbarians which are really far away. I know that logically is the right behaviour but there are some problems with this:

  • with just 4 villages my first cycle needs 50 minutes to find all the barbarians (i am running the script over an oc intel xeon x5670 @4 Ghz)
  • I know it makes sense to attack different barbarians, but since the fact that all the players are farming, it doesn`t make sense to attack a village which is one hour and an half far away, since the fact that there are the same chance it is empty as the one i just farmed

Hope my explanation was not that bad, sorry but english is not my mother tongue, as you understood :slight_smile:
Thank you,
Marcons

1 Like

Nice idea! It makes sense the bot should refresh its reading of the army presets each time it starts a new farming cycle. I will look into adapting the bot program to do this.

It’s been some time since I looked into that area. At the moment, I do not remember how disabling a preset is modeled in the game client and bot. What behavior do you observe with the version you are currently using? What happens if you re-enable a matching army preset?

I implemented this in the program code here:

You can run this version from https://catalog.botengine.org/54c7eb6f7d49aff5e32c404216d53b349702babd55a296b583a90f19160e11b7

For the developers I compiled this summary of the approach:

How do we implement this behavior?
First of, to clarify the concepts: Finishing a break means starting a new farm cycle.
Some background on how the bot works: The bot reads the list of the army presets from the game client and then stores it to pick the right one when sending an attack.
To implement this new feature, we start by moving the memory of the army presets from the global level down to the level of the farm cycle. This means moving the getArmyPresetsResult field from the BotState type to the FarmCycleState type. We discard the farm cycle state when we finish a farm cycle, so moving the field into there protects us from accidentally using an outdated reading. After moving the field, we follow the compiler’s error messages to adapt all places in the program that update or read this field.

1 Like

It’s been some time since I looked into that area. At the moment, I do not remember how disabling a preset is modeled in the game client and bot. What behavior do you observe with the version you are currently using? What happens if you re-enable a matching army preset?

When I try it, while the bot is running? When I disable the preset, the bot will continue to “try” to use that preset even though it can’t as it’s been disabled. I get a message in the game saying something like “Trying to use a preset that is unavailable for this village”. The bot would obviously skip that preset after a while.

When I enable that same preset, which I disabled earlier it doesn’t recognize it anymore even when it starts a new farm cycle and refreshes the browser. I would then have to re-run the bot client again.

I implemented this in the program code here:

Implement the feature idea Drklord shared at Farm Manager - Tribal Wars 2 Farmbot - #189 by Drklord ``` Is there a way, when it finishes a break and refresh the browser the…
You can run this version from https://catalog.botengine.org/54c7eb6f7d49aff5e32c404216d53b349702babd55a296b583a90f19160e11b7 1

For the developers I compiled this summary of the approach:

How do we implement this behavior?
First of, to clarify the concepts: Finishing a break means starting a new farm cycle.
Some background on how the bot works: The bot reads the list of the army presets from the game client and then stores it to pick the right one when sending an attack.
To implement this new feature, we start by moving the memory of the army presets from the global level down to the level of the farm cycle. This means moving the getArmyPresetsResult field from the BotState type to the FarmCycleState type. We discard the farm cycle state when we finish a farm cycle, so moving the field into there protects us from accidentally using an outdated reading. After moving the field, we follow the compiler’s error messages to adapt all places in the program that update or read this field.

Want to say this works great!

Have you tested it for more than one hour? When I look at the catalog page it displays less than one hour usage for 54c7eb6f7d.

I can look into this when the results for App 54c7eb6f7d. If it turns out there is a problem with 54c7eb6f7d we should fix that first before trying to add more features.

Hello Max, thank you for sharing your experience!
The scenarios I had seen so far had less than 40 villages. So this is where my focus was in the past and where we optimized so far. By shifting attention to scenarios with more villages, I am sure we can improve these cases.

I have some ideas on how we could improve for this scenario. One option is to use a more strict condition for switching to another village. As you described, the bot currently switches to a village when it has at least one free attack slot (49 active attacks out of 50 possible)(bots/implement/applications/tribal-wars-2/tribal-wars-2-farmbot/BotEngineApp.elm at 9b1aa54e89628968dfd19e4dbae840f4dbadb894 · Viir/bots · GitHub)
The idea is if we require at least five free slots before switching to another village, this could break the cycle that you described above.

I uploaded a new version using this additional constraint on continuing a farm cycle. You can load it from https://catalog.botengine.org/3d2af48f6841217f8370b2234da854df4c0c50701ce39f04a83927751dc10112

1 Like

Whats the standing of this application? i see a handful of users but you you have a forum of any kind to determine the detection rate of this bot? i only ask as a pre-buyer.

Hi.
Can anyone help what’s wrong? Offline version works but online not working.
scren

To run App 21e86dc95a you need to use the engine version 2020-12-08 or newer. You can download the botengine executable file from https://botengine.blob.core.windows.net/blob-library/by-name/2020-12-08-botengine-console.zip

This version also displays the 2020-12-08 in the window title, this way you can check what you are running.

The current setup guide is at bots/guide/how-to-install-the-botlab-client-and-register-the-botlab-command.md at main · Viir/bots · GitHub

Just updated the repo and now i’m getting this error with my list string.

run v2020-08-24 failed with exception: System.NotImplementedException: Failed for 1 attempts. Output file not found. Maybe the output from the Elm make process from the last attempt helps to find the cause:
Exit Code: 1
Standard Output:
Dependencies ready!
Detected problems in 1 module.
'
Standard Error:
'-- TYPE MISMATCH ------------------------------------------ src\BotEngineApp.elm

The 2nd branch of this `if` does not match all the previous branches:

126|             if settings.farmArmyPresetPatterns == [] then
127|                 [ farmArmyPresetNamePatternDefault ]
128|
129|             else
130|                 settings.farmArmyPresetPatterns
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The value at .farmArmyPresetPatterns is a:

    List String

But all the previous branches result in:

    List (List String)

Hint: All branches in an `if` must produce the same type of values. This way, no
matter which branch we take, the result is always a consistent shape. Read
<https://elm-lang.org/0.19.1/custom-types> to learn how to ΓÇ£mixΓÇ¥ types.

'
   at Kalmit.ProcessFromElm019Code.CompileElm(IImmutableDictionary`2 elmCodeFiles, IImmutableList`1 pathToFileWithElmEntryPoint, String outputFileName, String elmMakeCommandAppendix)
   at Kalmit.ProcessFromElm019Code.CompileElmToJavascript(IImmutableDictionary`2 elmCodeFiles, IImmutableList`1 pathToFileWithElmEntryPoint, String elmMakeCommandAppendix)
   at Kalmit.ProcessFromElm019Code.ProcessFromElmCodeFiles(IImmutableDictionary`2 elmCodeFiles, Nullable`1 overrideElmAppInterfaceConfig)
   at Kalmit.PersistentProcess.PersistentProcessWithHistoryOnFileFromElm019Code..ctor(IProcessStoreReader storeReader, IImmutableDictionary`2 elmAppFiles, Action`1 logger, Nullable`1 overrideElmAppInterfaceConfig)
   at BotEngine.Windows.Console.RunAppSession.Run(TreeComponent appCodeTree, Func`2 getFileFromHashSHA256, String appProcessRecordingDirectory, Action`1 logEntry, Action`1 addSessionLogEntry, String appSettings, String sessionCustomName, AppSourceStructure appSource, String keyToStartOnlineSession, IEnumerable`1 sessionLengthLimits, IImmutableList`1 pauseAppKeys, IImmutableList`1 statusDisplayAdditionLines, RunSimulation simulation) in D:\a\dev-of-botengine\dev-of-botengine\implement\client\windows-console\BotEngine.Windows.Console\RunAppSession.cs:line 55
   at BotEngine.Windows.Console.BotEngine.runAppWithOptionsFromCommandLine(String appSourceInputAddress, String appSettings, String pauseAppKeysString, Boolean onlineSession, String keyToStartOnlineSession, String sessionLengthLimitArgumentString, RunSimulation simulation, Nullable`1 detailedSessionRecording) in D:\a\dev-of-botengine\dev-of-botengine\implement\client\windows-console\BotEngine.Windows.Console\Program.cs:line 690

Never mind, looks like I saw what you added and now got it to work. Had to update the botengine file as well :smiley:

Moin ich bin komplett neu und habe folgenden Fehlercode:

Man sieht dort nicht das ganze Fenster, schaut aus als wäre eine ältere Version des Bot gestartet worden die nicht zu der bei dir installierten engine passt.
Du kannst eine passende Version laden von https://catalog.botengine.org/21e86dc95a434e21f4c99cd958057e6b468394e81e1a344f46fc20f080f8621d

Oh du hast Recht. Dachte ich hätte die neuste. Danke dir für die schnelle Antwort!

so in this case we would delete that line to ensure an attack isnt on the same villages?

By default, the bot avoids sending more than one attack to the same village in the same farm cycle.
Are you looking for a different behavior?
Do you want to expand the avoidance across farm cycles?

Getting this error. Tried to add it to the barb avoid cord but doesn’t help. Unable to copy just the text so had to take a screen shot.

Thank you for this discovery. In this case, the screenshot contained all the necessary information. I adapted the bot to ignore these villages:

You can start the new bot from FrontendWeb.Main

1 Like