Tribal Wars scavenge calculator

Enter the amount of troops you have.
Check the raids available. (FF, BB, SS or RR. FF is sometimes also known as LR)
Click submit.
The table will show what troop distribution should be used to achieve either the max amount of resources per hour, or the max amount of resources per run.
It’s possible that some troops are left unused, due to rounding. Use those however you like.

Max time away: :



unitavailableFF BB SS RR
spear0000
sword0000
axe0000
archer0000
light0000
marcher0000
heavy0000
ideal cap0000
res. per run00000
res/hour00000
hour/run0000

Integration (approved under T13915666)

Select what troops you want to send with the checkboxes, then hit “Open calculator” to automatically have your troops filled in. Copy the JSON generated below into “Calculator output” and hit “Plaats calculator output in templates.” to place the troops from this calculator into the templates.

JSON representation of result:

Iterations to achieve result:

This calculator was approved on tribalwars.nl under ticket number T13900636.

If your world(speed) is not here:

Please leave a comment below. In order for me to add a world, I need the following information:
– The name of the world (start of the URL).
– The game speed of the given world.

How this works

In the game javascript the following formula can be found for how much a scavenge brings in:

iCap * iRatio

where iCap is the total capacity of all units, and iRatio is 10% for the first hunt, 25% for the second, 50% for the third and 75% for the fourth.

The following equation is found for the duration of a scavenge:

((Math.pow(Math.pow(iCap, 2) * 100 * Math.pow(iRatio, 2), 0.45) + 1800) * df)

In this formula, df stands for the duration factor. This seems to be loosely based on the world speed. On NL73 it’s 0.9045869428, on NLP9 it’s exactly 1. By throwing the data of the duration_factor and game_speed into google sheets and letting sheets calculate a power trendline, I found that the formula is game_speed^(-0.55).

Worldduration_factorgame_speedunit_speed
zz10.88450337191.250.8
nlp9111
nl710.683020128420.5
nl72111
nl730.90458694281.20.8
World information for duration_factor used to figure out the formula.

This gives the following formula for resources per hour:

iCap * iRatio / ((Math.pow(Math.pow(iCap, 2) * 100 * Math.pow(iRatio, 2), 0.45) + 1800) * df)

This function can be summed four times, with a spread of the iCap (or capacity) for all different ratios. Let’s assume “a” to be an array representing the spread of carry capacity over the four scavenges, where the sum of the 4 elements <= 1. This gives the following:

iCap * a[0] * 0.10 / ((Math.pow(Math.pow(iCap * a[0], 2) * 100 * Math.pow(a[0], 2), 0.45) + 1800) * df) +
iCap * a[1] * 0.25 / ((Math.pow(Math.pow(iCap * a[1], 2) * 100 * Math.pow(a[1], 2), 0.45) + 1800) * df) +
iCap * a[2] * 0.50 / ((Math.pow(Math.pow(iCap * a[2], 2) * 100 * Math.pow(a[2], 2), 0.45) + 1800) * df) +
iCap * a[3] * 0.75 / ((Math.pow(Math.pow(iCap * a[3], 2) * 100 * Math.pow(a[3], 2), 0.45) + 1800) * df)

Now this is a formula that we could start brute-forcing to find the ideal “a”. Once we find that one, we can simply multiply the total capacity by the individual elements of “a” in order to find how much capacity we should send on a given scavenge hunt.

With this initial “a” we calculate how much we’d get per hour, and save this in a variable. After that, we move half of a[0] to a[1]. We also do the opposite. Of those three options, we check which gives the highest revenue and keep that one.

Given that all scavenges are enabled, we'd start with [0.25,0.25,0.25,0.25]. Our second attempt would be [0.125,0.375,0.25,0.25], and our third attempt would be [0.375,0.125,0.25,0.25].

Next up, we do the same, but then with a[1] and a[2]. After that, we do it with a[2] and a[3]. And then we start over.

We keep doing this, until our total revenue does not increase any more. At that point “a” is distributed so that it gives us the ratio of carry capacity required to get the maximum amount of resources per hour. We then calculate that back to how many troops are required to get as close to that required carry capacity, and show this as an output.

66 thoughts on “Tribal Wars scavenge calculator

  1. Goedemiddag Daniel,

    Je rooftochten script ziet er goed uit, de calculatietool heeft me al veel vooruit geholpen. Nu is het echter zo dat wanneer ik het script probeer te installeren door de ‘Download Integration’ button te gebruiken, ik een foutmelding krijg;

    ”Deze site is niet bereikbaar
    https://gitweb.dmvandenberg.nl/Scavenge%20calculator%20integration.user.js?p=tribalwarsscripts.git;a=blob_plain;f=Scavenge%20calculator%20integration.user.js;hb=master#bypass=true werkt even niet, of de pagina kan verhuisd zijn naar een nieuw webadres.”

    Ben nog een beetje nieuw met zo’n soort scripts, maar weet jij of dit verholpen kan worden?

    Alvast bedankt!

    Met vriendelijke groet,
    Rob

    1. Goedemorgen Rob,

      Dank je voor je bericht. Ik had toevallig gisterochtend wat serveronderhoud uitgevoerd, en blijkbaar waren mijn scripts daarmee even tijdelijk niet bereikbaar. Ik heb dit zojuist opgelost, je kan het script nu weer downloaden!

  2. Wow Great calculator thank you!
    When I install the script however, I click “Open Calculator” And nothing happens. What am I doing wrong?
    Thank you so much!

    1. Hi Gavin,

      On what server are you playing? I’m guessing it’s a bug with specific troops being enabled/disabled.

      Edit:
      I have just placed an update that should make the script more robust. Can you try updating it, and then try again?

  3. Thanks for keeping this tool up to date Daniël helps us alot out there with scavenging <3

    I have seen in the scripts section other scripts is there a way to get an english description for it or is it only in netherland?

    Thanks in advance!

    1. Hi Christian,

      I have not provided English translations for any scripts, as I’ve been told that no servers but the .nl servers allow the use of userscripts. If you could provide me with information that proves otherwise, I’d definitely be interested to start working on translated versions!

  4. Hi, I managed to confuse it by setting a maximum away time which was too short for the number of troops I was using. It reported in the table the time I specified, but used troops that took far longer.

    Is it worth setting this up so that it’s aware and holds troops back to meet the max time restriction?

  5. Hi, I love your tool but I think there is something wrong with the code (or I am using it wrong).
    If you use the option most resources per hour on a large army the run times don’t come close to the one in game (even when you would have selected a wrong world speed) and the gathered resources are to low as well.
    In addition under “Make all scavenges take equally long” the shown run time isn’t close to etch other.

    Hope you are having a nice weekend and have a nice day

  6. Hello,

    when I download script, to using him I must have premium account od tribal wars?
    I am asking because I dont see any choice to calculate.

    Thanks

    1. Hi Martin,

      On what world (what URL) do you play? Can you verify that the script is active on the scavenge screen? The script is currently only active on any domain containing “.tribalwars.”. If it is, please let me know, I’ll mail you with some more questions (with screenshots).

  7. Hallo Daniël,

    Wat ziet het er mooi uit!
    Heb het al handmatig al gebruikt maar wil heel graag het script downloaden voor w75 en w76
    Heb je die ook kan en klaar zeg maar?
    Ik ben niet handig in zelf dingen veranderen in scripts namelijk 😀

    Hoor graag van je…

    Lizz

  8. Hallo,

    Echt een top script man ! Bedankt!
    Alleen gebruik hem nu dan op de nieuwe wereld en ging paar dagen goed en hij werkt nog wel hoor alleen wat er nu gebeurt is vreemd

    Open calculator en Templates ding moet ik een heel stuk naar rechts gaan op de pagina.
    en je kan ook toch de troepen selecteren met die vinkjes. er staat een hele rij met vinkjes die er niet hoeven staan enz..

    Weet jij hoe dit komt? want het maakt het namelijk beetje onoverzichtelijk plus is irritant haha.

    Groetjes Stefan

    1. Hoi Stefan,

      Nee, geen idee eigenlijk. Kan je eens al je andere scripts uitschakelen en kijken of het dan nog steeds gebeurt? Bij mij werkt het namelijk nog steeds gewoon goed, dus dit klinkt voor mij alsof er een ander script in de weg zit.

  9. Nice one on the above.

    Another request though please?
    Could you add UK World 52?

    Game speed – 1.8
    Unit speed – 0.625

  10. Also spotted another slight bug, it’s allowing <10 troop scavs to be suggested with low numbers of troops (example 76sp, 65sw on first three levels)

    1. I’ve added UK52. I know about the <10 troops scavenging "bug", but to be honest, it's not worth fixing. The amount of resources gained is minimal, and the technical complications are quite big. The system would have to make multiple passes to calculate the best outcome. Say it thinks 5 should go to the first scavenge and 15 to the second, is it then more efficient to send out 0 and 20 or 10 and 10? So thanks for mentioning it, but yeah, not really worth fixing to me.

  11. Hi, excellent Calculator!!

    I am receiving an error when trying to download the script, is this a problem on my end?

    Regards,

    Richard

  12. Hi, optimise for resources per run, with an 8hr limit and largish troops isn’t working for me. Its not using all troops, the first level isn’t being utilitised at all, and the second tier is only around 3hrs long.

    Sorry to keep reporting this stuff.

    1. Don’t be sorry, thank you so much for mentioning it! I’ve gone through all the code again, and fished out a couple inconsistencies and problems. So, it’s fixed! (Or at least, as good as. It still leaves 300 troops behind but if I’d make it fix that it would take too long to calculate, and it’s only 3% of the troops on the slowest run, so probably <1% resource gain.)

    1. Hi Lucas,

      My German is absolutely terrible, but you’re free to request whitelisting yourself. If you get some sort of number (like a ticket number or so) that I can display to show others it’s whitelisted, I’ll happily add it to this page.

      If the author needs to make the request, you can mention that I asked you to request it on my behalf.

      With kind regards, Daniël

  13. Hi,
    Thank you for this great calculator! That’s exactly what I was looking for.

    Could you add the German world?

    w184
    Game speed 1.25

    Or is that the same setting as world ZZ1 in the calculator?

    greetings

  14. Hey Daniel,

    First off thank you for this script it has been a huge help in maximizing my scavenging profits! I was wondering if this script has been approved on any worlds other then the nl world? I am currently playing w53 on UK but didn’t want to use the script incase it wasn’t approved.

    Thanks in advance!

    1. Hi Jason,

      As I do not have an account on any server but the Dutch servers, I can’t make any support tickets relating those worlds. As far as I’m aware scripts like these are never blocked, but if you want to be sure, you can always contact support.

      If you do and they verify that it’s okay, please let me know the ticket number, I’ll add that to the page so your fellow UK players know it’s approved!

      With kind regards, Daniël

  15. Hello,

    is there some way how to apply this calculator for a czech tribal war server? I have tried it for czech S74 server (server speed 1.2), however the time for a singe run with equal troops is still different than the one which is given by the calculator. I would love to use it for the new s75 server which will have speed 1.0.

    Thank you very much and have a nice day.

      1. Yes, of course. For instance, when I try to send:
        1) 100 spears for the 1st level
        resources: 83, 83, 84
        time: 0:49:03

        2) 100 spears for the 2nd level
        resources: 208, 208, 209
        time: 1:13:28

      1. The results are coming out well off in terms of res/run and res/hour.

        I’m getting about 1/3 of what it thinks. Have you got the speeds right?

  16. Hi, it’s a great tool, thank you!

    Are these the equivalent of the UK scavenges?

    On UK server they are called:
    Lackadaisical Looters – Level 1
    Humble Haulers – Level 2
    Clever Collectors – Level 3
    Great Gatherers – Level 4

    Can I assume that FF = level 1
    BB = level 2
    SS = level 3
    RR = level 4?

    Thanks

  17. Hello mate,

    Great work on the calculator. I was wondering if you could help me on integrating it into my TW account. Any other script i have used i just copy a line of JS into the “Target-URL” box. When i click download on your file i get an actual JS file that im unsure of what to do with.

    Could you help me out with integrating this please?

    Regards,

    Jack

  18. Hi Daniel,

    Im having issues in the portuguese server.

    The “Open calculator” is fine!
    But the “Plaats calculator output in templates” is alerting me that im missing the small-script, im sending you a print of my problem.

    https://prnt.sc/10lgfcm

    I already visited the url, and installed, but the problem persist.

    Thank you!

  19. I found a strange bug. If i calculate 1000 speers for max res per hour i get around 3460 Ress/hour
    and the longest time away is 3:48

    If i set a maximum time away on 4 hours i would expect the same result.
    But now we have 3050 Ress/hours and max time away 4 hours?

    1. Hi Florian,

      As this script attempts to brute force the best solution, it’s entirely possible that it doesn’t always end up at the most optimal solution. Without rewriting the entire code, unfortunately there’s not a lot I can do about this.

  20. Dear Daniel,

    At first thank u for ur amazing tool that u created to make all our tribal wars life’s an easier life for so many years ❤️
    I’m using ur calculator for quite a while now and never had problems.
    Now out of nowhere the estimated times the calculator shows me do not match the numbers in the game.
    I’m actively playing on CAS14DE which is at world speed 1 which i can choose with ur calculator but only the last 3 days it gives me numbers that are about an hour ten longer in the game then the estimation here.
    Maybe u can help me out here ?

    Best wishes and stay healthy

    Julian

  21. also, thanks for all your work, it’s truly awesome! i’ve read some of the above messages, and i installed tampermonkey on chrome. when i go to install the script, am i just supposed to copy the entire downloadable js scripts and paste it into the “Target URL” box? because that doesn’t seem to be working. it just says “this site can’t be reached”. thanks.

    1. Hi Celestium,

      I added the world speed!
      With tampermonkey installed, when you click the “Download Integration” button you should get a screen from tampermonkey.
      Tampermonkey screen

      I did update my server lately, can you try again?

      If that doesn’t work, you can also create a new script in tampermonkey and paste the script in there.

  22. Awesome, thanks. The new world speed seems to work pretty well. And, i now have new options on my scavenge page: “Open calculator.”, and “Plaats calculator output in templates.”. However, when i put the “JSON representation of result” into the text field, and click the “Plaats calculator output in templates.”, chrome gives me a little window at the top that says:
    “us53.tribalwars.us says
    Please install scavenge templates. See https://daniel.dmvandenberg.nl/scripting-tribal-wars/small-scripts/
    I’ve visited that page, and installed the template integration in tampermonkey using the “Install” button. that didn’t seem to work, still got the same message. i then copies the script and pasted it as a new script in tampermonkey, saved it, then deleted the original. same thing. doesn’t seem to work for me.

Leave a Reply to Darren Cancel reply

Your email address will not be published.

CAPTCHA ImageChange Image