RedAlert

Senior In-Game Staff
Tribal Wars Team
Senior
Team
Script Moderator
Reaction score
608
Author
RedAlert
Contributors
b@ldr
Quickbar Entry
javascript:$.getScript('https://twscripts.dev/scripts/massAttackPlanner.js');
Public?
Public
Mass Attack Planner

Approved: t14001534

This is a mass attack planner script.

mass-attack-planner.jpg

Here is how it works:

The script does not necessarily require PA to be used.
The script does require popups to be allowed on the browser.

The script itself can work even if you supply it with a large amount of villages. So you could tell the script to prepare a plan to attack like 20 villages and have to send on each target village 3 clearing nukes + 1 noble train + 1 support ... the script wont have a problem preparing the plan ... but you wont be able to save this kind of plan on the ingame Notebook (because of the bracket limitation).

For any bugs, suggestions, questions and or if you need help with the script, let me know by replying on the thread.
 
Last edited:
Upvote 4

ScrubLords

Member
Reaction score
14
Wow, such a nice planner. Thank you for doing this.

Suggestion: Is it possible to add an attack link like what the advance attack planner app does?
 

RedAlert

Senior In-Game Staff
Tribal Wars Team
Senior
Team
Script Moderator
Reaction score
608
@tawewet , you mean that when the "From" village is clicked, to send you to the rally point directly?

I havent used Advanced Attack Planner (if that is the one that requires Adobe Air to be installed)

Red.
 

ScrubLords

Member
Reaction score
14
Yeah AAP requires adobe to install. It has a feature where it includes a link on the exported data that sends you to the rally point and the target's coordinates already filled up. Other than that suggestion, the script is definitely one of the best out there.
 

RedAlert

Senior In-Game Staff
Tribal Wars Team
Senior
Team
Script Moderator
Reaction score
608
Yeah AAP requires adobe to install. It has a feature where it includes a link on the exported data that sends you to the rally point and the target's coordinates already filled up. Other than that suggestion, the script is definitely one of the best out there.
Thank you, regarding your suggestion. Currently that is not possible. It will need some changes (couple of them actually to make that happen).

I dont know if im gonna ever do that honestly because im planning on another version which changes radically from this one but does the same thing.

Red.
 

RedAlert

Senior In-Game Staff
Tribal Wars Team
Senior
Team
Script Moderator
Reaction score
608
How exactly the algoritm works?
It loops through all the targeted villages and loops through all attacking villages to calculate time differences between them.

Red.
 

lodi94

Active Member
Reaction score
29
It loops through all the targeted villages and loops through all attacking villages to calculate time differences between them.

Red.


This approach (used by all the planner i have seen) may be problematic and can lead to really bad assignment. I made a simple example of why i think this algorithm is deeply flawed.
cacca.jpeg

Imagine having two villages:
A (500|500)
B (505|500)
and you want to attack two enemies:
1 (500|505)
2 (504|500)

the distances between the villages will be:
AB
15sqrt(50) = 7.07
241

What the algorithm will do?
He will see which target is closest to A, create the first "couple" (A-2, distance 4) and then pair the other two villages(B-1, distance 7.07).
The total travel distance for the nukes will be 4+7.07=11 when the most logical choice would be A-1 B-2 whith a total travel distance of 6.
Of course you can change the order of the villages to get the rigth one, but when you are planning lot of nukes on lot of targets it would be really hard to spot and fix manually similar situation.
There are several ways to find the "minimum total travel time solution"; i digged a little and i think the best one is using the "Lap-Jv" algorithm. I made a working planner prototype using python and he seems to work well but it's really user-unfriendly. I'm trying to make an usable one whith js but i suck at coding so i'm really slow and the result will be 100x uglier than yours.
Here there is an example of js implementation, if you coul add to your script the option to use it i think that would be a huge improvement over every other existing planner

(sorry for my bad english and the long speech)
 

RedAlert

Senior In-Game Staff
Tribal Wars Team
Senior
Team
Script Moderator
Reaction score
608
@lodi94 I know the algorithm is not perfect. The end result, what the script creates is an attack plan which still needs to be checked from our imaginative brains (and i think that is how it should be). I know everyone expects more.

Thanks also for providing that repo link. Having to deal with find shortest time (or more in general optimisation algorithms like traveling salesman algo or shortest path between nodes in a graph) that's usually relatively hard thing to do.

For the future i might add your recommandation but for the moment I'm not working on this right now, focused on other scripts., If your recommandation gets implemented, probably it will on Mass Attack Planner v2 (which will be a total re-write on the UI and probably even logic behind it, still thinking on the logic part).

To close this off, I dont want to make things this easy and to remove "completely" the need for the player. Such a script is very powerfu (especially if its even better then it currently is) and if connected with the right stuff could mean that a player never has to do anything on his/her account other then just running scripts which will do everything for him/her (dont think this is how we wanna play the game).

Red.
 
Last edited:

ScrubLords

Member
Reaction score
14
I've noticed some wrong launch times, happened couple of times already where the launch time is earlier by 1 hour.
 

RedAlert

Senior In-Game Staff
Tribal Wars Team
Senior
Team
Script Moderator
Reaction score
608
Earlier by 1 hour? Have you tested this with the ingame built attack planner?
Thats what i use as the gold standard to test if the results my planner creates are correct. Havent been able to reproduce this issue with 1h difference ...

Red.
 

Strong Hand

Active Member
Reaction score
14
Great looking so far, but on w114 with the noble package system using a full train (at least this early) doesn't seem too viable. Also with the 150ms trains its sniping heaven, so maybe an option for villages with 2 nobles a piece would be more useful in this situation!
 

ScrubLords

Member
Reaction score
14
@misteralb Yeah we got wrong launch times only on the support launches. Noticed that it happened when we're sending support to multiple village under 1 plan.
 

RedAlert

Senior In-Game Staff
Tribal Wars Team
Senior
Team
Script Moderator
Reaction score
608
Interesting. I havent been able to replicate this but i will double check.

I havent personaly tested the script that much because the current world im playing is almost finished, nothing to attack there anymore.

Red.
 

Deleted User - 11595623

Guest
I wrote one of these many years ago and used a least cost algorithm - where one of the inputs was preferred launch time (different ones for each player) and anything outside of that incurred a higher cost - travel time was of course one of the other costs.

but anyhow - a simpler request ... the output is pretty simple ... and doesn't really need a table ...

please could that be made optional or even removed - then this planner would be more widely useful, as the only place that supports tables is the forum, and of course plans could be made bigger as you'll hit the bracket limitation much later...

maybe the fixed length stuff at the beginning (type and time) and each 'row' on a new line...

cheers
Slow
 

RedAlert

Senior In-Game Staff
Tribal Wars Team
Senior
Team
Script Moderator
Reaction score
608
Hi @slowtarget ,

Regarding changing the algorithm its something I haven't considered, not at the moment at least. But im planning on rewriting the script so probably at that time might do that also.

Regarding your other suggestion to remove tables, since that was a problem (when you calculated big plans you could not save those plans on the Notebook because of the bracket limitation) I removed table support. Now the script generates table-less attack plan. Its not an universal solution, so again for very big plans, you might end up not being able to save that plan on the Notebook but at least you should be able to save a bigger plan on the Notebook.

However, I would not recommend generating big plans even though Notebook might be able now to handle them.

For those who know programming the scripts complexity is O(n2) so its not the best. Passing it to many variables (too many villages in our case) it increases exponentially the time needed to execute the script (passing the script a lot of villages ... it could end up blocking the browser).

Red.
 

RedAlert

Senior In-Game Staff
Tribal Wars Team
Senior
Team
Script Moderator
Reaction score
608
Hello guys, I have updated the script to make it more dynamic. Changed also the way how time was being calculated so the planner should be more precise right now. I had noticed sometime a time difference of 1s between the plan generated using this script and plan generated for example using the Attack Planner built in into the TW Stats. That bug should not exist anymore.
 

.MAXIMUS.

Well-Known Member
Reaction score
18
I really appreciate your work.

Could you implement the following commands to this script?

1. A "SEND" button.
2. Add a "wall breaker" villages section
3. Ability to use own groups when selecting nukes/wall breakers/nobles/support villages.
 
Last edited:
Top