I have a field of tiles - basically each tile is a country that has some kind of sovereign. The tiles - countries - have different weight. For now I use some numerical value but in the future the weight will depend on tile size, produced resources and so on.
So I want for those countries to make alliances if their sole weight is much lower - or at least lower than a certain threshold - than the weight of the neighborhood tile (each sovereign is basically a primitive AI at that stage that is able to make decision to create the alliance). Here is couple of scenarios
Here are the examples for bigger maps with possible alliances
So my question is - is there some kind of algorithm that allows to achieve that or I have to create it myself or use training sets for AI to gain the ability to form alliances?