Snoil mentions some very good points there. It is really helpful to plan who your allies are going to be from the start - it avoids you having allied countries that you end up wanting to attack later, and gives you a very clear road to follow (at least politically) throughout the campaign. That said, I have a point or two to add.
The first is that it is infinitely easier to keep allies when the following are true:
- they share no border with you
- they have bigger fish to fry
That is, borders create tension, and that tension often breaks an alliance - the computer will jump at the opportunity to invade one of your cities most of the time. The second point of course simply means it's helpful if your ally will be distracted a lot of the time - if they're busy fighting other countries, odds are they're not going to add you to their plate as well.
The other point is of course that the decision variables that tell the AI how to deal with alliances are currently disabled. They are set to values that are unattainable, so nothing you do can actually make the AI respect an alliance you have with it (for instance relations are on a -1.0 to 1.0 scale, and the threshold for a trusted relationship is set to 9.0). If you want a shot at having maintainable alliances, I strongly recommend you re-enable those variables with reasonable values. You can read about this further, and what to do if you'd like to enable the variables, here: https://forums.totalwar.org/vb/showthread.php?t=75496
Bookmarks