lllll llll

Non-stop Poster
Reaction score
88
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: 742
Last edited:
Upvote 7

The Rat Pack

New Member
Reaction score
0
Hello, been having a lot of fun learning the ins and outs of this script and have a case I'd love to get your insight on.

I have a villa (lets call it X) that needs farm 30 (90k/125k/48k). That's the last building before it completes AM. It has 65k/46k/107k, so needs 25k/79k/-59k.

Running the script with settings 0/12/0/0 gives it EXACTLY that amount. It Also balances a ton of other villages.

Running at 0/4/0/0 gives it the same amount, but there's far less movement across other villages. This is expected because many of their queues are full/AM is not running.

Running at 0/1/0/0, it becomes the ONLY village that gets any kind of balancing (it gets the res needed). Where I'm confused is there's another villa (let's call it Y), that is 17k short of enough clay for farm 28 (costs 72k, has 55k). It has nothing in queue and it has AM active with that farm upgrade next in line... Not sure why it's ignored in favour of 480|584 though, or why other villages aren't pumping res to it so it can start its queue.

Is this purely down to the surplus/deficit you mentioned? X is in a high surplus area, the other in a low surplus area. Cluster setting set to 0, 1, or 2 has no effect on the 0/1/0 setting so I wouldn't expect that to have an impact. Either way, this means that villa Y is stuck unless I use a higher construction time number.

Could it be that the script sees it would take at least 2h to get the resources there and so discards the villages around village X in the calculation?
 

lllll llll

Non-stop Poster
Reaction score
88
Hello @Dezachu

Are you using the latest version of this script? There are some old versions of this script with a bug related to what you're describing on other markets.


Is it possible on 'Y' village to have some incoming resources?


Can you make screenshots with deficit/surplus statistics? It's interesting to see if you have surplus>higher deficit than all your villages should receive resource to construct buildings for at least X amount of hours from your settings.

In resulted deficit data for clay, you see only the number of clay needed for village X or for village X+y?

My best guess, since it's working if you increase construction time, it's s rounding issue somewhere on the code.
 

The Rat Pack

New Member
Reaction score
0
Hello @Dezachu

Are you using the latest version of this script? There are some old versions of this script with a bug related to what you're describing on other markets.


Is it possible on 'Y' village to have some incoming resources?


Can you make screenshots with deficit/surplus statistics? It's interesting to see if you have surplus>higher deficit than all your villages should receive resource to construct buildings for at least X amount of hours from your settings.

In resulted deficit data for clay, you see only the number of clay needed for village X or for village X+y?

My best guess, since it's working if you increase construction time, it's s rounding issue somewhere on the code.
More so others are aware, we spoke about this in Discord DMs - was/is a bug relating to villages where farm is < 30 and more than 99% of pop is used. Here, villages are sent the resources required for the current level of the farm, not the next level. Cos said he'll get this fixed, holidays allowing.
 

lllll llll

Non-stop Poster
Reaction score
88
More so others are aware, we spoke about this in Discord DMs - was/is a bug relating to villages where farm is < 30 and more than 99% of pop is used. Here, villages are sent the resources required for the current level of the farm, not the next level. Cos said he'll get this fixed, holidays allowing.
This bug should be fixed now
 

K I N G S

Active Member
Reaction score
24
Instead of using XMLHttpRequest, why don't you use async/await? This prevents the user's UX from freezing.
 

fi5hii

New Member
Reaction score
3
could you update the script please? the latest update changed something and it doesn't see the AM queue properly anymore, it would prioritize a villa to send it resources to build for over 40 hours (when set to 12) and one of them would not be building anything. I think it usually doesn't send to a villa when the AM preset is on the "prioritize farm upgrade if pop lower than x%" it used to work with this but after TW updated it stopped working.

greatly appreciate if you would update it
 

lllll llll

Non-stop Poster
Reaction score
88
could you update the script please? the latest update changed something and it doesn't see the AM queue properly anymore, it would prioritize a villa to send it resources to build for over 40 hours (when set to 12) and one of them would not be building anything. I think it usually doesn't send to a villa when the AM preset is on the "prioritize farm upgrade if pop lower than x%" it used to work with this but after TW updated it stopped working.

greatly appreciate if you would update it
i fixed this bug
 

RedAlert

Senior In-Game Staff
Tribal Wars Team
Senior
Team
Script Moderator
Reaction score
723
i fixed this bug

Yet you seem to not have followed the script update procedure.

You need to send the script update for evaluation, before actually updating a script.
 

lllll llll

Non-stop Poster
Reaction score
88
Hello @RedAlert ,

I am sorry, i may have misunderstood the script rules.
rules.png
I only made a change to the script logic, no new interactions with the game.

I reverted my update and sending the script for reapproval.
 
Last edited:

RedAlert

Senior In-Game Staff
Tribal Wars Team
Senior
Team
Script Moderator
Reaction score
723
Hello @RedAlert ,

I am sorry, i may have misunderstood the script rules.
I only made a change to the script logic, no new interactions with the game.

I reverted my update and sending the script for reapproval.
Thank you!

Will evaluate it asap. Hopefully today.

Sorry to everyone affected but we have to follow the procedures and make sure that nobody is affected negatively by unchecked updates.
 

RedAlert

Senior In-Game Staff
Tribal Wars Team
Senior
Team
Script Moderator
Reaction score
723
Wasn't the script working before this script update?
I mean ... it might have done wrong calculations, but it worked. It did calculations. It showed a table with combinations to send.

It was working here:
Before the script update.

Now after the update has been reverted, this has shown:
1745873230136.png
And, it should not have shown logically.
 

lllll llll

Non-stop Poster
Reaction score
88
Wasn't the script working before this script update?
I mean ... it might have done wrong calculations, but it worked. It did calculations. It showed a table with combinations to send.

It was working here:
Before the script update.

Now after the update has been reverted, this has shown:
View attachment 13260
And, it should not have shown logically.
this is a different fix that i made. Icons were changed from .png to .webp from a previous tw update.
 

higamy

Well-Known Member
Reaction score
28
@lllll llll


Try with .webp ?

JavaScript:
//add queued buildings

//line 2246
let list_queued=Array.from($(table_buildings[i]).find(".queue_icon img")).map(e=>e.src.match(/\w+.png/)[0].replace(".png",""))
Modifying the script and running it without approval is bannable, we have to wait for the proper approval.
 
Top