lllll llll

Well-Known Member
Reaction score
64
Author
lllll llll
Contributors
N/A
Quickbar Entry
javascript: $.getScript('https://dl.dropboxusercontent.com/s/bytvle86lj6230c/resBalancer.js?dl=0');void(0)
Public?
Public
Hello, I created a resources balancer script which calculates the average value for each resource and then using the average value, every resource above the average will be distributed to villages with resources below average. Resources will be balanced only for the current group selected and is taking in consideration incoming transports so if recaptcha is triggered you can continue from where you left. It works even if you have more than 1000 villages and it doesn't work on mobile app, but it works on mobile browser.

Total amount of surplus and deficit are calculated, ideally the value of deficit and surplus are equal. In practice these 2 variables have different values.
If surplus > deficit means warehouse's capacity is lower than the average value and there is not enough space to move the surplus. In this case after balancing resources each village will have resources equal or greater than average value. If a village has warehouse's capacity lower than the average value, this village will have after balancing 95% from warehouse's capacity.

The other case when deficit > surplus is because there are not enough merchants available to move a high quantity of resources. In this case the surplus will be distributed uniform to each village with deficit of resources.

You can either click on each button or just keep pressing key enter. If you press on "distance" table will be sorted by distance.

Screenshot_25.png

results.png
 

Attachments

  • Screenshot_24.png
    Screenshot_24.png
    68 KB · Views: 445
Last edited:
Upvote 7

lllll llll

Well-Known Member
Reaction score
64
Hello,

I made an update to this script. In this update, I grab from production page construction time for each village and then check AM construction template for each village, also I grab from building page current levels of each building for each village. The goal of this update is to prioritize small villages which need more resources than grown villages.

I added extra settings, the settings from below screenshot are equivalent with the old version, your villages will end up having the same amount of resources.

Villages will receive resources based on this formula:
total_resources = resources needed for building for [hours] + [average_factor] * average_resource

You can play with the settings however you like. My favorite settings for building small villages are average factor set to 0.2 because I want to keep at home 20% from average value for recruiting troops and construction time depends on how often I balanced and what is my average value for each res, if I have a high average value then I set construction time to 9-10 hours. If average value is low then I set to 2-3 hours.

Ideally you should have surplus > deficit ,if not your villages will receive proportionally less resources.


For late game I added an option to balance resources by clusters. The higher number of clusters is set the smaller max travel distance will be.
settings.png

This is the formula I use to calculate construction time for each building and it's not 100% accurate, construction time is calculated with a 5-10% error, if anyone knows a more accurate formula do let me know and I'll update the current formula.

exponent = max(-13, (level - 1 - 14 / (level-1))); baseTime = build_time * 1.18 * pow(time_factor, exponent); time = baseTime * pow(1.05, -levelHQ);



If you press on points ,merchants, hours, image for wood, stone, iron and warehouse the table will be sorted based on what you selected. Column [hours] is referred to for how long your villages will have resources at home for building construction.
results.png


I use mass request resources feature to decrease the number of launches. In the worst case scenario the number of launches will be equal to the number of villages owned.


If it's run on the map it will show how clusters were created and how many resources is sending(red) and receiving(green) each village.

map.png
 

Attachments

  • Screenshot_9.png
    Screenshot_9.png
    26.9 KB · Views: 135
Last edited:

Shinko to Kuma

Still Going Strong
Reaction score
776
Nice work :)

You can avoid having to do translations for this one btw :)

lang["57d28d1b211fddbb7a499ead5bf23079"] ="tomorrow at"
lang["aea2b0aa9ae1534226518faaefffdaad"]="today at"
lang["0cb274c906d622fa8ce524bcfbb7552d"]= "on %1 at %2"
 

The Quacks

Non-stop Poster
Reaction score
76
Hello,

I made an update to this script. In this update, I grab from production page construction time for each village and then check AM construction template for each village, also I grab from building page current levels of each building for each village. The goal of this update is to prioritize small villages which need more resources than grown villages.

I added extra settings, the settings from below screenshot are equivalent with the old version, your villages will end up having the same amount of resources.

Villages will receive resources based on this formula:
total_resources = resources needed for building for [hours] + [average_factor] * average_resource

You can play with the settings however you like. My favorite settings for building small villages are average factor set to 0.2 because I want to keep at home 20% from average value for recruiting troops and construction time depends on how often I balanced and what is my average value for each res, if I have a high average value then I set construction time to 9-10 hours. If average value is low then I set to 2-3 hours.

Ideally you should have surplus > deficit ,if not your villages will receive proportionally less resources.


For late game I added an option to balance resources by clusters. The higher number of clusters is set the smaller max travel distance will be.

This is the formula I use to calculate construction time for each building and it's not 100% accurate, construction time is calculated with a 5-10% error, if anyone knows a more accurate formula do let me know and I'll update the current formula.

exponent = max(-13, (level - 1 - 14 / (level-1))); baseTime = build_time * 1.18 * pow(time_factor, exponent); time = baseTime * pow(1.05, -levelHQ);



If you press on points ,merchants, hours, image for wood, stone, iron and warehouse the table will be sorted based on what you selected. Column [hours] is referred to for how long your villages will have resources at home for building construction.


I use mass request resources feature to decrease the number of launches. In the worst case scenario the number of launches will be equal to the number of villages owned.


If it's run on the map it will show how clusters were created and how many resources is sending(red) and receiving(green) each village.



Best thing ever!
 

Mintyfresh

Skilled Soldier 18 & Master Commander 21 & 22
Reaction score
4,382
Serious question.

How is this script legal and other automating tools/scripts/bots arent @JawJaw ? This is such a powerful tool when used correctly to get incredibly accurate resource pushing to the places that need it most. Theres literally no way a human could do this to such a calculated degree.

But yeah super good work my dude
 

RedAlert

Senior In-Game Staff
Tribal Wars Team
Senior
Team
Script Moderator
Reaction score
608
Yes, we just flip a coin usually. For very big scripts, the jury is composed of 3 people, each of us with his own coin and we all flip it at the same time.

If it's head we approve the script, otherwise, we disapprove.

Satisfied now. This is the secret to how scripts are really modded.

Putting jokes aside, scripts approval is described here:
and scripts should follow the universal game rule as specified here:

The fact that the script is approved it means that has passed the requirements to be approved. Other scripts haven't.

Also, it does not matter how powerful or not a script is. It could be a very easy script, just 10 lines that could do something simple and still be illegal.

It could be 2000 lines of code script that follows the rules and does many things (in a legal way), so we want it or not, it passes the requirements to be approved and that script, gets approved.

A bot (for example) does not follow these rules, which is how and why it is not allowed.

I would suggest that whenever you want to open a discussion or a question that are outside of the scope of the script like:
- if you need help with this script
- have found a bug in this script
- have a suggestion
- etc
pls create a new thread in this forum:

Why this suggestion?
Because a lot of people might come here trying to find the solution of an issue they might be having with this script, someone might want to report a bug, etc ... and if we open discussions here, all of that info (which could be important to someone) get lost inside the discussion.
 

Steelbread69

New Member
Reaction score
0
Some of my villages, which are fully built, don't send their res. out while most of my villages do. What could be the problem here? Have the following settings and AM is on in all villages which aren't fully built up:

reserve merchants: 0
construction time [hours]: 6
average factor [0-1]: 0.15
number of clusters: 1

Is there maybe a max distance which merchants will travel?

Maybe I should add that i have 2 clusters. One that is almost fully built up and one that isn't. To send res. from the built up cluster to the other, I keep "number of clusters" at 1

Besides this issue, great script!
 
Top