1
\$\begingroup\$

I have a Array data structure right now, which contains 10 soldiers in my army.

They can setup initially in various formations - e.g.

 o  o  o 
 o  o  o
o  o  o  o

The user can move one of the soldier(currently selected) with the joystick.

 o  o  o 
 o  o  o
o  o  o  
         o

When he moves I want to automatically adjust the rest of the soldiers position so that they occupy equal areas in the scene, as well as still follow their orignal formation to some extent.

Somehow like this http://arborjs.org/halfviz/#/Mzg

How do I do this? What kind of algorithms should I look at? How should store my soldiers? which data structure?

\$\endgroup\$