the AI's choice of ideology is still a mystery to me for the most part
When hitting point to select it the first time:
1. For every ideology, add points per each free tenet still available. (This is a LARGE number if both are still out)
2. For every player in the game who already has an ideology, if I like the player, add points to that one (in porportion to how much I like them). If I dislike a player, subtract points from one (in proportion to how much I dislike them)
3. Some points given to ideology from tourism pressure.
4. ZERO OUT points for ideology that doesn't have a level 3 tenet designed for my chosen victory. (In effect, those seeking Domination will never choose Freedom, those seeking Diplomatic will never choose Order, those seeking Space Race will never choose Autocracy)
5. It normalizes all numbers such that the total is a nice round number to make the dice roll check easier (for humans to understand / computer wouldn't have cared)
Now, AI deciding to change ideology is completely different and amounts to a weighted dice roll if the AI is both experiencing ideological unhappiness and is overall unhappy. If that number is selected, AI in this case will always pick the ideology they are feeling the most pressure from.