You should try using DarthsFormations mod, it makes the ai use the phalanxes much better by giving set formations to use in certain circumstances.