# How can I coordinate multiple attacks so that they all hit at the same time?

I am playing a game (Valor on iPad) and several people are attacking a single city. We're all different distances away and have various troops that have different travel times. We need to be able to pick a time for us to hit the city, then count back the travel durations to determine what time we need to kick off each unit's attack.

Yes, I can do this on paper, but there are so many units and so many starting cities that it'd be great if someone could show me how to use Excel or something to do the computations.

-
Pretty awesome question :) – iber Nov 2 '12 at 11:14
Reminds me of troubles with Travian - there you had a very similar problem, and people used online calculators for coordinated attacks. – Humungus Apr 27 '14 at 9:15
How are defined the speed of the unit? Second? Factor? And of the city? – DrakaSAN Aug 25 '14 at 16:06

Using variables in some kind of programming language would be the easiest, I think. I would just have a travel time variable for each location, and then a variable for each unit's travel time. Then just multiply the amount of each unit by that unit's travel time variable, then add or multiply that by the location travel time variable, depending on how the game works.

You could just do it on paper though, it might just take longer.

-
would you mind mentioning a basic algorithm for the solution? – DrFish Nov 2 '12 at 9:19

In javascript, assuming you can find the time of travel (in second) between the cities, and that the speed of the unit is a factor of that time (Unit1 take just that time, Unit2 is 1.5 slower...):

var unit = [{name: 'Unit1', factor:1},//Type of unit, with factor of speed
{name: 'Unit2', factor:1.5},
{name: 'Unit3', factor:1.7}],
city = [{name: 'City1', time:20},//City, and time of travel in second
{name: 'City2', time:25},
{name: 'City3', time:10}],
u = 0,
c = 0,
strike = new Date (2014, 11, 25, 12, 00),//Date and hour of the coordinated attack, 25 December 2014 at 12:00  for this example
time,
start;

while(c < city.length) {
console.log('City ' + city[c].name);
while(u < unit.length) {
time = (strike.getTime() - (city[c].time * unit[u].factor * 1000));
start = new Date(time);
console.log('\tUnit ' + unit[u].name + ' must start at ' + start);
u = u + 1;
}
c = c + 1;
u = 0;
}

You can run that on node.js, just change the name and variable.

(As example of output:

C:\Users\user>node valor.js
City City1
Unit Unit1 must start at Thu Dec 25 2014 11:59:40 GMT+0100 (Romance Standard Time)
Unit Unit2 must start at Thu Dec 25 2014 11:59:30 GMT+0100 (Romance Standard Time)
Unit Unit3 must start at Thu Dec 25 2014 11:59:26 GMT+0100 (Romance Standard Time)
City City2
Unit Unit1 must start at Thu Dec 25 2014 11:59:35 GMT+0100 (Romance Standard Time)
Unit Unit2 must start at Thu Dec 25 2014 11:59:22 GMT+0100 (Romance Standard Time)
Unit Unit3 must start at Thu Dec 25 2014 11:59:17 GMT+0100 (Romance Standard Time)
City City3
Unit Unit1 must start at Thu Dec 25 2014 11:59:50 GMT+0100 (Romance Standard Time)
Unit Unit2 must start at Thu Dec 25 2014 11:59:45 GMT+0100 (Romance Standard Time)
Unit Unit3 must start at Thu Dec 25 2014 11:59:43 GMT+0100 (Romance Standard Time)

)

PS: Careful with the date, month are 0 based (January is 0, December is 11).

PS bis: If someone know the way timing is calculated ingame, I d be thankful he post in comment so I can make this script useful.

-