You roll separately whenever units that can’t hit other units are involved. Rolling together and assigning the rolls to the units of your choice violates the principle that the owner of the hit units chooses casualties.
@aardvarkpepper Well if you are interested in developing an AI or improving the AI for A&A games and for an implementation much closer to the actual game then you should consider TripleA as we are always looking for contributions: https://github.com/triplea-game/triplea