I prefer to make my weak units (ashigaru) into more deep ranks when fighting enemy's stronger units and the stronger units (all kinds of samurai/monks) into more thin formations when fighting enemy's weak units.
I believe that for instance spear ashigaru will last a bit longer if you have a deep formation, and this gives a bit more time for flanking with other units etc.
So, in short, maximise your offense when you are winning unit vs. unit (wide and thin formation) and minimize your losses (deep formation) when losing unit vs. unit.
Bookmarks