It's very rare that the computer allies with anyone. If you want to ally with someone, have them in the same Team as you.
The computer does have a bad habit of donating resources to you in amounts of 100 and it can lag like hell at times, especially if it feels generous and gives you 500 of each in 100 amounts! LOL
So if you want teams to be set, it would be easier to set them yourself before battle.