So, how and when AI civs change their government.
1) every turn (after main city loop) AI checks if anarchy flag (diplomacy bit 'ALLY' with barbarians) is 1. If it's so, it calls 'change govt' function which in this case just sets anarchy flag to 0. This means that AI revolution always takes 1 turn. If you have embassy, you will get 'AI government changes to X!' message here.
2) human player, on the other hand, doesn't use this anarchy flag and instead changes its government to ANARCHY (0) during revolution. AI never goes through the anarchy as government number 0, it sets new govt immediately and instead of 'true anarchy' it just sets 'anarchy flag' to 1. Game uses 'anarchy flag' for human player only for 'democratic government collapsed' event. In this case, when game should give you a new govt selection menu it instead just sets 'anarchy flag' to 0. That's why in this case the anarchy period is much longer (8 turns max instead of 4). EDIT: actually, because govt selection menu is called right after city loop, there's a chance that "democracy collapsed" flag will be canceled immediately at the same turn, so anarchy duration in this case actually is not 5..8 turns, but 4..7 (normal anarchy duration is 1..4). Also, with Pyramids after collapse you will get govt selection menu immediately after city loop, at the same turn...
3) AI tries to change its govt every 8th turn, if remainder of (civ_number+game_turn)/8 is 0 (also if civ is not barbarians and not with bit flag 'human player'). If AI chose some govt, it will call 'change govt' function. If 'new' govt is different from the old one, you will get message 'The AI government has been overthrown!' and anarchy flag will be set to 1. Replay entry is also recorded here (when AI goes into anarchy state, not when it goes from it!). But even if 'new' govt is the same, AI will still change its tax rate (see https://forums.civfanatics.com/thre...ogic-tax-science-luxuries-distribution.657037). This basically means AI usually resets its tax rate every 8 turns.
Logic to change goverment here is following:
As you can see, there's no Pyramids in these rules. Pyramids are useless for AI. Also (as expected, because no one in 30 years has ever seen that) AI can't choose Democracy.
And about these 'despotism_desire' and 'republic_desire' variables and how they are calculated - in the next post...
4) when AI changes it's govt (goes to anarchy) it forgets all vendettas, means it will no more be upset about your (and others AIs) previous sneak attacks.
1) every turn (after main city loop) AI checks if anarchy flag (diplomacy bit 'ALLY' with barbarians) is 1. If it's so, it calls 'change govt' function which in this case just sets anarchy flag to 0. This means that AI revolution always takes 1 turn. If you have embassy, you will get 'AI government changes to X!' message here.
2) human player, on the other hand, doesn't use this anarchy flag and instead changes its government to ANARCHY (0) during revolution. AI never goes through the anarchy as government number 0, it sets new govt immediately and instead of 'true anarchy' it just sets 'anarchy flag' to 1. Game uses 'anarchy flag' for human player only for 'democratic government collapsed' event. In this case, when game should give you a new govt selection menu it instead just sets 'anarchy flag' to 0. That's why in this case the anarchy period is much longer (8 turns max instead of 4). EDIT: actually, because govt selection menu is called right after city loop, there's a chance that "democracy collapsed" flag will be canceled immediately at the same turn, so anarchy duration in this case actually is not 5..8 turns, but 4..7 (normal anarchy duration is 1..4). Also, with Pyramids after collapse you will get govt selection menu immediately after city loop, at the same turn...
3) AI tries to change its govt every 8th turn, if remainder of (civ_number+game_turn)/8 is 0 (also if civ is not barbarians and not with bit flag 'human player'). If AI chose some govt, it will call 'change govt' function. If 'new' govt is different from the old one, you will get message 'The AI government has been overthrown!' and anarchy flag will be set to 1. Replay entry is also recorded here (when AI goes into anarchy state, not when it goes from it!). But even if 'new' govt is the same, AI will still change its tax rate (see https://forums.civfanatics.com/thre...ogic-tax-science-luxuries-distribution.657037). This basically means AI usually resets its tax rate every 8 turns.
Logic to change goverment here is following:
Code:
IF despotism_desire < 1
THEN
IF civ DOESN'T know REPUBLIC advance OR republic_desire < 0
THEN
IF civ DOESN'T know COMMUNISM advance or number of cities < 11
THEN IF civ DOESN'T know MONARCHY advance
DON'T DO ANYTHING;
ELSE
SET GOVT TO MONARCHY;
ELSE
SET GOVT TO COMMUNISM;
ELSE
SET GOVT TO REPUBLIC;
ELSE
SET GOVT TO DESPOTISM;
And about these 'despotism_desire' and 'republic_desire' variables and how they are calculated - in the next post...
4) when AI changes it's govt (goes to anarchy) it forgets all vendettas, means it will no more be upset about your (and others AIs) previous sneak attacks.
Last edited: