lllll llll

Well-Known Member
Reaction score
62
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: 435
Last edited:
Upvote 7

lllll llll

Well-Known Member
Reaction score
62
Hello @Steelbread69,


When you want to grow barbs ideally is to make sure the surplus is greater than deficit for each type of resource, you can do that by adjusting either construction time or average factor, if surplus is smaller than deficit it's not a big problem, what will happen is instead of having resources for 6 hours as you wanted you may have resources only for 4-5 hours.

Now about your specific case where you have 1 cluster almost fully built up and the other one not, I assume your surplus is way higher than your deficit. Let's say you have 10 villages built up with 10k surplus each res and 10 small villages with deficit 5k each res, in this case in total you will have 100k surplus each res and 50k deficit each res. What will happen is you will be sending resources only from your first 5 built up villages, the deficit will be covered and at the end your last 5 built up villages will not be sending anything because none of your villages are still need resources. This is just an example, in reality it's way more complicated because each village that needs resources will receive resources from the closest villages that have a surplus of resources. This functionality is not a bug, it's working exactly how it was designed to work, bear in mind the first 5 built up villages from where the resources are sent are the closest to villages which need resources, for me at least i'd prefer my merchants to travel the least amount of time possible instead of making sure every single village send resources no matter where they are and how long it takes.

If you really want to send resources from every single built up village then what you should do is to adjust the settings until you have the surplus almost equal with deficit or even a smaller than surplus.


There is another case which could make the script to work weirdly, when you have a huge surplus for only one type of res, lets say you have plenty of villages with 100k wood, 100k stone and 300k iron and only 100 merchants available, in best case scenario you can only send 20k wood, 20k stone and 60k iron, these values are calculated proportionally to the amount of res for each type available village.


One more thing, for growing barbs i wouldn't say this script is a resource balancer, it's more likely a manager resources script where you send resources strictly where it's need it based on AM construction and no more then you ask for. I personally wouldn't want to send and waste resources on a barb where is already queued over 20 hours of buildings.
 
Last edited:

Steelbread69

New Member
Reaction score
0
Thank you for your explenation. I played a bit with the settings (average factor and construction time) and I think I know now how the script works. It makes sense that res gets sent from the closest village with a surplus. The villages that I mentioned, that didn't send any res were the ones that were the furthest away.

Just one more question about villages that aren't managed by AM (fully built up villages): If i set average factor to 0.0, would that mean that those villages don't get any res and send all their own res (down to 0) away if it's needed somewhere else?
 

lllll llll

Well-Known Member
Reaction score
62
Just one more question about villages that aren't managed by AM (fully built up villages): If i set average factor to 0.0, would that mean that those villages don't get any res and send all their own res (down to 0) away if it's needed somewhere else?

You are right, if average factor is set to 0 and AM is off then every single resource is seen as surplus and it's available to be sent wherever is needed
 

EARTHBOUND

Active Member
Reaction score
19
Assuming I have two sets of villages 1 + 2
Is there a possibility to make the script completely pull the resources from group number (1) and divide them evenly on group number (2)
 

Ceeed

New Member
Reaction score
0
Hi, great work. Best res balancer available.
Please add column with village name in the results table.
1654384832017.png
 

lllll llll

Well-Known Member
Reaction score
62
Assuming I have two sets of villages 1 + 2
Is there a possibility to make the script completely pull the resources from group number (1) and divide them evenly on group number (2)
For your case you may want to use this script res sender

Hi, great work. Best res balancer available.
Please add column with village name in the results table.
View attachment 11258

If i were to add village names instead of coords it would look like this.
Screenshot_10.png
In my opinion this is not an improvement because it is less readable. i'm waiting for other opinions.



edit: I forgot to mention on forum, since April the script is compatible with mobile app.
 
Last edited:

Ceeed

New Member
Reaction score
0
Imo it's quite readable. Maybe you can separate coords to another column. Like this:

NameCoordPoints...
0101.7 kira421|44010,580...
0085.4 kira434|45910,462...

EDIT: You can also add toggle in the options menu to show or hide column with names.
 

EARTHBOUND

Active Member
Reaction score
19
For your case you may want to use this script res sender



If i were to add village names instead of coords it would look like this.
In my opinion this is not an improvement because it is less readable. i'm waiting for other opinions.



edit: I forgot to mention on forum, since April the script is compatible with mobile app.
Thank you, nice script
 

Shinko to Kuma

Still Going Strong
Reaction score
776
Hey!
Just quick feedback, you might want to check if the map spawn sector has already been attached on the map screen, otherwise if the script gets rerun, you'll reattach map spawning again, and you'll end up with call stack errors like this

image.png

Nice work tho :D
 

fitzzero

New Member
Reaction score
2
Hello running into a strange issue with calculating village queue times. It seems that any village that has over 24 hours queued is returning `NaN` in the results. This then causes it to think it has no queue and to send even more resources to said village.

In the below screenshot, all the villages that show `NaN` next to them had over 24 hours queued on their headquarters but the calculation seems to break. It also wanted to send them a lot of unnecessary resources.

I was able to remove all the NaN's below by halving or cancelling existing queue times to reduce them below 24 hours and then re-running. Which also correctly reduced the amount of resources they were receiving.

- Tried Mobile IOS and Chrome
- Tried adjusting the construction time input, average factor, and number of clusters
- Same AM template applied to all


It might still be user error because sometimes when I queue a village over 24 hours it still works. But whenever I see a NaN it always has a long queue time.


1691983956068.png
 
Last edited:

lllll llll

Well-Known Member
Reaction score
62
Hello, I cannot replicate your issue.

What world have you test it on?
Is the server in English or other language?
Is this issue happening only on mobile or PC as well?

Can you make a print screen at production page to see how does time left for construction look like?
 

fitzzero

New Member
Reaction score
2
Hey thanks for the quick reply.

- This is happening on .us worlds on both Mobile and Desktop
- This is very strange, but I can no longer reproduce this by queuing a village above 24 hours. I even had a village at 35 hours that was calculating correctly, but when I increased it to 45 hours I was able to get NaN. Here are some additional screenshots of my reproduction.


Screenshots of it breaking:
1692030817786.png

Screenshots of it working (I cancelled the last thing on queue)
1692031064636.png

Summary:
Seems to only happen for me and for really long queues so I wouldn't say this is a high priority. My noob speculation is that it could be something to do with how long in the day is left. Last night when I was having this issue with 24 hr queues it was 23:50 (meaning 2 days away was only 24 hours and 10 min away) where as now that it's 12:00 (36 hours until next day) that's why things didn't break until queuing over 35 hours.


PS, I really vibe with some of your console log messages xD thanks again for all your hard work.
 

lllll llll

Well-Known Member
Reaction score
62
Hello, I don't think the problem is with queues over 24 hours, but because you have too many buildings queued

Look at production page where you have too many buildings queued and see if the layout of the page is different.

"time_queued => NaN" it means data was not found correctly in production page on "construction" column for some reason.

Check tomorrow between 23:50 - 00:00 on production page if construction time is shown correctly, I remember something weird was happening in that period of time , construction time finish was shown with +24 hours, but that was a long time ago and I'm not home to test it properly.
 

Attachments

  • Screenshot_2023-08-14-23-08-39-13_40deb401b9ffe8e1df2f1cc5ba480b12.jpg
    Screenshot_2023-08-14-23-08-39-13_40deb401b9ffe8e1df2f1cc5ba480b12.jpg
    240.8 KB · Views: 16
Last edited:
Top