Renew alliances
In this guide, we will learn how to keep alliances active by renewing them before they expire. We will use Controller.renew_alliance, and optionally the helper Controller.get_alliances_to_renew.
Each alliance has an expiration tick (expiresAt, see SimplifiedAlliance). If both players do not ask for renewal in time, the alliance expires.
The easiest pattern is:
- Use
get_alliances_to_reneweach loop - Call
renew_alliancefor every returned ally
python
# Find alliances that are close to expiration, then renew them.
alliances_to_renew = controller.get_alliances_to_renew(state) # default: 600 ticks (~60s)
for ally_id in alliances_to_renew:
await controller.renew_alliance(ally_id)java
// Find alliances that are close to expiration, then renew them.
List<PlayerID> alliancesToRenew = controller.getAlliancesToRenew(state, 600);
for (PlayerID allyId : alliancesToRenew) {
controller.renewAlliance(allyId);
}Possible improvements:
- Renew trusted allies earlier than others.
- Skip renewal if the ally recently attacked you or broke another alliance.
- Send a quick chat reminder to allies that are near expiration.
